From d4de1debe390c34d37a3e3d3cd19f2b1d52214b2 Mon Sep 17 00:00:00 2001 From: drdth Date: Thu, 2 Jan 2025 08:46:30 +0300 Subject: [PATCH] asdasdadasd new commit on my pr --- .../DamageOverlay/DamageOverlaySystem.cs | 27 ++++++++++--------- .../DamageOverlay/DamageOverlayPrototype.cs | 3 +++ .../_sunrise/damage-overlay/presets.ftl | 4 +-- .../_Sunrise/DamageOverlay/presets.yml | 24 +++-------------- 4 files changed, 24 insertions(+), 34 deletions(-) diff --git a/Content.Server/_Sunrise/DamageOverlay/DamageOverlaySystem.cs b/Content.Server/_Sunrise/DamageOverlay/DamageOverlaySystem.cs index 412bbcef42c..2af43772fa6 100644 --- a/Content.Server/_Sunrise/DamageOverlay/DamageOverlaySystem.cs +++ b/Content.Server/_Sunrise/DamageOverlay/DamageOverlaySystem.cs @@ -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 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); } } @@ -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); } } @@ -118,7 +118,7 @@ private EntityCoordinates GenerateRandomCoordinates(EntityCoordinates center, fl /// /// Проверка на то, включен ли у игрока данный урон для отображения /// - private bool IsDisabledByClient(ICommonSession session, DamageOverlayComponent component, DamageSpecifier damageDelta) + private bool IsDisabledByClient(ICommonSession session, Entity target, DamageSpecifier damageDelta) { if (_disabledSessions.Contains(session)) return true; @@ -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; } diff --git a/Content.Shared/_Sunrise/DamageOverlay/DamageOverlayPrototype.cs b/Content.Shared/_Sunrise/DamageOverlay/DamageOverlayPrototype.cs index a3194d2ec33..2d42eed1d5b 100644 --- a/Content.Shared/_Sunrise/DamageOverlay/DamageOverlayPrototype.cs +++ b/Content.Shared/_Sunrise/DamageOverlay/DamageOverlayPrototype.cs @@ -12,4 +12,7 @@ public sealed partial class DamageOverlayPrototype : IPrototype [DataField] public bool StructureDamageEnabled = true; + + [DataField] + public bool ToPlayerDamageEnabled = true; } diff --git a/Resources/Locale/ru-RU/_strings/_sunrise/damage-overlay/presets.ftl b/Resources/Locale/ru-RU/_strings/_sunrise/damage-overlay/presets.ftl index 132b26362be..b78386f062e 100644 --- a/Resources/Locale/ru-RU/_strings/_sunrise/damage-overlay/presets.ftl +++ b/Resources/Locale/ru-RU/_strings/_sunrise/damage-overlay/presets.ftl @@ -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 = Без урона по персонажу, без структур diff --git a/Resources/Prototypes/_Sunrise/DamageOverlay/presets.yml b/Resources/Prototypes/_Sunrise/DamageOverlay/presets.yml index 135279e95d2..0044a0a53cb 100644 --- a/Resources/Prototypes/_Sunrise/DamageOverlay/presets.yml +++ b/Resources/Prototypes/_Sunrise/DamageOverlay/presets.yml @@ -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