2024-05-12 16:35:30 +02:00
|
|
|
using Content.Server.Popups;
|
2021-12-13 16:45:49 +11:00
|
|
|
using Content.Shared.Administration;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-03-03 20:37:26 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Ghost
|
2020-03-03 20:37:26 +01:00
|
|
|
{
|
2020-10-30 16:06:48 +01:00
|
|
|
[AnyCommand]
|
2024-07-03 02:01:17 +02:00
|
|
|
public sealed class GhostCommand : IConsoleCommand
|
2020-03-03 20:37:26 +01:00
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
[Dependency] private readonly IEntityManager _entities = default!;
|
|
|
|
|
|
2020-03-03 20:37:26 +01:00
|
|
|
public string Command => "ghost";
|
2024-05-12 16:35:30 +02:00
|
|
|
public string Description => Loc.GetString("ghost-command-description");
|
|
|
|
|
public string Help => Loc.GetString("ghost-command-help-text");
|
2020-03-03 20:37:26 +01:00
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-03-03 20:37:26 +01:00
|
|
|
{
|
2023-10-28 09:59:53 +11:00
|
|
|
var player = shell.Player;
|
2020-03-03 20:37:26 +01:00
|
|
|
if (player == null)
|
|
|
|
|
{
|
2024-05-12 16:35:30 +02:00
|
|
|
shell.WriteLine(Loc.GetString("ghost-command-no-session"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (player.AttachedEntity is { Valid: true } frozen &&
|
|
|
|
|
_entities.HasComponent<AdminFrozenComponent>(frozen))
|
|
|
|
|
{
|
|
|
|
|
var deniedMessage = Loc.GetString("ghost-command-denied");
|
|
|
|
|
shell.WriteLine(deniedMessage);
|
|
|
|
|
_entities.System<PopupSystem>()
|
|
|
|
|
.PopupEntity(deniedMessage, frozen, frozen);
|
2020-03-03 20:37:26 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-30 21:46:11 -07:00
|
|
|
var minds = _entities.System<SharedMindSystem>();
|
2023-08-28 16:53:24 -07:00
|
|
|
if (!minds.TryGetMind(player, out var mindId, out var mind))
|
2020-08-25 05:37:54 -06:00
|
|
|
{
|
2023-10-07 12:00:48 +11:00
|
|
|
mindId = minds.CreateMind(player.UserId);
|
|
|
|
|
mind = _entities.GetComponent<MindComponent>(mindId);
|
2020-03-03 20:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
2024-08-26 15:15:33 +03:00
|
|
|
if (!_entities.System<GhostSystem>().OnGhostAttempt(mindId, true, true, mind))
|
2020-08-14 08:13:32 -05:00
|
|
|
{
|
2024-05-12 16:35:30 +02:00
|
|
|
shell.WriteLine(Loc.GetString("ghost-command-denied"));
|
2020-08-14 08:13:32 -05:00
|
|
|
}
|
2020-03-03 20:37:26 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|