]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Zombies keep their anomalies on zombification (#33867)
authorPatrik Caes-Sayrs <heartofgoldfish@gmail.com>
Tue, 17 Dec 2024 11:56:47 +0000 (04:56 -0700)
committerGitHub <noreply@github.com>
Tue, 17 Dec 2024 11:56:47 +0000 (14:56 +0300)
* Zombies keep their anomalies on zombification

* Refactor anombies to isolate anomalies and zombies

InnerBodyAnomalies now send an event when the host dies.
Zombies cancels this event if the host is turning into a zombie.

* Anomazombies: deprecate CancellableEntityEventArgs

CancellableEntityEventArgs is deprecated. Use structs
with bool Cancelled instead.

Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs
Content.Server/Zombies/ZombieSystem.cs
Content.Shared/Anomaly/Components/InnerBodyAnomalyComponent.cs

index 38c4c51d8745f9e53bfbf735016962c4f27388d2..b75be376383fafc75d0bde4b5e3fcd2248b0cd6b 100644 (file)
@@ -186,6 +186,11 @@ public sealed class InnerBodyAnomalySystem : SharedInnerBodyAnomalySystem
         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
     }
 
index 371c6f1222aeaadbd4fe3d1d0bd16c2749fd2867..ec50e11a0caf9b43da18cb00447f2099d0fba752 100644 (file)
@@ -5,6 +5,7 @@ using Content.Server.Chat;
 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 @@ namespace Content.Server.Zombies
             SubscribeLocalEvent<ZombieComponent, GetCharactedDeadIcEvent>(OnGetCharacterDeadIC);
 
             SubscribeLocalEvent<PendingZombieComponent, MapInitEvent>(OnPendingMapInit);
+            SubscribeLocalEvent<PendingZombieComponent, BeforeRemoveAnomalyOnDeathEvent>(OnBeforeRemoveAnomalyOnDeath);
 
             SubscribeLocalEvent<IncurableZombieComponent, MapInitEvent>(OnPendingMapInit);
 
             SubscribeLocalEvent<ZombifyOnDeathComponent, MobStateChangedEvent>(OnDamageChanged);
+
+        }
+
+        private void OnBeforeRemoveAnomalyOnDeath(Entity<PendingZombieComponent> 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)
index e88cedb18ef2aa567ee10588120efb9b2cfb8d4f..a7e07ae2b504c78fa1a14440fd5556ae99deb55e 100644 (file)
@@ -70,3 +70,11 @@ public sealed partial class InnerBodyAnomalyComponent : Component
     [DataField]
     public string LayerMap = "inner_anomaly_layer";
 }
+
+/// <summary>
+/// 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.
+/// </summary>
+[ByRefEvent]
+public record struct BeforeRemoveAnomalyOnDeathEvent(bool Cancelled = false);