Files
tbd-station-14/Content.Server/EntityList/SpawnEntityListCommand.cs
Brandon Hu 31c5d3555e fix(Commands): Improve Localization of commands. Standardize some behaviors. (#30362)
* I should be studying for school but that is sofucking boring, I will pass my class no matter, however getting an A might be a challenge. My gpa is important but is the tourture for 1 point of GPA worth it? The american government says yes but they are responsible for the majority of all genocides that have ever been conducted since the dawn of man

* ugh

* ugh
2024-08-11 19:46:57 +10:00

57 lines
1.8 KiB
C#

using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.EntityList;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
namespace Content.Server.EntityList
{
[AdminCommand(AdminFlags.Spawn)]
public sealed class SpawnEntityListCommand : IConsoleCommand
{
public string Command => "spawnentitylist";
public string Description => "Spawns a list of entities around you";
public string Help => $"Usage: {Command} <entityListPrototypeId>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteError($"Invalid arguments.\n{Help}");
return;
}
if (shell.Player is not { } player)
{
shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server"));
return;
}
if (player.AttachedEntity is not {} attached)
{
shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command"));
return;
}
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
if (!prototypeManager.TryIndex(args[0], out EntityListPrototype? prototype))
{
shell.WriteError($"No {nameof(EntityListPrototype)} found with id {args[0]}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var i = 0;
foreach (var entity in prototype.Entities(prototypeManager))
{
entityManager.SpawnEntity(entity.ID, entityManager.GetComponent<TransformComponent>(attached).Coordinates);
i++;
}
shell.WriteLine($"Spawned {i} entities.");
}
}
}