Files

44 lines
1.5 KiB
C#
Raw Permalink Normal View History

using Content.Server.Body.Systems;
2021-11-01 23:32:58 -05:00
using Content.Shared.Administration;
using Content.Shared.Body.Part;
2021-11-01 23:32:58 -05:00
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands;
[AdminCommand(AdminFlags.Admin)]
public sealed class AddBodyPartCommand : LocalizedEntityCommands
2021-11-01 23:32:58 -05:00
{
[Dependency] private readonly BodySystem _bodySystem = default!;
public override string Command => "addbodypart";
2021-11-01 23:32:58 -05:00
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 4)
2021-11-01 23:32:58 -05:00
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
return;
}
2021-11-01 23:32:58 -05:00
if (!NetEntity.TryParse(args[0], out var childNetId) || !EntityManager.TryGetEntity(childNetId, out var childId))
{
shell.WriteError(Loc.GetString("shell-invalid-entity-uid", ("uid", args[0])));
return;
}
if (!NetEntity.TryParse(args[1], out var parentNetId) || !EntityManager.TryGetEntity(parentNetId, out var parentId))
{
shell.WriteError(Loc.GetString("shell-invalid-entity-uid", ("uid", args[1])));
return;
}
if (Enum.TryParse<BodyPartType>(args[3], out var partType) &&
_bodySystem.TryCreatePartSlotAndAttach(parentId.Value, args[2], childId.Value, partType))
{
shell.WriteLine($@"Added {childId} to {parentId}.");
2021-11-01 23:32:58 -05:00
}
else
shell.WriteError($@"Could not add {childId} to {parentId}.");
2021-11-01 23:32:58 -05:00
}
}