From ca4e66529641ee6bb3db7d25e40a9e2bc35843da Mon Sep 17 00:00:00 2001 From: Galactic Chimp <63882831+GalacticChimp@users.noreply.github.com> Date: Sat, 12 Jun 2021 06:51:04 +0200 Subject: [PATCH] #3846 - fix for ControlMobVerb not working for ghosts (#4131) * #3846 - fix for ControlMobVerb not working for ghosts * #3846 - small improvents from CR * #3846 incorpated suggested changes * #3846 simplified visiting entity check in mind.cs --- Content.Server/Cloning/CloningSystem.cs | 2 +- Content.Server/Mind/Mind.cs | 12 ++++++++++-- Content.Server/Mind/Verbs/ControlMobVerb.cs | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Content.Server/Cloning/CloningSystem.cs b/Content.Server/Cloning/CloningSystem.cs index 5553eb4215..e04a7f877e 100644 --- a/Content.Server/Cloning/CloningSystem.cs +++ b/Content.Server/Cloning/CloningSystem.cs @@ -49,7 +49,7 @@ namespace Content.Server.Cloning mindComp.Mind != null) return; - mind.TransferTo(entity); + mind.TransferTo(entity, ghostCheckOverride: true); mind.UnVisit(); ClonesWaitingForMind.Remove(mind); } diff --git a/Content.Server/Mind/Mind.cs b/Content.Server/Mind/Mind.cs index 2e19f40d36..df137b387d 100644 --- a/Content.Server/Mind/Mind.cs +++ b/Content.Server/Mind/Mind.cs @@ -235,10 +235,13 @@ namespace Content.Server.Mind /// The entity to control. /// Can be null, in which case it will simply detach the mind from any entity. /// + /// + /// If true, skips ghost check for Visiting Entity + /// /// /// Thrown if is already owned by another mind. /// - public void TransferTo(IEntity? entity) + public void TransferTo(IEntity? entity, bool ghostCheckOverride = false) { MindComponent? component = null; var alreadyAttached = false; @@ -272,8 +275,13 @@ namespace Content.Server.Mind OwnedComponent = component; OwnedComponent?.InternalAssignMind(this); - if (VisitingEntity?.HasComponent() == false) + if (IsVisitingEntity + && (ghostCheckOverride // to force mind transfer, for example from ControlMobVerb + || !VisitingEntity!.TryGetComponent(out GhostComponent? ghostComponent) // visiting entity is not a Ghost + || !ghostComponent.CanReturnToBody)) // it is a ghost, but cannot return to body anyway, so it's okay + { VisitingEntity = null; + } // Player is CURRENTLY connected. if (Session != null && !alreadyAttached && VisitingEntity == null) diff --git a/Content.Server/Mind/Verbs/ControlMobVerb.cs b/Content.Server/Mind/Verbs/ControlMobVerb.cs index 89460fbbaf..2605064578 100644 --- a/Content.Server/Mind/Verbs/ControlMobVerb.cs +++ b/Content.Server/Mind/Verbs/ControlMobVerb.cs @@ -56,7 +56,7 @@ namespace Content.Server.Mind.Verbs var targetMind = target.GetComponent(); targetMind.Mind?.TransferTo(null); - userMind?.TransferTo(target); + userMind?.TransferTo(target, ghostCheckOverride: true); } } }