Convert ghost toggle button into an action (#12658)
* Convert ghost toggle button into an action * figs
This commit is contained in:
@@ -20,7 +20,19 @@ namespace Content.Client.Ghost
|
||||
CheckCanInteract = false,
|
||||
Event = new DisableLightingActionEvent(),
|
||||
};
|
||||
|
||||
public InstantAction ToggleGhostsAction = new()
|
||||
{
|
||||
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",
|
||||
ClientExclusive = true,
|
||||
CheckCanInteract = false,
|
||||
Event = new ToggleGhostsActionEvent(),
|
||||
};
|
||||
}
|
||||
|
||||
public sealed class DisableLightingActionEvent : InstantActionEvent { };
|
||||
|
||||
public sealed class ToggleGhostsActionEvent : InstantActionEvent { };
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user