From cd865b9aaace01a70e747820961f5a2f823bf672 Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Sat, 1 Jan 2022 22:00:21 -0800 Subject: [PATCH] Remove crit and dead mobs from GhostRole list (#5992) --- Content.Server/Ghost/Roles/GhostRoleSystem.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Content.Server/Ghost/Roles/GhostRoleSystem.cs b/Content.Server/Ghost/Roles/GhostRoleSystem.cs index 879ab1cbe5..e82402345a 100644 --- a/Content.Server/Ghost/Roles/GhostRoleSystem.cs +++ b/Content.Server/Ghost/Roles/GhostRoleSystem.cs @@ -5,11 +5,13 @@ using Content.Server.Ghost.Components; using Content.Server.Ghost.Roles.Components; using Content.Server.Ghost.Roles.UI; using Content.Server.Mind.Components; +using Content.Server.MobState.States; using Content.Server.Players; using Content.Shared.Administration; using Content.Shared.GameTicking; using Content.Shared.Ghost; using Content.Shared.Ghost.Roles; +using Content.Shared.MobState; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Server.Player; @@ -43,11 +45,29 @@ namespace Content.Server.Ghost.Roles SubscribeLocalEvent(Reset); SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnMindRemoved); + SubscribeLocalEvent(OnMindRemoved); + SubscribeLocalEvent(OnMobStateChanged); _playerManager.PlayerStatusChanged += PlayerStatusChanged; } + private void OnMobStateChanged(EntityUid uid, GhostRoleComponent component, MobStateChangedEvent args) + { + switch (args.CurrentMobState) + { + case NormalMobState: + { + if (!component.Taken) + RegisterGhostRole(component); + break; + } + case CriticalMobState: + case DeadMobState: + UnregisterGhostRole(component); + break; + } + } + public override void Shutdown() { base.Shutdown();