Ghost toggle lighting ability (#12374)

This commit is contained in:
Francesco
2022-11-04 01:56:30 +01:00
committed by GitHub
parent 331b01b7df
commit 0aba807ac2
3 changed files with 37 additions and 1 deletions

View File

@@ -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<GhostWarpsResponseEvent>(OnGhostWarpsResponse);
SubscribeNetworkEvent<GhostUpdateGhostRoleCountEvent>(OnUpdateGhostRoleCount);
SubscribeLocalEvent<GhostComponent, DisableLightingActionEvent>(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;