diff --git a/Content.Client/Ghost/GhostComponent.cs b/Content.Client/Ghost/GhostComponent.cs index 13966d76bf..4a3e1eb743 100644 --- a/Content.Client/Ghost/GhostComponent.cs +++ b/Content.Client/Ghost/GhostComponent.cs @@ -20,7 +20,19 @@ namespace Content.Client.Ghost CheckCanInteract = false, Event = new DisableLightingActionEvent(), }; + + public InstantAction ToggleGhostsAction = new() + { + Icon = new SpriteSpecifier.Rsi(new ResourcePath("Mobs/Ghosts/ghost_human.rsi"), "icon"), + DisplayName = "ghost-gui-toggle-ghost-visibility-name", + Description = "ghost-gui-toggle-ghost-visibility-desc", + ClientExclusive = true, + CheckCanInteract = false, + Event = new ToggleGhostsActionEvent(), + }; } public sealed class DisableLightingActionEvent : InstantActionEvent { }; + + public sealed class ToggleGhostsActionEvent : InstantActionEvent { }; } diff --git a/Content.Client/Ghost/GhostSystem.cs b/Content.Client/Ghost/GhostSystem.cs index f9ce30c181..33aacf9cfd 100644 --- a/Content.Client/Ghost/GhostSystem.cs +++ b/Content.Client/Ghost/GhostSystem.cs @@ -67,6 +67,7 @@ namespace Content.Client.Ghost SubscribeNetworkEvent(OnUpdateGhostRoleCount); SubscribeLocalEvent(OnActionPerform); + SubscribeLocalEvent(OnToggleGhosts); } private void OnGhostInit(EntityUid uid, GhostComponent component, ComponentInit args) @@ -77,6 +78,7 @@ namespace Content.Client.Ghost } _actions.AddAction(uid, component.DisableLightingAction, null); + _actions.AddAction(uid, component.ToggleGhostsAction, null); } private void OnActionPerform(EntityUid uid, GhostComponent component, DisableLightingActionEvent args) @@ -88,9 +90,19 @@ namespace Content.Client.Ghost args.Handled = true; } + private void OnToggleGhosts(EntityUid uid, GhostComponent component, ToggleGhostsActionEvent args) + { + if (args.Handled) + return; + + ToggleGhostVisibility(); + args.Handled = true; + } + private void OnGhostRemove(EntityUid uid, GhostComponent component, ComponentRemove args) { _actions.RemoveAction(uid, component.DisableLightingAction); + _actions.RemoveAction(uid, component.ToggleGhostsAction); _lightManager.Enabled = true; if (uid != _playerManager.LocalPlayer?.ControlledEntity) diff --git a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs index 9f10d0dfe2..c379cbf643 100644 --- a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs +++ b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs @@ -99,7 +99,6 @@ public sealed class GhostUIController : UIController, IOnSystemChanged