Files
tbd-station-14/Content.Server/Ghost/GhostCommand.cs
Winkarst 2d85b4e7e9 Move OnGhostAttempt to GhostSystem (#31445)
* Move OnGhostAttempt to GhostSystem

* Remove unused dependencies and sort them
2024-08-26 14:15:33 +02:00

50 lines
1.7 KiB
C#

using Content.Server.Popups;
using Content.Shared.Administration;
using Content.Shared.Mind;
using Robust.Shared.Console;
namespace Content.Server.Ghost
{
[AnyCommand]
public sealed class GhostCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
public string Command => "ghost";
public string Description => Loc.GetString("ghost-command-description");
public string Help => Loc.GetString("ghost-command-help-text");
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player;
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);
return;
}
var minds = _entities.System<SharedMindSystem>();
if (!minds.TryGetMind(player, out var mindId, out var mind))
{
mindId = minds.CreateMind(player.UserId);
mind = _entities.GetComponent<MindComponent>(mindId);
}
if (!_entities.System<GhostSystem>().OnGhostAttempt(mindId, true, true, mind))
{
shell.WriteLine(Loc.GetString("ghost-command-denied"));
}
}
}
}