Convert ghost toggle button into an action (#12658)

* Convert ghost toggle button into an action

* figs
This commit is contained in:
Kara
2022-11-18 16:30:53 -06:00
committed by GitHub
parent f12eb55153
commit c71850a53f
8 changed files with 28 additions and 14 deletions

View File

@@ -67,6 +67,7 @@ namespace Content.Client.Ghost
SubscribeNetworkEvent<GhostUpdateGhostRoleCountEvent>(OnUpdateGhostRoleCount);
SubscribeLocalEvent<GhostComponent, DisableLightingActionEvent>(OnActionPerform);
SubscribeLocalEvent<GhostComponent, ToggleGhostsActionEvent>(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)