Files
OldThink/Content.Server/Administration/Commands/AddMechanismCommand.cs

48 lines
1.5 KiB
C#
Raw Normal View History

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
{
[AdminCommand(AdminFlags.Admin)]
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;
}
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;
}
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>();
var bodySystem = entityManager.System<BodySystem>();
2021-11-01 23:32:58 -05:00
if (bodySystem.AddOrganToFirstValidSlot(organId, partId))
2021-11-01 23:32:58 -05:00
{
shell.WriteLine($@"Added {organId} to {partId}.");
2021-11-01 23:32:58 -05:00
}
else
{
shell.WriteError($@"Could not add {organId} to {partId}.");
2021-11-01 23:32:58 -05:00
}
}
}
}