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();