Fixes aghost spam creating many admin ghosts.
- Also gives aghosts their character/player name
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Content.Server.GameObjects.Components.Observer;
|
||||
using Content.Server.Commands.Observer;
|
||||
using Content.Server.GameObjects.Components.Observer;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
@@ -23,14 +25,15 @@ namespace Content.Server.Administration.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var mind = player.ContentData().Mind;
|
||||
var mind = player.ContentData()?.Mind;
|
||||
|
||||
if (mind == null)
|
||||
{
|
||||
shell.SendText(player, "You can't ghost here!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mind.VisitingEntity != null && mind.VisitingEntity.Prototype.ID == "AdminObserver")
|
||||
if (mind.VisitingEntity != null && mind.VisitingEntity.Prototype?.ID == "AdminObserver")
|
||||
{
|
||||
var visiting = mind.VisitingEntity;
|
||||
mind.UnVisit();
|
||||
@@ -38,13 +41,22 @@ namespace Content.Server.Administration.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
var canReturn = mind.CurrentEntity != null && !mind.CurrentEntity.HasComponent<GhostComponent>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var ghost = entityManager.SpawnEntity("AdminObserver", player.AttachedEntity.Transform.MapPosition);
|
||||
if(canReturn)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user