From 66ed63dd90e5a1aee2b9145ee7ce3cd72980e501 Mon Sep 17 00:00:00 2001 From: Tom Leys Date: Tue, 1 Aug 2023 10:46:06 +1200 Subject: [PATCH] Remember the first entity a Mind controls for the endround screen (#16950) --- Content.Server/GameTicking/GameTicker.RoundFlow.cs | 2 +- Content.Server/Mind/Mind.cs | 6 ++++++ Content.Server/Mind/MindSystem.cs | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index fff054bcd7..4883d8e3c0 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -343,7 +343,7 @@ namespace Content.Server.GameTicking PlayerOOCName = contentPlayerData?.Name ?? "(IMPOSSIBLE: REGISTERED MIND WITH NO OWNER)", // Character name takes precedence over current entity name PlayerICName = playerIcName, - PlayerEntityUid = mind.OwnedEntity, + PlayerEntityUid = mind.OriginalOwnedEntity, Role = antag ? mind.AllRoles.First(role => role.Antagonist).Name : mind.AllRoles.FirstOrDefault()?.Name ?? Loc.GetString("game-ticker-unknown-role"), diff --git a/Content.Server/Mind/Mind.cs b/Content.Server/Mind/Mind.cs index e219624ac7..844d1ee17c 100644 --- a/Content.Server/Mind/Mind.cs +++ b/Content.Server/Mind/Mind.cs @@ -48,6 +48,12 @@ namespace Content.Server.Mind [ViewVariables, Access(typeof(MindSystem))] public NetUserId? OriginalOwnerUserId { get; set; } + /// + /// Entity UID for the first entity that this mind controlled. Used for round end. + /// Might be relevant if the player has ghosted since. + /// + [ViewVariables] public EntityUid? OriginalOwnedEntity; + [ViewVariables] public bool IsVisitingEntity => VisitingEntity != null; diff --git a/Content.Server/Mind/MindSystem.cs b/Content.Server/Mind/MindSystem.cs index 2c04aa21f0..99ec003c9c 100644 --- a/Content.Server/Mind/MindSystem.cs +++ b/Content.Server/Mind/MindSystem.cs @@ -413,8 +413,10 @@ public sealed class MindSystem : EntitySystem InternalEjectMind(oldEntity.Value, oldComp); SetOwnedEntity(mind, entity, component); - if (mind.OwnedComponent != null) + if (mind.OwnedComponent != null){ InternalAssignMind(mind.OwnedEntity!.Value, mind, mind.OwnedComponent); + mind.OriginalOwnedEntity ??= mind.OwnedEntity; + } // Don't do the full deletion cleanup if we're transferring to our VisitingEntity if (alreadyAttached)