diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs index 149ce7e353..bac7632d01 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs @@ -1,3 +1,4 @@ +using System.Linq; using Content.Server.Administration; using Content.Server.Atmos.Components; using Content.Shared.Administration; @@ -16,7 +17,7 @@ public sealed partial class AtmosphereSystem // Fix Grid Atmos command. _consoleHost.RegisterCommand("fixgridatmos", "Makes every tile on a grid have a roundstart gas mix.", - "fixgridatmos ", FixGridAtmosCommand); + "fixgridatmos ", FixGridAtmosCommand, FixGridAtmosCommandCompletions); } private void ShutdownCommands() @@ -57,11 +58,11 @@ public sealed partial class AtmosphereSystem mixtures[5].AdjustMoles(Gas.Plasma, Atmospherics.MolesCellGasMiner); mixtures[5].Temperature = 5000f; - foreach (var gid in args) + foreach (var arg in args) { - if(!EntityUid.TryParse(gid, out var euid)) + if(!EntityUid.TryParse(arg, out var euid)) { - shell.WriteError($"Failed to parse euid '{gid}'."); + shell.WriteError($"Failed to parse euid '{arg}'."); return; } @@ -100,4 +101,19 @@ public sealed partial class AtmosphereSystem } } } + + private CompletionResult FixGridAtmosCommandCompletions(IConsoleShell shell, string[] args) + { + MapId? playerMap = null; + if (shell.Player is { AttachedEntity: { } playerEnt }) + playerMap = Transform(playerEnt).MapID; + + var options = _mapManager.GetAllGrids() + .OrderByDescending(e => playerMap != null && e.ParentMapId == playerMap) + .ThenBy(e => (int) e.ParentMapId) + .ThenBy(e => (int) e.GridEntityId) + .Select(e => new CompletionOption(e.GridEntityId.ToString(), $"{MetaData(e.GridEntityId).EntityName} - Map {e.ParentMapId}")); + + return CompletionResult.FromOptions(options); + } }