2023-10-25 01:23:56 +11:00
|
|
|
using Content.Server.Mind;
|
2020-10-30 16:06:48 +01:00
|
|
|
using Content.Shared.Administration;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-02-24 03:49:40 +01:00
|
|
|
|
2020-10-30 16:06:48 +01:00
|
|
|
namespace Content.Server.Administration.Commands
|
2020-02-24 03:49:40 +01:00
|
|
|
{
|
2022-07-14 22:34:07 +10:00
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
|
|
|
public sealed class ControlMob : IConsoleCommand
|
2020-02-24 03:49:40 +01:00
|
|
|
{
|
2021-12-05 18:09:01 +01:00
|
|
|
[Dependency] private readonly IEntityManager _entities = default!;
|
|
|
|
|
|
2020-02-24 03:49:40 +01:00
|
|
|
public string Command => "controlmob";
|
2021-06-21 02:13:54 +02:00
|
|
|
public string Description => Loc.GetString("control-mob-command-description");
|
|
|
|
|
public string Help => Loc.GetString("control-mob-command-help-text");
|
2020-02-24 03:49:40 +01:00
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-02-24 03:49:40 +01:00
|
|
|
{
|
2023-10-28 09:59:53 +11:00
|
|
|
if (shell.Player is not { } player)
|
2020-02-24 03:49:40 +01:00
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine("shell-server-cannot");
|
2020-02-24 03:49:40 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (args.Length != 1)
|
|
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("shell-wrong-arguments-number"));
|
2020-02-24 03:49:40 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!int.TryParse(args[0], out var targetId))
|
|
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("shell-argument-must-be-number"));
|
2020-02-24 03:49:40 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 19:04:31 -05:00
|
|
|
var targetNet = new NetEntity(targetId);
|
2020-02-24 03:49:40 +01:00
|
|
|
|
2024-01-03 19:04:31 -05:00
|
|
|
if (!_entities.TryGetEntity(targetNet, out var target))
|
2020-02-24 03:49:40 +01:00
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("shell-invalid-entity-id"));
|
2020-02-24 03:49:40 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 19:04:31 -05:00
|
|
|
_entities.System<MindSystem>().ControlMob(player.UserId, target.Value);
|
2020-02-24 03:49:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|