funny container commands (#5113)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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 AddEntityStorageCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "addstorage";
|
||||
public string Description => "Adds a given entity to a containing storage.";
|
||||
public string Help => "Usage: addstorage <entity uid> <storage 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 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<EntityStorageComponent>(storageUid, out var storage))
|
||||
{
|
||||
storage.Insert(entityManager.GetEntity(entityUid));
|
||||
}
|
||||
else
|
||||
{
|
||||
shell.WriteError("Could not insert into non-storage.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user