diff --git a/Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs b/Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs index 38c4c51d8745f9..b75be376383faf 100644 --- a/Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs +++ b/Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs @@ -186,6 +186,11 @@ private void OnMobStateChanged(Entity ent, ref MobSta if (args.NewMobState != MobState.Dead) return; + var ev = new BeforeRemoveAnomalyOnDeathEvent(); + RaiseLocalEvent(args.Target, ref ev); + if (ev.Cancelled) + return; + _anomaly.ChangeAnomalyHealth(ent, -2); //Shutdown it } diff --git a/Content.Server/Zombies/ZombieSystem.cs b/Content.Server/Zombies/ZombieSystem.cs index 371c6f1222aeaa..ec50e11a0caf9b 100644 --- a/Content.Server/Zombies/ZombieSystem.cs +++ b/Content.Server/Zombies/ZombieSystem.cs @@ -5,6 +5,7 @@ using Content.Server.Chat.Systems; using Content.Server.Emoting.Systems; using Content.Server.Speech.EntitySystems; +using Content.Shared.Anomaly.Components; using Content.Shared.Bed.Sleep; using Content.Shared.Cloning; using Content.Shared.Damage; @@ -64,10 +65,19 @@ public override void Initialize() SubscribeLocalEvent(OnGetCharacterDeadIC); SubscribeLocalEvent(OnPendingMapInit); + SubscribeLocalEvent(OnBeforeRemoveAnomalyOnDeath); SubscribeLocalEvent(OnPendingMapInit); SubscribeLocalEvent(OnDamageChanged); + + } + + private void OnBeforeRemoveAnomalyOnDeath(Entity ent, ref BeforeRemoveAnomalyOnDeathEvent args) + { + // Pending zombies (e.g. infected non-zombies) do not remove their hosted anomaly on death. + // Current zombies DO remove the anomaly on death. + args.Cancelled = true; } private void OnPendingMapInit(EntityUid uid, IncurableZombieComponent component, MapInitEvent args) diff --git a/Content.Shared/Anomaly/Components/InnerBodyAnomalyComponent.cs b/Content.Shared/Anomaly/Components/InnerBodyAnomalyComponent.cs index e88cedb18ef2aa..a7e07ae2b504c7 100644 --- a/Content.Shared/Anomaly/Components/InnerBodyAnomalyComponent.cs +++ b/Content.Shared/Anomaly/Components/InnerBodyAnomalyComponent.cs @@ -70,3 +70,11 @@ public sealed partial class InnerBodyAnomalyComponent : Component [DataField] public string LayerMap = "inner_anomaly_layer"; } + +/// +/// Event broadcast when an anomaly is being removed because the host is dying. +/// Raised directed at the host entity with the anomaly. +/// Cancel this if you want to prevent the host from losing their anomaly on death. +/// +[ByRefEvent] +public record struct BeforeRemoveAnomalyOnDeathEvent(bool Cancelled = false);