From ab43b9d54d8faa6cdfb75ff8c0c449bc6ea63fd9 Mon Sep 17 00:00:00 2001 From: drdth Date: Wed, 1 Jan 2025 06:33:32 +0300 Subject: [PATCH 01/14] damage overlay refactor: new visuals and ignored damage types feature --- Content.Client/Popups/PopupUIController.cs | 6 ++ .../DamageOverlay/DamageOverlayComponent.cs | 25 +++++++- .../DamageOverlay/DamageOverlaySystem.cs | 59 ++++++++++++++----- Content.Shared/Popups/SharedPopupSystem.cs | 1 + 4 files changed, 75 insertions(+), 16 deletions(-) diff --git a/Content.Client/Popups/PopupUIController.cs b/Content.Client/Popups/PopupUIController.cs index 05c3f793451..9f18490e88b 100644 --- a/Content.Client/Popups/PopupUIController.cs +++ b/Content.Client/Popups/PopupUIController.cs @@ -71,6 +71,12 @@ public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, font = _mediumFont; color = Color.Red; break; + // Sunrise edit start + case PopupType.MediumGreen: + font = _mediumFont; + color = Color.LightGreen; + break; + // Sunrise edit end case PopupType.Large: font = _largeFont; color = Color.LightGray; diff --git a/Content.Server/_Sunrise/DamageOverlay/DamageOverlayComponent.cs b/Content.Server/_Sunrise/DamageOverlay/DamageOverlayComponent.cs index 95f4ab2a812..fb0ae0913fc 100644 --- a/Content.Server/_Sunrise/DamageOverlay/DamageOverlayComponent.cs +++ b/Content.Server/_Sunrise/DamageOverlay/DamageOverlayComponent.cs @@ -1,7 +1,30 @@ -namespace Content.Server._Sunrise.DamageOverlay; +using Content.Shared.Popups; + +namespace Content.Server._Sunrise.DamageOverlay; [RegisterComponent, Access(typeof(DamageOverlaySystem))] public sealed partial class DamageOverlayComponent : Component { + [DataField] + public PopupType DamagePopupType = PopupType.MediumCaution; + + [DataField] + public PopupType HealPopupType = PopupType.LargeGreen; + + [DataField] + public float Radius = 0.5f; + [DataField] + public HashSet IgnoredDamageTypes = new () + { + "Cellular", + "Radiation", + "Poison", + "Bloodloss", + "Asphyxiation", + // Эти тоже, потому что может прийти урон по группе + "Genetic", + "Toxin", + "Airloss", + }; } diff --git a/Content.Server/_Sunrise/DamageOverlay/DamageOverlaySystem.cs b/Content.Server/_Sunrise/DamageOverlay/DamageOverlaySystem.cs index e82a41422e6..495f9b7e4e5 100644 --- a/Content.Server/_Sunrise/DamageOverlay/DamageOverlaySystem.cs +++ b/Content.Server/_Sunrise/DamageOverlay/DamageOverlaySystem.cs @@ -1,10 +1,13 @@ +using System.Linq; +using System.Numerics; using Content.Server.Mind; using Content.Server.Popups; using Content.Shared._Sunrise.DamageOverlay; using Content.Shared.Damage; using Content.Shared.FixedPoint; -using Content.Shared.Popups; +using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Random; namespace Content.Server._Sunrise.DamageOverlay; @@ -12,12 +15,14 @@ public sealed class DamageOverlaySystem : EntitySystem { [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly MindSystem _mindSystem = default!; + [Dependency] private readonly IRobustRandom _random = default!; private readonly List _disabledSessions = new(); public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnDamageChange); SubscribeNetworkEvent(OnDamageOverlayOption); } @@ -36,6 +41,11 @@ private void OnDamageChange(EntityUid uid, DamageOverlayComponent component, Dam return; var damageDelta = args.DamageDelta.GetTotal(); + var coords = GenerateRandomCoordinates(Transform(uid).Coordinates, component.Radius); + + // Проверка на игнорируемые типы урона + if (args.DamageDelta.DamageDict.Keys.Any(item => component.IgnoredDamageTypes.Contains(item))) + return; if (_mindSystem.TryGetMind(uid, out _, out var mindTarget) && mindTarget.Session != null) { @@ -44,29 +54,48 @@ private void OnDamageChange(EntityUid uid, DamageOverlayComponent component, Dam if (damageDelta > 0) { - _popupSystem.PopupEntity($"-{damageDelta}", uid, mindTarget.Session, PopupType.LargeCaution); + _popupSystem.PopupCoordinates($"-{damageDelta}", coords, mindTarget.Session, component.DamagePopupType); } } if (args.Origin == null) return; - if (_mindSystem.TryGetMind(args.Origin.Value, out _, out var mindOrigin) && mindOrigin.Session != null) + if (!_mindSystem.TryGetMind(args.Origin.Value, out _, out var mindOrigin) || mindOrigin.Session == null) + return; + + if (_disabledSessions.Contains(mindOrigin.Session)) + return; + + if (damageDelta > 0) { - if (_disabledSessions.Contains(mindOrigin.Session)) + // Ударили себя + if (args.Origin == uid) return; - if (damageDelta > 0) - { - if (args.Origin == uid) - return; - - _popupSystem.PopupEntity($"-{damageDelta}", uid, mindOrigin.Session, PopupType.LargeCaution); - } - else - { - _popupSystem.PopupEntity($"+{FixedPoint2.Abs(damageDelta)}", uid, mindOrigin.Session, PopupType.LargeGreen); - } + _popupSystem.PopupCoordinates($"-{damageDelta}", coords, mindOrigin.Session, component.DamagePopupType); + } + else + { + _popupSystem.PopupCoordinates($"+{FixedPoint2.Abs(damageDelta)}", coords, mindOrigin.Session, component.HealPopupType); } } + + private EntityCoordinates GenerateRandomCoordinates(EntityCoordinates center, float radius) + { + // Случайное направление в радианах. + var angle = _random.NextDouble() * 2 * Math.PI; + + // Случайное расстояние от центра в пределах радиуса. + var distance = _random.NextDouble() * radius; + + // Вычисление смещения. + var offsetX = (float)(Math.Cos(angle) * distance); + var offsetY = (float)(Math.Sin(angle) * distance); + + // Создание новых координат с учетом смещения. + var newPosition = new Vector2(center.Position.X + offsetX, center.Position.Y + offsetY); + + return new EntityCoordinates(center.EntityId, newPosition); + } } diff --git a/Content.Shared/Popups/SharedPopupSystem.cs b/Content.Shared/Popups/SharedPopupSystem.cs index 9c093ba13b9..f660df2e681 100644 --- a/Content.Shared/Popups/SharedPopupSystem.cs +++ b/Content.Shared/Popups/SharedPopupSystem.cs @@ -191,6 +191,7 @@ public enum PopupType : byte /// Medium, MediumCaution, + MediumGreen, // Sunrise edit /// /// Large popups should be used for actions which may be important or very important to one or more users, /// but is not life-threatening. From b1c0a7545f8afc76fafac666dabc374a4c2808e6 Mon Sep 17 00:00:00 2001 From: drdth Date: Wed, 1 Jan 2025 06:42:33 +0300 Subject: [PATCH 02/14] remove unused popup types --- Content.Client/Popups/PopupUIController.cs | 6 ------ Content.Shared/Popups/SharedPopupSystem.cs | 1 - 2 files changed, 7 deletions(-) diff --git a/Content.Client/Popups/PopupUIController.cs b/Content.Client/Popups/PopupUIController.cs index 9f18490e88b..05c3f793451 100644 --- a/Content.Client/Popups/PopupUIController.cs +++ b/Content.Client/Popups/PopupUIController.cs @@ -71,12 +71,6 @@ public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, font = _mediumFont; color = Color.Red; break; - // Sunrise edit start - case PopupType.MediumGreen: - font = _mediumFont; - color = Color.LightGreen; - break; - // Sunrise edit end case PopupType.Large: font = _largeFont; color = Color.LightGray; diff --git a/Content.Shared/Popups/SharedPopupSystem.cs b/Content.Shared/Popups/SharedPopupSystem.cs index f660df2e681..9c093ba13b9 100644 --- a/Content.Shared/Popups/SharedPopupSystem.cs +++ b/Content.Shared/Popups/SharedPopupSystem.cs @@ -191,7 +191,6 @@ public enum PopupType : byte /// Medium, MediumCaution, - MediumGreen, // Sunrise edit /// /// Large popups should be used for actions which may be important or very important to one or more users, /// but is not life-threatening. From dff6a48bbb00cb964ba065e33e2b787668e8ddf3 Mon Sep 17 00:00:00 2001 From: drdth Date: Wed, 1 Jan 2025 21:37:55 +0300 Subject: [PATCH 03/14] add horizontal direction movement --- Content.Client/Popups/PopupOverlay.cs | 8 +++++++- Content.Client/Popups/PopupUIController.cs | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Content.Client/Popups/PopupOverlay.cs b/Content.Client/Popups/PopupOverlay.cs index 5a69457720a..9c81b5c8e44 100644 --- a/Content.Client/Popups/PopupOverlay.cs +++ b/Content.Client/Popups/PopupOverlay.cs @@ -97,8 +97,14 @@ private void DrawWorld(DrawingHandleScreen worldHandle, OverlayDrawArgs args, fl e => e == popup.InitialPos.EntityId || e == ourEntity, entMan: _entManager)) continue; + var horizontalDirection = 0f; + if (_entManager.TryGetComponent(ourEntity, out var transformComponent)) + { + horizontalDirection = transformComponent.Coordinates.X <= popup.InitialPos.X ? 1f : -1f; + } + var pos = Vector2.Transform(mapPos.Position, matrix); - _controller.DrawPopup(popup, worldHandle, pos, scale); + _controller.DrawPopup(popup, worldHandle, pos, scale, horizontalDirection); } } } diff --git a/Content.Client/Popups/PopupUIController.cs b/Content.Client/Popups/PopupUIController.cs index 05c3f793451..f7e1fb84fef 100644 --- a/Content.Client/Popups/PopupUIController.cs +++ b/Content.Client/Popups/PopupUIController.cs @@ -47,16 +47,17 @@ public void OnStateExited(GameplayState state) _popupControl = null; } - public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, Vector2 position, float scale) + // float horizontalDirection = 0f -1 for left, 1 for right. + public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, Vector2 position, float scale, float horizontalDirection = 0f) { var lifetime = PopupSystem.GetPopupLifetime(popup); // Keep alpha at 1 until TotalTime passes half its lifetime, then gradually decrease to 0. var alpha = MathF.Min(1f, 1f - MathF.Max(0f, popup.TotalTime - lifetime / 2) * 2 / lifetime); - var updatedPosition = position - new Vector2(0f, MathF.Min(8f, 12f * (popup.TotalTime * popup.TotalTime + popup.TotalTime))); var font = _smallFont; var color = Color.White.WithAlpha(alpha); + var useHorizontalDirection = false; switch (popup.Type) { @@ -70,6 +71,7 @@ public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, case PopupType.MediumCaution: font = _mediumFont; color = Color.Red; + useHorizontalDirection = true; break; case PopupType.Large: font = _largeFont; @@ -87,6 +89,14 @@ public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, // Sunrise-End } + if (!useHorizontalDirection) + horizontalDirection = 0f; + + // Calculate horizontal offset based on direction. + var horizontalOffset = horizontalDirection * MathF.Min(8f, 12f * popup.TotalTime); + // Adjust position to move both vertically and horizontally. + var updatedPosition = position + new Vector2(horizontalOffset, -MathF.Min(8f, 12f * (popup.TotalTime * popup.TotalTime + popup.TotalTime))); + var dimensions = handle.GetDimensions(font, popup.Text, scale); handle.DrawString(font, updatedPosition - dimensions / 2f, popup.Text, scale, color.WithAlpha(alpha)); } From 732a136679581f6fed54d52ee4fd30be73cbc660 Mon Sep 17 00:00:00 2001 From: drdth Date: Wed, 1 Jan 2025 21:48:01 +0300 Subject: [PATCH 04/14] fix default popup type --- Content.Server/_Sunrise/DamageOverlay/DamageOverlayComponent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/_Sunrise/DamageOverlay/DamageOverlayComponent.cs b/Content.Server/_Sunrise/DamageOverlay/DamageOverlayComponent.cs index fb0ae0913fc..8efb80de653 100644 --- a/Content.Server/_Sunrise/DamageOverlay/DamageOverlayComponent.cs +++ b/Content.Server/_Sunrise/DamageOverlay/DamageOverlayComponent.cs @@ -6,7 +6,7 @@ namespace Content.Server._Sunrise.DamageOverlay; public sealed partial class DamageOverlayComponent : Component { [DataField] - public PopupType DamagePopupType = PopupType.MediumCaution; + public PopupType DamagePopupType = PopupType.MediumCautionFloating; [DataField] public PopupType HealPopupType = PopupType.LargeGreen; From d7b399ac56101156bfd63a19935fe7e6b7893744 Mon Sep 17 00:00:00 2001 From: drdth Date: Wed, 1 Jan 2025 21:48:13 +0300 Subject: [PATCH 05/14] fix fix --- Content.Shared/Popups/SharedPopupSystem.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Content.Shared/Popups/SharedPopupSystem.cs b/Content.Shared/Popups/SharedPopupSystem.cs index 9c093ba13b9..ef30e37b4a7 100644 --- a/Content.Shared/Popups/SharedPopupSystem.cs +++ b/Content.Shared/Popups/SharedPopupSystem.cs @@ -186,11 +186,13 @@ public enum PopupType : byte /// Small, SmallCaution, + SmallFloating, // Sunrise /// /// Medium popups should be used for actions which are not spammable but may not be particularly important. /// Medium, MediumCaution, + MediumCautionFloating, // Sunrise /// /// Large popups should be used for actions which may be important or very important to one or more users, /// but is not life-threatening. From 686da1ba9ad2c1a3c8b5ec655dbf33fc6d9c4c53 Mon Sep 17 00:00:00 2001 From: drdth Date: Wed, 1 Jan 2025 21:48:35 +0300 Subject: [PATCH 06/14] fix fix fix --- Content.Client/Popups/PopupUIController.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Content.Client/Popups/PopupUIController.cs b/Content.Client/Popups/PopupUIController.cs index f7e1fb84fef..b1b7d3e6a9e 100644 --- a/Content.Client/Popups/PopupUIController.cs +++ b/Content.Client/Popups/PopupUIController.cs @@ -61,6 +61,11 @@ public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, switch (popup.Type) { + // Sunrise start + case PopupType.SmallFloating: + useHorizontalDirection = true; + break; + // Sunrise end case PopupType.SmallCaution: color = Color.Red; break; @@ -69,10 +74,16 @@ public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, color = Color.LightGray; break; case PopupType.MediumCaution: + font = _mediumFont; + color = Color.Red; + break; + // Sunrise start + case PopupType.MediumCautionFloating: font = _mediumFont; color = Color.Red; useHorizontalDirection = true; break; + // Sunrise end case PopupType.Large: font = _largeFont; color = Color.LightGray; From d40a3c6cbc4590d411d89dbce51e7f761f5c9a0c Mon Sep 17 00:00:00 2001 From: drdth Date: Wed, 1 Jan 2025 21:48:54 +0300 Subject: [PATCH 07/14] add damage overlay to structures --- Resources/Prototypes/Entities/Structures/base_structure.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Resources/Prototypes/Entities/Structures/base_structure.yml b/Resources/Prototypes/Entities/Structures/base_structure.yml index 0f017bf43da..e9d557a265d 100644 --- a/Resources/Prototypes/Entities/Structures/base_structure.yml +++ b/Resources/Prototypes/Entities/Structures/base_structure.yml @@ -29,6 +29,9 @@ voice: FactCore # Sunrise-TTS - type: StaticPrice price: 0 # Sunrise-TTS + - type: DamageOverlay + damagePopupType: SmallFloating + radius: 0.7 - type: entity # This means that it's not anchored on spawn. From fb5180ad5a9fda4d3a248fee3a1d3aef5ee279c0 Mon Sep 17 00:00:00 2001 From: drdth Date: Wed, 1 Jan 2025 22:14:28 +0300 Subject: [PATCH 08/14] comments + better implementation --- Content.Client/Popups/PopupOverlay.cs | 10 +++++++--- Content.Client/Popups/PopupUIController.cs | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Content.Client/Popups/PopupOverlay.cs b/Content.Client/Popups/PopupOverlay.cs index 9c81b5c8e44..a6be86bb0c4 100644 --- a/Content.Client/Popups/PopupOverlay.cs +++ b/Content.Client/Popups/PopupOverlay.cs @@ -97,14 +97,18 @@ private void DrawWorld(DrawingHandleScreen worldHandle, OverlayDrawArgs args, fl e => e == popup.InitialPos.EntityId || e == ourEntity, entMan: _entManager)) continue; + // Sunrise edit start var horizontalDirection = 0f; - if (_entManager.TryGetComponent(ourEntity, out var transformComponent)) + if (ourEntity.HasValue) { - horizontalDirection = transformComponent.Coordinates.X <= popup.InitialPos.X ? 1f : -1f; + var moverCoords = _transform.GetMoverCoordinates(ourEntity.Value); + // float horizontalDirection = 0f -1 for left, 1 for right. + horizontalDirection = moverCoords.X <= popup.InitialPos.X ? 1f : -1f; } + // Sunrise edit end var pos = Vector2.Transform(mapPos.Position, matrix); - _controller.DrawPopup(popup, worldHandle, pos, scale, horizontalDirection); + _controller.DrawPopup(popup, worldHandle, pos, scale, horizontalDirection); // Sunrise edit } } } diff --git a/Content.Client/Popups/PopupUIController.cs b/Content.Client/Popups/PopupUIController.cs index b1b7d3e6a9e..89b4911be36 100644 --- a/Content.Client/Popups/PopupUIController.cs +++ b/Content.Client/Popups/PopupUIController.cs @@ -47,7 +47,6 @@ public void OnStateExited(GameplayState state) _popupControl = null; } - // float horizontalDirection = 0f -1 for left, 1 for right. public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, Vector2 position, float scale, float horizontalDirection = 0f) { var lifetime = PopupSystem.GetPopupLifetime(popup); @@ -100,6 +99,7 @@ public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, // Sunrise-End } + // Sunrise edit start if (!useHorizontalDirection) horizontalDirection = 0f; @@ -107,6 +107,7 @@ public void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, var horizontalOffset = horizontalDirection * MathF.Min(8f, 12f * popup.TotalTime); // Adjust position to move both vertically and horizontally. var updatedPosition = position + new Vector2(horizontalOffset, -MathF.Min(8f, 12f * (popup.TotalTime * popup.TotalTime + popup.TotalTime))); + // Sunrise edit end var dimensions = handle.GetDimensions(font, popup.Text, scale); handle.DrawString(font, updatedPosition - dimensions / 2f, popup.Text, scale, color.WithAlpha(alpha)); From 360c5b74e58532fde78eb6c65e3dead9f24e8b09 Mon Sep 17 00:00:00 2001 From: drdth Date: Thu, 2 Jan 2025 08:01:05 +0300 Subject: [PATCH 09/14] add ui dropdown option --- .../Options/UI/Tabs/SunriseTab.xaml | 1 + .../Options/UI/Tabs/SunriseTab.xaml.cs | 11 ++++++ .../DamageOverlay/DamageOverlaySystem.cs | 8 ++++ .../DamageOverlay/DamageOverlayComponent.cs | 17 ++++----- .../DamageOverlay/DamageOverlaySystem.cs | 38 ++++++++++++++++++- .../DamageOverlay/DamageOverlayOptionEvent.cs | 11 ++++++ .../DamageOverlay/DamageOverlayPrototype.cs | 15 ++++++++ .../_Sunrise/SunriseCCVars/SunriseCCVars.cs | 3 ++ .../_sunrise/damage-overlay/presets.ftl | 6 +++ .../Entities/Structures/base_structure.yml | 1 + .../_Sunrise/DamageOverlay/presets.yml | 31 +++++++++++++++ 11 files changed, 131 insertions(+), 11 deletions(-) create mode 100644 Content.Shared/_Sunrise/DamageOverlay/DamageOverlayPrototype.cs create mode 100644 Resources/Locale/ru-RU/_strings/_sunrise/damage-overlay/presets.ftl create mode 100644 Resources/Prototypes/_Sunrise/DamageOverlay/presets.yml diff --git a/Content.Client/Options/UI/Tabs/SunriseTab.xaml b/Content.Client/Options/UI/Tabs/SunriseTab.xaml index d89bdaf4b2a..c2541cb318a 100644 --- a/Content.Client/Options/UI/Tabs/SunriseTab.xaml +++ b/Content.Client/Options/UI/Tabs/SunriseTab.xaml @@ -18,6 +18,7 @@ private bool IsDisabledByClient(ICommonSession session, DamageOverlayComponent component, DamageSpecifier damageDelta) { + if (_disabledSessions.Contains(session)) + return true; + if (_playerSettings.TryGetValue(session, out var playerPreset)) { if (damageDelta.DamageDict.Keys.Any(item => playerPreset.Types.Contains(item))) From d4de1debe390c34d37a3e3d3cd19f2b1d52214b2 Mon Sep 17 00:00:00 2001 From: drdth Date: Thu, 2 Jan 2025 08:46:30 +0300 Subject: [PATCH 12/14] 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 From 7ba8b26215382757cb8badc0c354725b3b248889 Mon Sep 17 00:00:00 2001 From: Vigers Ray Date: Sun, 5 Jan 2025 14:45:54 +0300 Subject: [PATCH 13/14] =?UTF-8?q?=D0=A7=D0=95=20=D0=91=D0=9B=D0=AF=D0=94?= =?UTF-8?q?=D0=AC=20=D0=A1=D0=9B=D0=9E=D0=96=D0=9D=D0=9E=20=D0=94=D0=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/Options/UI/Tabs/ExtraTab.xaml | 5 +- .../Options/UI/Tabs/ExtraTab.xaml.cs | 13 +--- .../DamageOverlay/DamageOverlaySystem.cs | 20 +++--- .../DamageOverlay/DamageOverlayComponent.cs | 9 --- .../DamageOverlay/DamageOverlaySystem.cs | 63 +++++++------------ .../DamageOverlay/DamageOverlayOptionEvent.cs | 20 ++---- .../DamageOverlay/DamageOverlayPrototype.cs | 18 ------ .../_Sunrise/SunriseCCVars/SunriseCCVars.cs | 19 ++++-- .../_sunrise/damage-overlay/presets.ftl | 6 -- .../_sunrise/escape-menu/ui/options-menu.ftl | 4 +- .../_Sunrise/DamageOverlay/presets.yml | 15 ----- 11 files changed, 59 insertions(+), 133 deletions(-) delete mode 100644 Content.Shared/_Sunrise/DamageOverlay/DamageOverlayPrototype.cs delete mode 100644 Resources/Locale/ru-RU/_strings/_sunrise/damage-overlay/presets.ftl delete mode 100644 Resources/Prototypes/_Sunrise/DamageOverlay/presets.yml diff --git a/Content.Client/Options/UI/Tabs/ExtraTab.xaml b/Content.Client/Options/UI/Tabs/ExtraTab.xaml index eab6293d02e..9bed634b1a1 100644 --- a/Content.Client/Options/UI/Tabs/ExtraTab.xaml +++ b/Content.Client/Options/UI/Tabs/ExtraTab.xaml @@ -17,8 +17,9 @@