funny container commands (#5113)

This commit is contained in:
moonheart08
2021-11-01 23:32:58 -05:00
committed by GitHub
parent b4d32bdb29
commit a27c1d9bd9
6 changed files with 320 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
using Content.Server.Body;
using Content.Server.Body.Mechanism;
using Content.Server.Body.Part;
using Content.Server.Storage.Components;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Fun)]
public class AddBodyPartCommand : IConsoleCommand
{
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;
}
if (!EntityUid.TryParse(args[0], out var entityUid))
{
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
return;
}
if (!EntityUid.TryParse(args[1], out var storageUid))
{
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (entityManager.TryGetComponent<BodyComponent>(storageUid, out var storage)
&& entityManager.TryGetComponent<BodyPartComponent>(entityUid, out var bodyPart))
{
if (storage.TryAddPart(args[3], bodyPart))
{
shell.WriteLine($@"Added {entityUid} to {storageUid}.");
}
else
{
shell.WriteError($@"Could not add {entityUid} to {storageUid}.");
}
}
else
{
shell.WriteError("Could not insert.");
}
}
}
}