2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.GameTicking;
|
2024-05-12 16:35:30 +02:00
|
|
|
using Content.Server.Popups;
|
2021-12-13 16:45:49 +11:00
|
|
|
using Content.Shared.Administration;
|
2024-08-10 20:05:54 -07:00
|
|
|
using Content.Shared.Chat;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Shared.Enums;
|
2019-04-13 09:45:09 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Chat.Commands
|
2019-04-13 09:45:09 +02:00
|
|
|
{
|
2020-10-30 16:06:48 +01:00
|
|
|
[AnyCommand]
|
2022-02-16 00:23:23 -07:00
|
|
|
internal sealed class SuicideCommand : IConsoleCommand
|
2020-05-27 20:05:12 -03:00
|
|
|
{
|
2024-05-12 17:34:52 -07:00
|
|
|
[Dependency] private readonly IEntityManager _e = default!;
|
|
|
|
|
|
2020-05-27 20:05:12 -03:00
|
|
|
public string Command => "suicide";
|
|
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
public string Description => Loc.GetString("suicide-command-description");
|
2020-05-27 20:05:12 -03:00
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
public string Help => Loc.GetString("suicide-command-help-text");
|
2020-05-27 20:05:12 -03:00
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-05-27 20:05:12 -03:00
|
|
|
{
|
2023-10-28 09:59:53 +11:00
|
|
|
if (shell.Player is not { } player)
|
2022-05-12 16:09:15 -07:00
|
|
|
{
|
2024-08-11 09:46:57 +00:00
|
|
|
shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server"));
|
2022-05-12 16:09:15 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (player.Status != SessionStatus.InGame || player.AttachedEntity == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2024-05-12 17:34:52 -07:00
|
|
|
var minds = _e.System<SharedMindSystem>();
|
|
|
|
|
|
2022-05-12 16:09:15 -07:00
|
|
|
// This check also proves mind not-null for at the end when the mob is ghosted.
|
2024-08-10 20:05:54 -07:00
|
|
|
if (!minds.TryGetMind(player, out var mindId, out var mindComp) ||
|
|
|
|
|
mindComp.OwnedEntity is not { Valid: true } victim)
|
2022-05-12 16:09:15 -07:00
|
|
|
{
|
2024-05-12 16:35:30 +02:00
|
|
|
shell.WriteLine(Loc.GetString("suicide-command-no-mind"));
|
2022-05-12 16:09:15 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2023-08-28 16:53:24 -07:00
|
|
|
|
2024-05-12 17:34:52 -07:00
|
|
|
var suicideSystem = _e.System<SuicideSystem>();
|
|
|
|
|
|
|
|
|
|
if (_e.HasComponent<AdminFrozenComponent>(victim))
|
2024-05-12 16:35:30 +02:00
|
|
|
{
|
|
|
|
|
var deniedMessage = Loc.GetString("suicide-command-denied");
|
|
|
|
|
shell.WriteLine(deniedMessage);
|
2024-05-12 17:34:52 -07:00
|
|
|
_e.System<PopupSystem>()
|
2024-05-12 16:35:30 +02:00
|
|
|
.PopupEntity(deniedMessage, victim, victim);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-12 16:09:15 -07:00
|
|
|
if (suicideSystem.Suicide(victim))
|
|
|
|
|
return;
|
|
|
|
|
|
2024-05-12 16:35:30 +02:00
|
|
|
shell.WriteLine(Loc.GetString("ghost-command-denied"));
|
2020-05-27 20:05:12 -03:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-13 09:45:09 +02:00
|
|
|
}
|