2020-08-13 14:40:27 +02:00
|
|
|
|
using Content.Server.GameObjects.Components.Observer;
|
2020-04-05 02:29:04 +02:00
|
|
|
|
using Content.Server.Players;
|
2019-04-15 21:11:38 -06:00
|
|
|
|
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;
|
2020-08-25 05:37:54 -06:00
|
|
|
|
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();
|
2020-04-17 19:23:06 +02:00
|
|
|
|
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>();
|
2020-07-30 11:28:08 -07:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|