2021-01-02 22:11:39 +01:00
|
|
|
|
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;
|
2020-10-30 16:06:48 +01:00
|
|
|
|
using Content.Shared.Administration;
|
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
|
|
|
|
|
2020-10-30 16:06:48 +01:00
|
|
|
|
namespace Content.Server.Administration.Commands
|
2018-09-20 18:19:04 +02:00
|
|
|
|
{
|
2020-10-30 16:06:48 +01: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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-01-02 22:11:39 +01:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-01-02 22:11:39 +01:00
|
|
|
|
if (mind.VisitingEntity != null && mind.VisitingEntity.Prototype?.ID == "AdminObserver")
|
2018-09-20 18:19:04 +02:00
|
|
|
|
{
|
|
|
|
|
|
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
|
|
|
|
|
|
{
|
2021-01-02 22:11:39 +01:00
|
|
|
|
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);
|
2021-01-02 22:11:39 +01:00
|
|
|
|
}
|
2020-04-05 02:29:04 +02:00
|
|
|
|
else
|
2021-01-02 22:11:39 +01:00
|
|
|
|
{
|
|
|
|
|
|
ghost.Name = player.Name;
|
2020-04-05 02:29:04 +02:00
|
|
|
|
mind.TransferTo(ghost);
|
2021-01-02 22:11:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-05 02:29:04 +02:00
|
|
|
|
ghost.GetComponent<GhostComponent>().CanReturnToBody = canReturn;
|
2018-09-20 18:19:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|