2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Mind.Components;
|
2020-02-24 03:49:40 +01:00
|
|
|
using Content.Server.Players;
|
2020-10-30 16:06:48 +01:00
|
|
|
using Content.Shared.Administration;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.Player;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-02-24 03:49:40 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Localization;
|
2021-03-16 15:50:20 +01:00
|
|
|
using Robust.Shared.Utility;
|
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
|
|
|
{
|
2020-10-30 16:06:48 +01:00
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
2022-02-16 00:23:23 -07:00
|
|
|
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
|
|
|
{
|
2021-12-05 18:09:01 +01:00
|
|
|
if (shell.Player is not IPlayerSession 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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
var target = new EntityUid(targetId);
|
2020-02-24 03:49:40 +01:00
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
if (!target.IsValid() || !_entities.EntityExists(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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
if (!_entities.HasComponent<MindComponent>(target))
|
2020-02-24 03:49:40 +01:00
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("shell-entity-is-not-mob"));
|
2020-02-24 03:49:40 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 15:50:20 +01:00
|
|
|
var mind = player.ContentData()?.Mind;
|
|
|
|
|
|
|
|
|
|
DebugTools.AssertNotNull(mind);
|
|
|
|
|
|
2021-12-03 15:53:09 +01:00
|
|
|
mind!.TransferTo(target);
|
2020-02-24 03:49:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|