2022-10-23 00:46:28 +02:00
|
|
|
using Content.Server.Body.Systems;
|
2021-11-01 23:32:58 -05:00
|
|
|
using Content.Shared.Administration;
|
|
|
|
|
using Robust.Shared.Console;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Administration.Commands
|
|
|
|
|
{
|
2022-09-14 17:02:38 -07:00
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class AddMechanismCommand : IConsoleCommand
|
2021-11-01 23:32:58 -05:00
|
|
|
{
|
|
|
|
|
public string Command => "addmechanism";
|
|
|
|
|
public string Description => "Adds a given entity to a containing body.";
|
|
|
|
|
public string Help => "Usage: addmechanism <entity uid> <bodypart uid>";
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length != 2)
|
|
|
|
|
{
|
|
|
|
|
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-23 00:46:28 +02:00
|
|
|
if (!EntityUid.TryParse(args[0], out var organId))
|
2021-11-01 23:32:58 -05:00
|
|
|
{
|
|
|
|
|
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-23 00:46:28 +02:00
|
|
|
if (!EntityUid.TryParse(args[1], out var partId))
|
2021-11-01 23:32:58 -05:00
|
|
|
{
|
|
|
|
|
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
2022-10-23 00:46:28 +02:00
|
|
|
var bodySystem = entityManager.System<BodySystem>();
|
2021-11-01 23:32:58 -05:00
|
|
|
|
2022-10-23 00:46:28 +02:00
|
|
|
if (bodySystem.AddOrganToFirstValidSlot(organId, partId))
|
2021-11-01 23:32:58 -05:00
|
|
|
{
|
2022-10-23 00:46:28 +02:00
|
|
|
shell.WriteLine($@"Added {organId} to {partId}.");
|
2021-11-01 23:32:58 -05:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-10-23 00:46:28 +02:00
|
|
|
shell.WriteError($@"Could not add {organId} to {partId}.");
|
2021-11-01 23:32:58 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|