Files
crystall-punk-14/Content.Server/Ghost/GhostCommand.cs

50 lines
1.7 KiB
C#
Raw Permalink Normal View History

using Content.Server.Popups;
using Content.Shared.Administration;
using Content.Shared.Mind;
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
{
[AnyCommand]
2024-07-03 02:01:17 +02:00
public sealed class GhostCommand : IConsoleCommand
2020-03-03 20:37:26 +01:00
{
[Dependency] private readonly IEntityManager _entities = default!;
2020-03-03 20:37:26 +01:00
public string Command => "ghost";
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
public void Execute(IConsoleShell shell, string argStr, string[] args)
2020-03-03 20:37:26 +01:00
{
var player = shell.Player;
2020-03-03 20:37:26 +01:00
if (player == null)
{
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;
}
var minds = _entities.System<SharedMindSystem>();
if (!minds.TryGetMind(player, out var mindId, out var mind))
{
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
}
if (!_entities.System<GhostSystem>().OnGhostAttempt(mindId, true, true, mind))
{
shell.WriteLine(Loc.GetString("ghost-command-denied"));
}
2020-03-03 20:37:26 +01:00
}
}
}