Files
OldThink/Content.Server/Administration/Commands/AddEntityStorageCommand.cs

49 lines
1.6 KiB
C#
Raw Normal View History

2021-11-01 23:32:58 -05:00
using Content.Server.Storage.Components;
2022-07-13 19:11:59 -04:00
using Content.Server.Storage.EntitySystems;
2021-11-01 23:32:58 -05:00
using Content.Shared.Administration;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Admin)]
public sealed class AddEntityStorageCommand : IConsoleCommand
2021-11-01 23:32:58 -05:00
{
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>();
2022-07-13 19:11:59 -04:00
if (entityManager.HasComponent<EntityStorageComponent>(storageUid) &&
entityManager.EntitySysManager.TryGetEntitySystem<EntityStorageSystem>(out var storageSys))
2021-11-01 23:32:58 -05:00
{
2022-07-13 19:11:59 -04:00
storageSys.Insert(entityUid, storageUid);
2021-11-01 23:32:58 -05:00
}
else
{
shell.WriteError("Could not insert into non-storage.");
}
}
}
}