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 AddBodyPartCommand : IConsoleCommand
|
2021-11-01 23:32:58 -05:00
|
|
|
{
|
|
|
|
|
public string Command => "addbodypart";
|
|
|
|
|
public string Description => "Adds a given entity to a containing body.";
|
|
|
|
|
public string Help => "Usage: addbodypart <entity uid> <body uid> <part slot>";
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length != 3)
|
|
|
|
|
{
|
|
|
|
|
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-23 00:46:28 +02:00
|
|
|
if (!EntityUid.TryParse(args[0], out var childId))
|
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 parentId))
|
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
|
|
|
|
2023-05-16 00:24:03 +03:00
|
|
|
if (bodySystem.TryCreatePartSlotAndAttach(parentId, args[2], childId))
|
2021-11-01 23:32:58 -05:00
|
|
|
{
|
2022-10-23 00:46:28 +02:00
|
|
|
shell.WriteLine($@"Added {childId} to {parentId}.");
|
2021-11-01 23:32:58 -05:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-10-23 00:46:28 +02:00
|
|
|
shell.WriteError($@"Could not add {childId} to {parentId}.");
|
2021-11-01 23:32:58 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|