From 81607d03275c8b5b3b135d1f824709bcd72a8f90 Mon Sep 17 00:00:00 2001
From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Date: Sat, 1 Jan 2022 08:48:45 -0800
Subject: [PATCH] Reregister ghost role when player ghosts while alive (#5956)
* Reregister ghost role when player ghosts while alive
* Add ReregisterOnGhost property
---
.../Ghost/Roles/Components/GhostRoleComponent.cs | 9 ++++++++-
Content.Server/Ghost/Roles/GhostRoleSystem.cs | 10 ++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs
index 0701fcc1a3..0cb4a2fafe 100644
--- a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs
+++ b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs
@@ -56,11 +56,18 @@ namespace Content.Server.Ghost.Roles.Components
}
[ViewVariables(VVAccess.ReadOnly)]
- public bool Taken { get; protected set; }
+ public bool Taken { get; set; }
[ViewVariables]
public uint Identifier { get; set; }
+ ///
+ /// Reregisters the ghost role when the current player ghosts.
+ ///
+ [ViewVariables(VVAccess.ReadWrite)]
+ [DataField("reregister")]
+ public bool ReregisterOnGhost { get; set; } = true;
+
protected override void Initialize()
{
base.Initialize();
diff --git a/Content.Server/Ghost/Roles/GhostRoleSystem.cs b/Content.Server/Ghost/Roles/GhostRoleSystem.cs
index 5619a23fbf..879ab1cbe5 100644
--- a/Content.Server/Ghost/Roles/GhostRoleSystem.cs
+++ b/Content.Server/Ghost/Roles/GhostRoleSystem.cs
@@ -4,6 +4,7 @@ using Content.Server.EUI;
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.Players;
using Content.Shared.Administration;
using Content.Shared.GameTicking;
@@ -42,6 +43,7 @@ namespace Content.Server.Ghost.Roles
SubscribeLocalEvent(Reset);
SubscribeLocalEvent(OnPlayerAttached);
+ SubscribeLocalEvent(OnMindRemoved);
_playerManager.PlayerStatusChanged += PlayerStatusChanged;
}
@@ -200,6 +202,14 @@ namespace Content.Server.Ghost.Roles
CloseEui(message.Player);
}
+ private void OnMindRemoved(EntityUid uid, GhostRoleComponent component, MindRemovedMessage args)
+ {
+ if (!component.ReregisterOnGhost)
+ return;
+ component.Taken = false;
+ RegisterGhostRole(component);
+ }
+
public void Reset(RoundRestartCleanupEvent ev)
{
foreach (var session in _openUis.Keys)