Expensive for what it is just really annoying in debug to not have it. Worst case I just make it debug only and we don't add it for release.
56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using Content.Server.Mind;
|
|
using Content.Shared.Administration;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Content.Server.Administration.Commands
|
|
{
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
public sealed class ControlMob : IConsoleCommand
|
|
{
|
|
[Dependency] private readonly IEntityManager _entities = default!;
|
|
|
|
public string Command => "controlmob";
|
|
public string Description => Loc.GetString("control-mob-command-description");
|
|
public string Help => Loc.GetString("control-mob-command-help-text");
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (shell.Player is not { } player)
|
|
{
|
|
shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server"));
|
|
return;
|
|
}
|
|
|
|
if (args.Length != 1)
|
|
{
|
|
shell.WriteLine(Loc.GetString("shell-wrong-arguments-number"));
|
|
return;
|
|
}
|
|
|
|
if (!int.TryParse(args[0], out var targetId))
|
|
{
|
|
shell.WriteLine(Loc.GetString("shell-argument-must-be-number"));
|
|
return;
|
|
}
|
|
|
|
var targetNet = new NetEntity(targetId);
|
|
|
|
if (!_entities.TryGetEntity(targetNet, out var target))
|
|
{
|
|
shell.WriteLine(Loc.GetString("shell-invalid-entity-id"));
|
|
return;
|
|
}
|
|
|
|
_entities.System<MindSystem>().ControlMob(player.UserId, target.Value);
|
|
}
|
|
|
|
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
{
|
|
if (args.Length != 1)
|
|
return CompletionResult.Empty;
|
|
|
|
return CompletionResult.FromOptions(CompletionHelper.NetEntities(args[0], entManager: _entities));
|
|
}
|
|
}
|
|
}
|