ECS MindComponent (#5917)

This commit is contained in:
Vera Aguilera Puerto
2022-01-04 13:37:50 +01:00
committed by GitHub
parent b0ee574c70
commit 675a29ed33
4 changed files with 157 additions and 118 deletions

View File

@@ -291,15 +291,19 @@ namespace Content.Server.Mind
}
}
OwnedComponent?.InternalEjectMind();
var mindSystem = EntitySystem.Get<MindSystem>();
if(OwnedComponent != null)
mindSystem.InternalEjectMind(OwnedComponent.Owner, OwnedComponent);
OwnedComponent = component;
OwnedComponent?.InternalAssignMind(this);
if(OwnedComponent != null)
mindSystem.InternalAssignMind(OwnedComponent.Owner, this, OwnedComponent);
if (VisitingEntity != null
&& (ghostCheckOverride // to force mind transfer, for example from ControlMobVerb
|| !entMan.TryGetComponent(VisitingEntity!, 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
|| !entMan.TryGetComponent(VisitingEntity!, 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 = default;
}