mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-09-15 14:52:26 +02:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using Content.Shared.Administration;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Content.Server.Administration.Commands;
|
|
|
|
[AdminCommand(AdminFlags.Spawn)]
|
|
public sealed partial class DeleteComponentCommand : LocalizedEntityCommands
|
|
{
|
|
[Dependency] private IComponentFactory _compFactory = default!;
|
|
|
|
public override string Command => "deletecomponent";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length == 0)
|
|
{
|
|
shell.WriteLine(Loc.GetString($"shell-need-exactly-one-argument"));
|
|
return;
|
|
}
|
|
|
|
var name = string.Join(" ", args);
|
|
|
|
if (!_compFactory.TryGetRegistration(name, out var registration))
|
|
{
|
|
shell.WriteLine(Loc.GetString($"cmd-deletecomponent-no-component-exists", ("name", name)));
|
|
return;
|
|
}
|
|
|
|
var componentType = registration.Type;
|
|
var components = EntityManager.GetAllComponents(componentType, true);
|
|
|
|
var i = 0;
|
|
|
|
foreach (var (uid, component) in components)
|
|
{
|
|
EntityManager.RemoveComponent(uid, component);
|
|
i++;
|
|
}
|
|
|
|
shell.WriteLine(Loc.GetString($"cmd-deletecomponent-success", ("count", i), ("name", name)));
|
|
}
|
|
}
|