diff --git a/Content.Client/Ghost/GhostComponent.cs b/Content.Client/Ghost/GhostComponent.cs index 3b228a8f8b..13966d76bf 100644 --- a/Content.Client/Ghost/GhostComponent.cs +++ b/Content.Client/Ghost/GhostComponent.cs @@ -1,4 +1,7 @@ +using Content.Shared.Actions; +using Content.Shared.Actions.ActionTypes; using Content.Shared.Ghost; +using Robust.Shared.Utility; namespace Content.Client.Ghost { @@ -7,5 +10,17 @@ namespace Content.Client.Ghost public sealed class GhostComponent : SharedGhostComponent { public bool IsAttached { get; set; } + + public InstantAction DisableLightingAction = 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", + ClientExclusive = true, + CheckCanInteract = false, + Event = new DisableLightingActionEvent(), + }; } + + public sealed class DisableLightingActionEvent : InstantActionEvent { }; } diff --git a/Content.Client/Ghost/GhostSystem.cs b/Content.Client/Ghost/GhostSystem.cs index b701c0d498..f9ce30c181 100644 --- a/Content.Client/Ghost/GhostSystem.cs +++ b/Content.Client/Ghost/GhostSystem.cs @@ -1,7 +1,9 @@ +using Content.Shared.Actions; using Content.Shared.Ghost; using JetBrains.Annotations; using Robust.Client.Console; using Robust.Client.GameObjects; +using Robust.Client.Graphics; using Robust.Client.Player; using Robust.Shared.GameStates; @@ -12,6 +14,8 @@ namespace Content.Client.Ghost { [Dependency] private readonly IClientConsoleHost _console = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly SharedActionsSystem _actions = default!; + [Dependency] private readonly ILightManager _lightManager = default!; public int AvailableGhostRoleCount { get; private set; } @@ -61,6 +65,8 @@ namespace Content.Client.Ghost SubscribeNetworkEvent(OnGhostWarpsResponse); SubscribeNetworkEvent(OnUpdateGhostRoleCount); + + SubscribeLocalEvent(OnActionPerform); } private void OnGhostInit(EntityUid uid, GhostComponent component, ComponentInit args) @@ -69,10 +75,24 @@ namespace Content.Client.Ghost { sprite.Visible = GhostVisibility; } + + _actions.AddAction(uid, component.DisableLightingAction, null); + } + + private void OnActionPerform(EntityUid uid, GhostComponent component, DisableLightingActionEvent args) + { + if (args.Handled) + return; + + _lightManager.Enabled = !_lightManager.Enabled; + args.Handled = true; } private void OnGhostRemove(EntityUid uid, GhostComponent component, ComponentRemove args) { + _actions.RemoveAction(uid, component.DisableLightingAction); + _lightManager.Enabled = true; + if (uid != _playerManager.LocalPlayer?.ControlledEntity) return; diff --git a/Resources/Locale/en-US/ghost/ghost-gui.ftl b/Resources/Locale/en-US/ghost/ghost-gui.ftl index 74b52cd304..69cdba1f01 100644 --- a/Resources/Locale/en-US/ghost/ghost-gui.ftl +++ b/Resources/Locale/en-US/ghost/ghost-gui.ftl @@ -2,6 +2,8 @@ ghost-gui-return-to-body-button = Return to body ghost-gui-ghost-warp-button = Ghost Warp ghost-gui-ghost-roles-button = Ghost Roles ({$count}) ghost-gui-toggle-ghost-visibility-button = Toggle 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-target-window-title = Ghost Warp ghost-target-window-current-button = Warp: {$name} @@ -12,4 +14,3 @@ ghost-roles-window-request-role-button-timer = Request ({$time}s) ghost-roles-window-follow-role-button = Follow ghost-roles-window-no-roles-available-label = There are currently no available ghost roles. ghost-roles-window-rules-footer = The button will enable after {$time} seconds (this delay is to make sure you read the rules). -