From cf2e80e2d5efa984a6a58e07c233c6ab34c9d91e Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Sat, 5 Aug 2023 20:13:27 +0300 Subject: [PATCH] Fix aghost (#272) --- Content.Server/Administration/Commands/AGhost.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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)