@@ -3,52 +3,41 @@ using Content.Shared.Administration;
|
|||||||
using Content.Shared.Body.Part;
|
using Content.Shared.Body.Part;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
namespace Content.Server.Administration.Commands
|
namespace Content.Server.Administration.Commands;
|
||||||
|
|
||||||
|
[AdminCommand(AdminFlags.Admin)]
|
||||||
|
public sealed class AddBodyPartCommand : LocalizedEntityCommands
|
||||||
{
|
{
|
||||||
[AdminCommand(AdminFlags.Admin)]
|
[Dependency] private readonly BodySystem _bodySystem = default!;
|
||||||
public sealed class AddBodyPartCommand : IConsoleCommand
|
|
||||||
|
public override string Command => "addbodypart";
|
||||||
|
|
||||||
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
if (args.Length != 4)
|
||||||
|
|
||||||
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> <part type>";
|
|
||||||
|
|
||||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
||||||
{
|
{
|
||||||
if (args.Length != 3)
|
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
||||||
{
|
return;
|
||||||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NetEntity.TryParse(args[0], out var childNetId))
|
|
||||||
{
|
|
||||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NetEntity.TryParse(args[1], out var parentNetId))
|
|
||||||
{
|
|
||||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var childId = _entManager.GetEntity(childNetId);
|
|
||||||
var parentId = _entManager.GetEntity(parentNetId);
|
|
||||||
var bodySystem = _entManager.System<BodySystem>();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (Enum.TryParse<BodyPartType>(args[3], out var partType) &&
|
|
||||||
bodySystem.TryCreatePartSlotAndAttach(parentId, args[2], childId, partType))
|
|
||||||
{
|
|
||||||
shell.WriteLine($@"Added {childId} to {parentId}.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shell.WriteError($@"Could not add {childId} to {parentId}.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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}.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
shell.WriteError($@"Could not add {childId} to {parentId}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
cmd-addbodypart-desc = Adds a given entity to a containing body.
|
||||||
|
cmd-addbodypart-help = Usage: addbodypart <entity uid> <body uid> <part slot> <part type>
|
||||||
Reference in New Issue
Block a user