Fix lingering ghost roles (and expand tests to catch it) (#38788)

* Improve and expand `TakeRoleAndReturn` to fail on bug #38292

* fix #38292 and expanded test cases

* use validated EntProtoIds for tests

remove unusued using declarations

* use const strings that match the TestPrototypes
This commit is contained in:
Quantum-cross
2025-07-09 07:07:41 -04:00
committed by GitHub
parent f29c35ff37
commit 989338cb08
2 changed files with 180 additions and 56 deletions

View File

@@ -510,6 +510,11 @@ public sealed class GhostRoleSystem : EntitySystem
DebugTools.AssertNotNull(player.ContentData());
// After taking a ghost role, the player cannot return to the original body, so wipe the player's current mind
// unless it is a visiting mind
if(_mindSystem.TryGetMind(player.UserId, out _, out var mind) && !mind.IsVisitingEntity)
_mindSystem.WipeMind(player);
var newMind = _mindSystem.CreateMind(player.UserId,
Comp<MetaDataComponent>(mob).EntityName);