Handle MindComponent deletion:

You now get turned into a ghost if it happens, or return to body gets disabled if you were already ghosted.
This commit is contained in:
Pieter-Jan Briers
2020-04-18 00:39:22 +02:00
parent 4125c36e8d
commit ce2d6175d2

View File

@@ -1,4 +1,5 @@
using Content.Server.Mobs;
using Content.Server.GameObjects.Components.Observer;
using Content.Server.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.ViewVariables;
@@ -46,13 +47,31 @@ namespace Content.Server.GameObjects.Components.Mobs
Mind = value;
}
public override void OnRemove()
protected override void Shutdown()
{
base.OnRemove();
base.Shutdown();
if (HasMind)
{
Mind.TransferTo(null);
var visiting = Mind.VisitingEntity;
if (visiting != null)
{
if (visiting.TryGetComponent(out GhostComponent ghost))
{
ghost.CanReturnToBody = false;
}
Mind.TransferTo(visiting);
}
else
{
var ghost = Owner.EntityManager.SpawnEntity("MobObserver", Owner.Transform.GridPosition);
ghost.Name = Mind.CharacterName;
var ghostComponent = ghost.GetComponent<GhostComponent>();
ghostComponent.CanReturnToBody = false;
Mind.TransferTo(ghost);
}
}
}
}