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.Server.Players;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Server.Interfaces.Console;
|
using Robust.Server.Interfaces.Console;
|
||||||
@@ -23,14 +25,15 @@ namespace Content.Server.Administration.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mind = player.ContentData().Mind;
|
var mind = player.ContentData()?.Mind;
|
||||||
|
|
||||||
if (mind == null)
|
if (mind == null)
|
||||||
{
|
{
|
||||||
shell.SendText(player, "You can't ghost here!");
|
shell.SendText(player, "You can't ghost here!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mind.VisitingEntity != null && mind.VisitingEntity.Prototype.ID == "AdminObserver")
|
if (mind.VisitingEntity != null && mind.VisitingEntity.Prototype?.ID == "AdminObserver")
|
||||||
{
|
{
|
||||||
var visiting = mind.VisitingEntity;
|
var visiting = mind.VisitingEntity;
|
||||||
mind.UnVisit();
|
mind.UnVisit();
|
||||||
@@ -38,13 +41,22 @@ namespace Content.Server.Administration.Commands
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var canReturn = mind.CurrentEntity != null && !mind.CurrentEntity.HasComponent<GhostComponent>();
|
var canReturn = mind.CurrentEntity != null;
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var ghost = IoCManager.Resolve<IEntityManager>()
|
||||||
var ghost = entityManager.SpawnEntity("AdminObserver", player.AttachedEntity.Transform.MapPosition);
|
.SpawnEntity("AdminObserver", player.AttachedEntity?.Transform.Coordinates
|
||||||
if(canReturn)
|
?? IoCManager.Resolve<IGameTicker>().GetObserverSpawnPoint());
|
||||||
|
|
||||||
|
if (canReturn)
|
||||||
|
{
|
||||||
|
ghost.Name = mind.CharacterName;
|
||||||
mind.Visit(ghost);
|
mind.Visit(ghost);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
ghost.Name = player.Name;
|
||||||
mind.TransferTo(ghost);
|
mind.TransferTo(ghost);
|
||||||
|
}
|
||||||
|
|
||||||
ghost.GetComponent<GhostComponent>().CanReturnToBody = canReturn;
|
ghost.GetComponent<GhostComponent>().CanReturnToBody = canReturn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user