diff --git a/Content.Server/Administration/Commands/AGhost.cs b/Content.Server/Administration/Commands/AGhost.cs index d541b1c884..6740eedfcc 100644 --- a/Content.Server/Administration/Commands/AGhost.cs +++ b/Content.Server/Administration/Commands/AGhost.cs @@ -3,6 +3,7 @@ using Content.Shared.Administration; using Content.Shared.Ghost; using Content.Shared.Mind; using Robust.Shared.Console; +using Robust.Shared.Map; namespace Content.Server.Administration.Commands { @@ -33,6 +34,10 @@ namespace Content.Server.Administration.Commands var metaDataSystem = _entities.System(); + EntityCoordinates? coordinates = null; + if (player.AttachedEntity != null) + coordinates = _entities.GetComponent(player.AttachedEntity.Value).Coordinates; + if (mind.VisitingEntity != default && _entities.TryGetComponent(mind.VisitingEntity, out var oldGhostComponent)) { mindSystem.UnVisit(mindId, mind); @@ -43,10 +48,10 @@ namespace Content.Server.Administration.Commands var canReturn = mind.CurrentEntity != null && !_entities.HasComponent(mind.CurrentEntity); - var coordinates = player.AttachedEntity != null + coordinates ??= player.AttachedEntity != null ? _entities.GetComponent(player.AttachedEntity.Value).Coordinates : EntitySystem.Get().GetObserverSpawnPoint(); - var ghost = _entities.SpawnEntity(GameTicker.AdminObserverPrototypeName, coordinates); + var ghost = _entities.SpawnEntity(GameTicker.AdminObserverPrototypeName, coordinates.Value); _entities.GetComponent(ghost).AttachToGridOrMap(); if (canReturn)