From 1e061094cace361adbc8fb571a2e1f9c419d8f8e Mon Sep 17 00:00:00 2001 From: 20kdc Date: Tue, 23 Nov 2021 00:34:56 +0000 Subject: [PATCH] Direct pressure and asphyxiation damage do not interrupt DoAfters anymore (#5459) --- .../Atmos/EntitySystems/BarotraumaSystem.cs | 4 ++-- .../Body/Components/RespiratorComponent.cs | 2 +- Content.Server/DoAfter/DoAfterSystem.cs | 2 +- .../Damage/Systems/DamageableSystem.cs | 18 +++++++++++++----- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs b/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs index 897164d732..7dd99dd3c0 100644 --- a/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs +++ b/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs @@ -103,7 +103,7 @@ namespace Content.Server.Atmos.EntitySystems goto default; // Deal damage and ignore resistances. Resistance to pressure damage should be done via pressure protection gear. - _damageableSystem.TryChangeDamage(uid, barotrauma.Damage * Atmospherics.LowPressureDamage, true); + _damageableSystem.TryChangeDamage(uid, barotrauma.Damage * Atmospherics.LowPressureDamage, true, false); if (status == null) break; @@ -126,7 +126,7 @@ namespace Content.Server.Atmos.EntitySystems var damageScale = MathF.Min((pressure / Atmospherics.HazardHighPressure) * Atmospherics.PressureDamageCoefficient, Atmospherics.MaxHighPressureDamage); // Deal damage and ignore resistances. Resistance to pressure damage should be done via pressure protection gear. - _damageableSystem.TryChangeDamage(uid, barotrauma.Damage * damageScale, true); + _damageableSystem.TryChangeDamage(uid, barotrauma.Damage * damageScale, true, false); if (status == null) break; diff --git a/Content.Server/Body/Components/RespiratorComponent.cs b/Content.Server/Body/Components/RespiratorComponent.cs index 0c809b9560..00bf65fe84 100644 --- a/Content.Server/Body/Components/RespiratorComponent.cs +++ b/Content.Server/Body/Components/RespiratorComponent.cs @@ -320,7 +320,7 @@ namespace Content.Server.Body.Components alertsComponent.ShowAlert(AlertType.LowOxygen); } - EntitySystem.Get().TryChangeDamage(Owner.Uid, Damage, true); + EntitySystem.Get().TryChangeDamage(Owner.Uid, Damage, true, false); } private void StopSuffocation() diff --git a/Content.Server/DoAfter/DoAfterSystem.cs b/Content.Server/DoAfter/DoAfterSystem.cs index 2ba7b65187..e64afc9456 100644 --- a/Content.Server/DoAfter/DoAfterSystem.cs +++ b/Content.Server/DoAfter/DoAfterSystem.cs @@ -23,7 +23,7 @@ namespace Content.Server.DoAfter public void HandleDamage(EntityUid _, DoAfterComponent component, DamageChangedEvent args) { - if (component.DoAfters.Count == 0 || !args.DamageIncreased) + if (component.DoAfters.Count == 0 || !args.InterruptsDoAfters) { return; } diff --git a/Content.Shared/Damage/Systems/DamageableSystem.cs b/Content.Shared/Damage/Systems/DamageableSystem.cs index 769ae165f1..ab29607352 100644 --- a/Content.Shared/Damage/Systems/DamageableSystem.cs +++ b/Content.Shared/Damage/Systems/DamageableSystem.cs @@ -113,7 +113,7 @@ namespace Content.Shared.Damage /// This updates cached damage information, flags the component as dirty, and raises a damage changed event. /// The damage changed event is used by other systems, such as damage thresholds. /// - public void DamageChanged(DamageableComponent component, DamageSpecifier? damageDelta = null) + public void DamageChanged(DamageableComponent component, DamageSpecifier? damageDelta = null, bool interruptsDoAfters = true) { component.DamagePerGroup = component.Damage.GetDamagePerGroup(); SetTotalDamage(component, component.Damage.Total); @@ -121,7 +121,7 @@ namespace Content.Shared.Damage if (EntityManager.TryGetComponent(component.OwnerUid, out var appearance) && damageDelta != null) appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, damageDelta.GetDamagePerGroup().Keys.ToList()); - RaiseLocalEvent(component.OwnerUid, new DamageChangedEvent(component, damageDelta), false); + RaiseLocalEvent(component.OwnerUid, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false); } /// @@ -136,7 +136,7 @@ namespace Content.Shared.Damage /// Returns a with information about the actual damage changes. This will be /// null if the user had no applicable components that can take damage. /// - public DamageSpecifier? TryChangeDamage(EntityUid uid, DamageSpecifier damage, bool ignoreResistances = false) + public DamageSpecifier? TryChangeDamage(EntityUid uid, DamageSpecifier damage, bool ignoreResistances = false, bool interruptsDoAfters = true) { if (!EntityManager.TryGetComponent(uid, out var damageable)) { @@ -185,7 +185,7 @@ namespace Content.Shared.Damage if (!delta.Empty) { - DamageChanged(damageable, delta); + DamageChanged(damageable, delta, interruptsDoAfters); } return delta; @@ -282,7 +282,14 @@ namespace Content.Shared.Damage /// public readonly bool DamageIncreased = false; - public DamageChangedEvent(DamageableComponent damageable, DamageSpecifier? damageDelta) + /// + /// Does this event interrupt DoAfters? + /// Note: As provided in the constructor, this *does not* account for DamageIncreased. + /// As written into the event, this *does* account for DamageIncreased. + /// + public readonly bool InterruptsDoAfters = false; + + public DamageChangedEvent(DamageableComponent damageable, DamageSpecifier? damageDelta, bool interruptsDoAfters) { Damageable = damageable; DamageDelta = damageDelta; @@ -298,6 +305,7 @@ namespace Content.Shared.Damage break; } } + InterruptsDoAfters = interruptsDoAfters && DamageIncreased; } } }