Skip to content

Commit

Permalink
asdasdadasd new commit on my pr
Browse files Browse the repository at this point in the history
  • Loading branch information
ThereDrD0 committed Jan 2, 2025
1 parent 40fde6d commit d4de1de
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
27 changes: 15 additions & 12 deletions Content.Server/_Sunrise/DamageOverlay/DamageOverlaySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,26 @@ private async void OnDamageOverlayPresetChanged(DamageOverlayPresetChangedEvent
_playerSettings[args.SenderSession] = presetPrototype;
}

private void OnDamageChange(EntityUid uid, DamageOverlayComponent component, DamageChangedEvent args)
private void OnDamageChange(Entity<DamageOverlayComponent> ent, ref DamageChangedEvent args)
{
if (args.DamageDelta == null)
return;

var damageDelta = args.DamageDelta.GetTotal();
var coords = GenerateRandomCoordinates(Transform(uid).Coordinates, component.Radius);
var coords = GenerateRandomCoordinates(Transform(ent).Coordinates, ent.Comp.Radius);

// Проверка на игнорируемые типы урона
if (args.DamageDelta.DamageDict.Keys.Any(item => component.IgnoredDamageTypes.Contains(item)))
if (args.DamageDelta.DamageDict.Keys.Any(item => ent.Comp.IgnoredDamageTypes.Contains(item)))
return;

if (_mindSystem.TryGetMind(uid, out _, out var mindTarget) && mindTarget.Session != null)
if (_mindSystem.TryGetMind(ent, out _, out var mindTarget) && mindTarget.Session != null)
{
if (IsDisabledByClient(mindTarget.Session, component, args.DamageDelta))
if (IsDisabledByClient(mindTarget.Session, ent, args.DamageDelta))
return;

if (damageDelta > 0)
{
_popupSystem.PopupCoordinates($"-{damageDelta}", coords, mindTarget.Session, component.DamagePopupType);
_popupSystem.PopupCoordinates($"-{damageDelta}", coords, mindTarget.Session, ent.Comp.DamagePopupType);
}
}

Expand All @@ -80,20 +80,20 @@ private void OnDamageChange(EntityUid uid, DamageOverlayComponent component, Dam
if (!_mindSystem.TryGetMind(args.Origin.Value, out _, out var mindOrigin) || mindOrigin.Session == null)
return;

if (IsDisabledByClient(mindOrigin.Session, component, args.DamageDelta))
if (IsDisabledByClient(mindOrigin.Session, ent, args.DamageDelta))
return;

if (damageDelta > 0)
{
// Ударили себя
if (args.Origin == uid)
if (args.Origin == ent)
return;

_popupSystem.PopupCoordinates($"-{damageDelta}", coords, mindOrigin.Session, component.DamagePopupType);
_popupSystem.PopupCoordinates($"-{damageDelta}", coords, mindOrigin.Session, ent.Comp.DamagePopupType);
}
else
{
_popupSystem.PopupCoordinates($"+{FixedPoint2.Abs(damageDelta)}", coords, mindOrigin.Session, component.HealPopupType);
_popupSystem.PopupCoordinates($"+{FixedPoint2.Abs(damageDelta)}", coords, mindOrigin.Session, ent.Comp.HealPopupType);
}
}

Expand All @@ -118,7 +118,7 @@ private EntityCoordinates GenerateRandomCoordinates(EntityCoordinates center, fl
/// <summary>
/// Проверка на то, включен ли у игрока данный урон для отображения
/// </summary>
private bool IsDisabledByClient(ICommonSession session, DamageOverlayComponent component, DamageSpecifier damageDelta)
private bool IsDisabledByClient(ICommonSession session, Entity<DamageOverlayComponent> target, DamageSpecifier damageDelta)
{
if (_disabledSessions.Contains(session))
return true;
Expand All @@ -128,7 +128,10 @@ private bool IsDisabledByClient(ICommonSession session, DamageOverlayComponent c
if (damageDelta.DamageDict.Keys.Any(item => playerPreset.Types.Contains(item)))
return true;

if (component.IsStructure && !playerPreset.StructureDamageEnabled)
if (target.Comp.IsStructure && !playerPreset.StructureDamageEnabled)
return true;

if (target == session.AttachedEntity && !playerPreset.ToPlayerDamageEnabled)
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ public sealed partial class DamageOverlayPrototype : IPrototype

[DataField]
public bool StructureDamageEnabled = true;

[DataField]
public bool ToPlayerDamageEnabled = true;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ui-options-damage-overlay-preset = Типы всплывающего урона
damage-overlay-All = Весь урон
damage-overlay-Primitive = Только базовый урон
damage-overlay-WithoutPlayer = Без урона по персонажу
damage-overlay-AllWithoutStructures = Весь урон, без структур
damage-overlay-PrimitiveWithoutStructures = Только базовый урон, без структур
damage-overlay-WithoutPlayerWithoutStructures = Без урона по персонажу, без структур
24 changes: 4 additions & 20 deletions Resources/Prototypes/_Sunrise/DamageOverlay/presets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,14 @@
id: All

- type: damageOverlay
id: Primitive
types:
- Cellular
- Radiation
- Poison
- Bloodloss
- Asphyxiation
- Genetic
- Toxin
- Airloss
id: WithoutPlayer
toPlayerDamageEnabled: false

- type: damageOverlay
id: AllWithoutStructures
structureDamageEnabled: false

- type: damageOverlay
id: PrimitiveWithoutStructures
id: WithoutPlayerWithoutStructures
structureDamageEnabled: false
types:
- Cellular
- Radiation
- Poison
- Bloodloss
- Asphyxiation
- Genetic
- Toxin
- Airloss
toPlayerDamageEnabled: false

0 comments on commit d4de1de

Please sign in to comment.