]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add command to toggle ghost visibility on the client (#27314)
authorShadowCommander <shadowjjt@gmail.com>
Thu, 25 Apr 2024 16:26:21 +0000 (09:26 -0700)
committerGitHub <noreply@github.com>
Thu, 25 Apr 2024 16:26:21 +0000 (18:26 +0200)
* Add command to toggle ghost visibility on the client

* Fix description

* Fix index of arg parsing

* Allow setting GhostVisibility directly

Content.Client/Ghost/Commands/ToggleGhostVisibilityCommand.cs [new file with mode: 0644]
Content.Client/Ghost/GhostSystem.cs

diff --git a/Content.Client/Ghost/Commands/ToggleGhostVisibilityCommand.cs b/Content.Client/Ghost/Commands/ToggleGhostVisibilityCommand.cs
new file mode 100644 (file)
index 0000000..480da6a
--- /dev/null
@@ -0,0 +1,26 @@
+using Robust.Shared.Console;
+
+namespace Content.Client.Ghost.Commands;
+
+public sealed class ToggleGhostVisibilityCommand : IConsoleCommand
+{
+    [Dependency] private readonly IEntitySystemManager _entSysMan = default!;
+
+    public string Command => "toggleghostvisibility";
+    public string Description => "Toggles ghost visibility on the client.";
+    public string Help => "toggleghostvisibility [bool]";
+
+    public void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        var ghostSystem = _entSysMan.GetEntitySystem<GhostSystem>();
+
+        if (args.Length != 0 && bool.TryParse(args[0], out var visibility))
+        {
+            ghostSystem.ToggleGhostVisibility(visibility);
+        }
+        else
+        {
+            ghostSystem.ToggleGhostVisibility();
+        }
+    }
+}
index c42e7cd0e0c5f45be4b2a9b79b28d32793566d3a..94872a58ef9772247b801287df0b3195bcbe1bd7 100644 (file)
@@ -3,7 +3,6 @@ using Content.Shared.Actions;
 using Content.Shared.Ghost;
 using Robust.Client.Console;
 using Robust.Client.GameObjects;
-using Robust.Client.Graphics;
 using Robust.Client.Player;
 using Robust.Shared.Player;
 
@@ -177,9 +176,9 @@ namespace Content.Client.Ghost
             _console.RemoteExecuteCommand(null, "ghostroles");
         }
 
-        public void ToggleGhostVisibility()
+        public void ToggleGhostVisibility(bool? visibility = null)
         {
-            GhostVisibility = !GhostVisibility;
+            GhostVisibility = visibility ?? !GhostVisibility;
         }
     }
 }