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

65 lines
2.1 KiB
C#
Raw Normal View History

using Content.Server.Commands.Observer;
using Content.Server.GameObjects.Components.Observer;
using Content.Server.Interfaces.GameTicking;
2020-04-05 02:29:04 +02:00
using Content.Server.Players;
using Content.Shared.Administration;
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.Commands
2018-09-20 18:19:04 +02:00
{
[AdminCommand(AdminFlags.Admin)]
2018-09-20 18:19:04 +02:00
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;
}
if (mind.VisitingEntity != null && mind.VisitingEntity.Prototype?.ID == "AdminObserver")
2018-09-20 18:19:04 +02:00
{
var visiting = mind.VisitingEntity;
mind.UnVisit();
visiting.Delete();
2018-09-20 18:19:04 +02:00
}
else
{
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;
2020-04-05 02:29:04 +02:00
mind.Visit(ghost);
}
2020-04-05 02:29:04 +02:00
else
{
ghost.Name = player.Name;
2020-04-05 02:29:04 +02:00
mind.TransferTo(ghost);
}
2020-04-05 02:29:04 +02:00
ghost.GetComponent<GhostComponent>().CanReturnToBody = canReturn;
2018-09-20 18:19:04 +02:00
}
}
}
}