Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zombies keep their anomalies on zombification #33867

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ private void OnMobStateChanged(Entity<InnerBodyAnomalyComponent> 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
}

Expand Down
10 changes: 10 additions & 0 deletions Content.Server/Zombies/ZombieSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,10 +65,19 @@ public override void Initialize()
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Loading