mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Add command to toggle ghost visibility on the client (#27314)
* Add command to toggle ghost visibility on the client * Fix description * Fix index of arg parsing * Allow setting GhostVisibility directly
This commit is contained in:
parent
960a50c0ff
commit
cf45005471
2 changed files with 28 additions and 3 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue