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