Files
OldThink/Content.Server/Administration/AGhost.cs

51 lines
1.7 KiB
C#
Raw Normal View History

using Content.Server.GameObjects.Components.Observer;
2020-04-05 02:29:04 +02:00
using Content.Server.Players;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
2018-09-20 18:19:04 +02:00
namespace Content.Server.Administration
{
public class AGhost : IClientCommand
{
public string Command => "aghost";
public string Description => "Makes you an admin ghost.";
public string Help => "aghost";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
{
if (player == null)
{
shell.SendText((IPlayerSession) null, "Nah");
return;
}
var mind = player.ContentData().Mind;
if (mind == null)
{
shell.SendText(player, "You can't ghost here!");
return;
}
2018-09-20 18:19:04 +02:00
if (mind.VisitingEntity != null && mind.VisitingEntity.Prototype.ID == "AdminObserver")
{
var visiting = mind.VisitingEntity;
mind.UnVisit();
visiting.Delete();
2018-09-20 18:19:04 +02:00
}
else
{
2020-04-05 02:29:04 +02:00
var canReturn = mind.CurrentEntity != null && !mind.CurrentEntity.HasComponent<GhostComponent>();
2018-09-20 18:19:04 +02:00
var entityManager = IoCManager.Resolve<IEntityManager>();
var ghost = entityManager.SpawnEntity("AdminObserver", player.AttachedEntity.Transform.MapPosition);
2020-04-05 02:29:04 +02:00
if(canReturn)
mind.Visit(ghost);
else
mind.TransferTo(ghost);
ghost.GetComponent<GhostComponent>().CanReturnToBody = canReturn;
2018-09-20 18:19:04 +02:00
}
}
}
}