diff --git a/Content.Server/Administration/DeleteEntitiesWithComponent.cs b/Content.Server/Administration/DeleteEntitiesWithComponent.cs new file mode 100644 index 0000000000..b476ba3a0d --- /dev/null +++ b/Content.Server/Administration/DeleteEntitiesWithComponent.cs @@ -0,0 +1,62 @@ +using Robust.Server.Interfaces.Console; +using Robust.Server.Interfaces.Player; +using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Localization; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Content.Server.Administration +{ + class DeleteEntitiesWithComponent : IClientCommand + { + public string Command => "deleteewc"; + public string Description + { + get + { + var localizationManager = IoCManager.Resolve(); + return localizationManager.GetString("Deletes entities with the specified components."); + } + } + public string Help + { + get + { + var localizationManager = IoCManager.Resolve(); + return localizationManager.GetString("Usage: deleteewc ... \nDeletes any entities with the components specified."); + } + } + + public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) + { + var localizationManager = IoCManager.Resolve(); + if (args.Length < 1) + { + shell.SendText(player, Help); + return; + } + + var factory = IoCManager.Resolve(); + + var components = new List(); + foreach (var arg in args) + { + components.Add(factory.GetRegistration(arg).Type); + } + + var entityManager = IoCManager.Resolve(); + var entities = entityManager.GetEntities(new MultipleTypeEntityQuery(components)); + var count = 0; + foreach (var entity in entities) + { + entity.Delete(); + count += 1; + } + + shell.SendText(player, localizationManager.GetString("Deleted {0} entities", count)); + } + } +} diff --git a/Resources/Groups/groups.yml b/Resources/Groups/groups.yml index a8e006cddb..99f52c169f 100644 --- a/Resources/Groups/groups.yml +++ b/Resources/Groups/groups.yml @@ -79,6 +79,7 @@ - addai - warp - hostlogin + - deleteewc CanViewVar: true CanAdminPlace: true @@ -145,6 +146,7 @@ - gc - gc_mode - warp + - deleteewc CanViewVar: true CanAdminPlace: true CanScript: true