Ghost toggle lighting ability (#12374)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user