From 5ae1b06095f3695aaaa2e95f0c3b77dd4782feae Mon Sep 17 00:00:00 2001 From: Injazz <43905364+Injazz@users.noreply.github.com> Date: Thu, 25 Feb 2021 06:14:16 +0500 Subject: [PATCH] fixes ghost duplication on aghosting (#3235) Co-authored-by: Injazz --- .../Administration/Commands/AGhost.cs | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/Content.Server/Administration/Commands/AGhost.cs b/Content.Server/Administration/Commands/AGhost.cs index 9ec7adab07..4454f79872 100644 --- a/Content.Server/Administration/Commands/AGhost.cs +++ b/Content.Server/Administration/Commands/AGhost.cs @@ -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()) { - 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() + .SpawnEntity("AdminObserver", player.AttachedEntity?.Transform.Coordinates + ?? IoCManager.Resolve().GetObserverSpawnPoint()); + + if (canReturn) + { + ghost.Name = mind.CharacterName; + mind.Visit(ghost); } else { - var canReturn = mind.CurrentEntity != null; - var ghost = IoCManager.Resolve() - .SpawnEntity("AdminObserver", player.AttachedEntity?.Transform.Coordinates - ?? IoCManager.Resolve().GetObserverSpawnPoint()); - - if (canReturn) - { - ghost.Name = mind.CharacterName; - mind.Visit(ghost); - } - else - { - ghost.Name = player.Name; - mind.TransferTo(ghost); - } - - ghost.GetComponent().CanReturnToBody = canReturn; + ghost.Name = player.Name; + mind.TransferTo(ghost); } + + ghost.GetComponent().CanReturnToBody = canReturn; } } }