diff --git a/Content.Shared/Mobs/Systems/MobThresholdSystem.cs b/Content.Shared/Mobs/Systems/MobThresholdSystem.cs index f34240d8fe..59d9fb4c23 100644 --- a/Content.Shared/Mobs/Systems/MobThresholdSystem.cs +++ b/Content.Shared/Mobs/Systems/MobThresholdSystem.cs @@ -22,6 +22,7 @@ public sealed class MobThresholdSystem : EntitySystem SubscribeLocalEvent(MobThresholdStartup); SubscribeLocalEvent(OnDamaged); SubscribeLocalEvent(OnUpdateMobState); + SubscribeLocalEvent(OnThresholdsMobState); } private void OnGetState(EntityUid uid, MobThresholdsComponent component, ref ComponentGetState args) @@ -424,9 +425,7 @@ public sealed class MobThresholdSystem : EntitySystem if (!TryComp(target, out var mobState) || !TryComp(target, out var damageable)) return; CheckThresholds(target, mobState, thresholds, damageable); - var ev = new MobThresholdChecked(target, mobState, thresholds, damageable); - RaiseLocalEvent(target, ref ev, true); - UpdateAlerts(target, mobState.CurrentState, thresholds, damageable); + UpdateAllEffects((target, thresholds, mobState, damageable), mobState.CurrentState); } private void MobThresholdShutdown(EntityUid target, MobThresholdsComponent component, ComponentShutdown args) @@ -447,6 +446,23 @@ public sealed class MobThresholdSystem : EntitySystem } } + private void UpdateAllEffects(Entity ent, MobState currentState) + { + var (_, thresholds, mobState, damageable) = ent; + if (Resolve(ent, ref thresholds, ref mobState, ref damageable)) + { + var ev = new MobThresholdChecked(ent, mobState, thresholds, damageable); + RaiseLocalEvent(ent, ref ev, true); + } + + UpdateAlerts(ent, currentState, thresholds, damageable); + } + + private void OnThresholdsMobState(Entity ent, ref MobStateChangedEvent args) + { + UpdateAllEffects((ent, ent, null, null), args.NewMobState); + } + #endregion }