From 01e0ea7922bf9ad7369b0912adf9998bc7402f8e Mon Sep 17 00:00:00 2001 From: Kara Date: Wed, 30 Nov 2022 23:46:04 -0600 Subject: [PATCH] Ghost toggle FoV action (#12818) * Ghost toggle FoV action * p --- Content.Client/Ghost/GhostComponent.cs | 21 ++++++++++++++++++--- Content.Client/Ghost/GhostSystem.cs | 21 +++++++++++++++++---- Content.Server/Ghost/GhostSystem.cs | 6 +++--- Resources/Locale/en-US/ghost/ghost-gui.ftl | 9 +++++++-- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/Content.Client/Ghost/GhostComponent.cs b/Content.Client/Ghost/GhostComponent.cs index 4a3e1eb743..aaf1da46e6 100644 --- a/Content.Client/Ghost/GhostComponent.cs +++ b/Content.Client/Ghost/GhostComponent.cs @@ -11,14 +11,26 @@ namespace Content.Client.Ghost { public bool IsAttached { get; set; } - public InstantAction DisableLightingAction = new() + public InstantAction ToggleLightingAction = new() { Icon = new SpriteSpecifier.Texture(new ResourcePath("Interface/VerbIcons/light.svg.192dpi.png")), DisplayName = "ghost-gui-toggle-lighting-manager-name", Description = "ghost-gui-toggle-lighting-manager-desc", + UserPopup = "ghost-gui-toggle-lighting-manager-popup", ClientExclusive = true, CheckCanInteract = false, - Event = new DisableLightingActionEvent(), + Event = new ToggleLightingActionEvent(), + }; + + public InstantAction ToggleFoVAction = new() + { + Icon = new SpriteSpecifier.Texture(new ResourcePath("Interface/VerbIcons/vv.svg.192dpi.png")), + DisplayName = "ghost-gui-toggle-fov-name", + Description = "ghost-gui-toggle-fov-desc", + UserPopup = "ghost-gui-toggle-fov-popup", + ClientExclusive = true, + CheckCanInteract = false, + Event = new ToggleFoVActionEvent(), }; public InstantAction ToggleGhostsAction = new() @@ -26,13 +38,16 @@ namespace Content.Client.Ghost 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", + UserPopup = "ghost-gui-toggle-ghost-visibility-popup", ClientExclusive = true, CheckCanInteract = false, Event = new ToggleGhostsActionEvent(), }; } - public sealed class DisableLightingActionEvent : InstantActionEvent { }; + public sealed class ToggleLightingActionEvent : InstantActionEvent { }; + + public sealed class ToggleFoVActionEvent : InstantActionEvent { }; public sealed class ToggleGhostsActionEvent : InstantActionEvent { }; } diff --git a/Content.Client/Ghost/GhostSystem.cs b/Content.Client/Ghost/GhostSystem.cs index 33aacf9cfd..73fb26f1dd 100644 --- a/Content.Client/Ghost/GhostSystem.cs +++ b/Content.Client/Ghost/GhostSystem.cs @@ -16,6 +16,7 @@ namespace Content.Client.Ghost [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly SharedActionsSystem _actions = default!; [Dependency] private readonly ILightManager _lightManager = default!; + [Dependency] private readonly IEyeManager _eye = default!; public int AvailableGhostRoleCount { get; private set; } @@ -66,7 +67,8 @@ namespace Content.Client.Ghost SubscribeNetworkEvent(OnGhostWarpsResponse); SubscribeNetworkEvent(OnUpdateGhostRoleCount); - SubscribeLocalEvent(OnActionPerform); + SubscribeLocalEvent(OnToggleLighting); + SubscribeLocalEvent(OnToggleFoV); SubscribeLocalEvent(OnToggleGhosts); } @@ -77,11 +79,12 @@ namespace Content.Client.Ghost sprite.Visible = GhostVisibility; } - _actions.AddAction(uid, component.DisableLightingAction, null); + _actions.AddAction(uid, component.ToggleLightingAction, null); + _actions.AddAction(uid, component.ToggleFoVAction, null); _actions.AddAction(uid, component.ToggleGhostsAction, null); } - private void OnActionPerform(EntityUid uid, GhostComponent component, DisableLightingActionEvent args) + private void OnToggleLighting(EntityUid uid, GhostComponent component, ToggleLightingActionEvent args) { if (args.Handled) return; @@ -90,6 +93,15 @@ namespace Content.Client.Ghost args.Handled = true; } + private void OnToggleFoV(EntityUid uid, GhostComponent component, ToggleFoVActionEvent args) + { + if (args.Handled) + return; + + _eye.CurrentEye.DrawFov = !_eye.CurrentEye.DrawFov; + args.Handled = true; + } + private void OnToggleGhosts(EntityUid uid, GhostComponent component, ToggleGhostsActionEvent args) { if (args.Handled) @@ -101,7 +113,8 @@ namespace Content.Client.Ghost private void OnGhostRemove(EntityUid uid, GhostComponent component, ComponentRemove args) { - _actions.RemoveAction(uid, component.DisableLightingAction); + _actions.RemoveAction(uid, component.ToggleLightingAction); + _actions.RemoveAction(uid, component.ToggleFoVAction); _actions.RemoveAction(uid, component.ToggleGhostsAction); _lightManager.Enabled = true; diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index af79e72f4c..13b99b3e0f 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -298,7 +298,7 @@ namespace Content.Server.Ghost return ghostBoo.Handled; } } - + [AnyCommand] public sealed class ToggleGhostVisibility : IConsoleCommand { @@ -308,10 +308,10 @@ namespace Content.Server.Ghost public void Execute(IConsoleShell shell, string argStr, string[] args) { if (shell.Player == null) - shell.WriteLine("You can only open the ghost roles UI on a client."); + shell.WriteLine("You can only toggle ghost visibility on a client."); var entityManager = IoCManager.Resolve(); - + var uid = shell.Player?.AttachedEntity; if (uid == null || !entityManager.HasComponent(uid) diff --git a/Resources/Locale/en-US/ghost/ghost-gui.ftl b/Resources/Locale/en-US/ghost/ghost-gui.ftl index 1d4560879e..bf0be3bc72 100644 --- a/Resources/Locale/en-US/ghost/ghost-gui.ftl +++ b/Resources/Locale/en-US/ghost/ghost-gui.ftl @@ -3,8 +3,13 @@ ghost-gui-ghost-warp-button = Ghost Warp ghost-gui-ghost-roles-button = Ghost Roles ({$count}) ghost-gui-toggle-ghost-visibility-name = Toggle Ghosts ghost-gui-toggle-ghost-visibility-desc = Toggle the visibility of other ghosts. -ghost-gui-toggle-lighting-manager-name = Toggle Lighting -ghost-gui-toggle-lighting-manager-desc = Toggle light rendering to better observe dark areas or to see what players see. +ghost-gui-toggle-ghost-visibility-popup = Toggled visibility of ghosts. +ghost-gui-toggle-lighting-manager-name = Toggle All Lighting +ghost-gui-toggle-lighting-manager-desc = Toggle all light rendering to better observe dark areas. +ghost-gui-toggle-lighting-manager-popup = Toggled all lighting. +ghost-gui-toggle-fov-name = Toggle FoV +ghost-gui-toggle-fov-desc = Toggles field-of-view in order to see what players see. +ghost-gui-toggle-fov-popup = Toggled field-of-view. ghost-target-window-title = Ghost Warp ghost-target-window-current-button = Warp: {$name}