* #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
This commit is contained in:
@@ -49,7 +49,7 @@ namespace Content.Server.Cloning
|
|||||||
mindComp.Mind != null)
|
mindComp.Mind != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mind.TransferTo(entity);
|
mind.TransferTo(entity, ghostCheckOverride: true);
|
||||||
mind.UnVisit();
|
mind.UnVisit();
|
||||||
ClonesWaitingForMind.Remove(mind);
|
ClonesWaitingForMind.Remove(mind);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,10 +235,13 @@ namespace Content.Server.Mind
|
|||||||
/// The entity to control.
|
/// The entity to control.
|
||||||
/// Can be null, in which case it will simply detach the mind from any entity.
|
/// Can be null, in which case it will simply detach the mind from any entity.
|
||||||
/// </param>
|
/// </param>
|
||||||
|
/// <param name="ghostCheckOverride">
|
||||||
|
/// If true, skips ghost check for Visiting Entity
|
||||||
|
/// </param>
|
||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
/// Thrown if <paramref name="entity"/> is already owned by another mind.
|
/// Thrown if <paramref name="entity"/> is already owned by another mind.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public void TransferTo(IEntity? entity)
|
public void TransferTo(IEntity? entity, bool ghostCheckOverride = false)
|
||||||
{
|
{
|
||||||
MindComponent? component = null;
|
MindComponent? component = null;
|
||||||
var alreadyAttached = false;
|
var alreadyAttached = false;
|
||||||
@@ -272,8 +275,13 @@ namespace Content.Server.Mind
|
|||||||
OwnedComponent = component;
|
OwnedComponent = component;
|
||||||
OwnedComponent?.InternalAssignMind(this);
|
OwnedComponent?.InternalAssignMind(this);
|
||||||
|
|
||||||
if (VisitingEntity?.HasComponent<GhostComponent>() == 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;
|
VisitingEntity = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Player is CURRENTLY connected.
|
// Player is CURRENTLY connected.
|
||||||
if (Session != null && !alreadyAttached && VisitingEntity == null)
|
if (Session != null && !alreadyAttached && VisitingEntity == null)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace Content.Server.Mind.Verbs
|
|||||||
var targetMind = target.GetComponent<MindComponent>();
|
var targetMind = target.GetComponent<MindComponent>();
|
||||||
|
|
||||||
targetMind.Mind?.TransferTo(null);
|
targetMind.Mind?.TransferTo(null);
|
||||||
userMind?.TransferTo(target);
|
userMind?.TransferTo(target, ghostCheckOverride: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user