From 219609d35888f71d6c75d6e5851cbf613b909038 Mon Sep 17 00:00:00 2001 From: wrexbe <81056464+wrexbe@users.noreply.github.com> Date: Mon, 30 May 2022 00:06:50 -0700 Subject: [PATCH] Dirty Command (#8533) Dirty Command Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> --- .../Administration/Commands/DirtyCommand.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Content.Server/Administration/Commands/DirtyCommand.cs diff --git a/Content.Server/Administration/Commands/DirtyCommand.cs b/Content.Server/Administration/Commands/DirtyCommand.cs new file mode 100644 index 0000000000..6b23c42238 --- /dev/null +++ b/Content.Server/Administration/Commands/DirtyCommand.cs @@ -0,0 +1,45 @@ +using Content.Shared.Administration; +using Robust.Shared.Console; + +namespace Content.Server.Administration.Commands; + +[AdminCommand(AdminFlags.Debug)] +public sealed class DirtyCommand : IConsoleCommand +{ + public string Command => "dirty"; + public string Description => "Marks all components on an entity as dirty, if not specified, dirties everything"; + public string Help => $"Usage: {Command} [entityUid]"; + + public async void Execute(IConsoleShell shell, string argStr, string[] args) + { + var entityManager = IoCManager.Resolve(); + switch (args.Length) + { + case 0: + foreach (var entity in entityManager.GetEntities()) + { + DirtyAll(entityManager, entity); + } + break; + case 1: + if (!EntityUid.TryParse(args[0], out var parsedTarget)) + { + shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); + return; + } + DirtyAll(entityManager, parsedTarget); + break; + default: + shell.WriteLine(Loc.GetString("shell-wrong-arguments-number")); + break; + } + } + + private static void DirtyAll(IEntityManager manager, EntityUid entityUid) + { + foreach (var component in manager.GetComponents(entityUid)) + { + manager.Dirty(component); + } + } +}