fixes ghost duplication on aghosting (#3235)

Co-authored-by: Injazz <injazza@gmail.com>
This commit is contained in:
Injazz
2021-02-25 06:14:16 +05:00
committed by GitHub
parent 94bdf01ab7
commit 5ae1b06095

View File

@@ -33,32 +33,29 @@ namespace Content.Server.Administration.Commands
return;
}
if (mind.VisitingEntity != null && mind.VisitingEntity.Prototype?.ID == "AdminObserver")
if (mind.VisitingEntity != null && mind.VisitingEntity.HasComponent<GhostComponent>())
{
var visiting = mind.VisitingEntity;
mind.UnVisit();
visiting.Delete();
shell.WriteLine("Aren't you a ghost already?");
return;
}
var canReturn = mind.CurrentEntity != null;
var ghost = IoCManager.Resolve<IEntityManager>()
.SpawnEntity("AdminObserver", player.AttachedEntity?.Transform.Coordinates
?? IoCManager.Resolve<IGameTicker>().GetObserverSpawnPoint());
if (canReturn)
{
ghost.Name = mind.CharacterName;
mind.Visit(ghost);
}
else
{
var canReturn = mind.CurrentEntity != null;
var ghost = IoCManager.Resolve<IEntityManager>()
.SpawnEntity("AdminObserver", player.AttachedEntity?.Transform.Coordinates
?? IoCManager.Resolve<IGameTicker>().GetObserverSpawnPoint());
if (canReturn)
{
ghost.Name = mind.CharacterName;
mind.Visit(ghost);
}
else
{
ghost.Name = player.Name;
mind.TransferTo(ghost);
}
ghost.GetComponent<GhostComponent>().CanReturnToBody = canReturn;
ghost.Name = player.Name;
mind.TransferTo(ghost);
}
ghost.GetComponent<GhostComponent>().CanReturnToBody = canReturn;
}
}
}