Ghost toggle FoV action (#12818)

* Ghost toggle FoV action

* p
This commit is contained in:
Kara
2022-11-30 23:46:04 -06:00
committed by GitHub
parent 771e6721eb
commit 01e0ea7922
4 changed files with 45 additions and 12 deletions

View File

@@ -11,14 +11,26 @@ namespace Content.Client.Ghost
{
public bool IsAttached { get; set; }
public InstantAction DisableLightingAction = new()
public InstantAction ToggleLightingAction = 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",
UserPopup = "ghost-gui-toggle-lighting-manager-popup",
ClientExclusive = true,
CheckCanInteract = false,
Event = new DisableLightingActionEvent(),
Event = new ToggleLightingActionEvent(),
};
public InstantAction ToggleFoVAction = new()
{
Icon = new SpriteSpecifier.Texture(new ResourcePath("Interface/VerbIcons/vv.svg.192dpi.png")),
DisplayName = "ghost-gui-toggle-fov-name",
Description = "ghost-gui-toggle-fov-desc",
UserPopup = "ghost-gui-toggle-fov-popup",
ClientExclusive = true,
CheckCanInteract = false,
Event = new ToggleFoVActionEvent(),
};
public InstantAction ToggleGhostsAction = new()
@@ -26,13 +38,16 @@ namespace Content.Client.Ghost
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",
UserPopup = "ghost-gui-toggle-ghost-visibility-popup",
ClientExclusive = true,
CheckCanInteract = false,
Event = new ToggleGhostsActionEvent(),
};
}
public sealed class DisableLightingActionEvent : InstantActionEvent { };
public sealed class ToggleLightingActionEvent : InstantActionEvent { };
public sealed class ToggleFoVActionEvent : InstantActionEvent { };
public sealed class ToggleGhostsActionEvent : InstantActionEvent { };
}

View File

@@ -16,6 +16,7 @@ namespace Content.Client.Ghost
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ILightManager _lightManager = default!;
[Dependency] private readonly IEyeManager _eye = default!;
public int AvailableGhostRoleCount { get; private set; }
@@ -66,7 +67,8 @@ namespace Content.Client.Ghost
SubscribeNetworkEvent<GhostWarpsResponseEvent>(OnGhostWarpsResponse);
SubscribeNetworkEvent<GhostUpdateGhostRoleCountEvent>(OnUpdateGhostRoleCount);
SubscribeLocalEvent<GhostComponent, DisableLightingActionEvent>(OnActionPerform);
SubscribeLocalEvent<GhostComponent, ToggleLightingActionEvent>(OnToggleLighting);
SubscribeLocalEvent<GhostComponent, ToggleFoVActionEvent>(OnToggleFoV);
SubscribeLocalEvent<GhostComponent, ToggleGhostsActionEvent>(OnToggleGhosts);
}
@@ -77,11 +79,12 @@ namespace Content.Client.Ghost
sprite.Visible = GhostVisibility;
}
_actions.AddAction(uid, component.DisableLightingAction, null);
_actions.AddAction(uid, component.ToggleLightingAction, null);
_actions.AddAction(uid, component.ToggleFoVAction, null);
_actions.AddAction(uid, component.ToggleGhostsAction, null);
}
private void OnActionPerform(EntityUid uid, GhostComponent component, DisableLightingActionEvent args)
private void OnToggleLighting(EntityUid uid, GhostComponent component, ToggleLightingActionEvent args)
{
if (args.Handled)
return;
@@ -90,6 +93,15 @@ namespace Content.Client.Ghost
args.Handled = true;
}
private void OnToggleFoV(EntityUid uid, GhostComponent component, ToggleFoVActionEvent args)
{
if (args.Handled)
return;
_eye.CurrentEye.DrawFov = !_eye.CurrentEye.DrawFov;
args.Handled = true;
}
private void OnToggleGhosts(EntityUid uid, GhostComponent component, ToggleGhostsActionEvent args)
{
if (args.Handled)
@@ -101,7 +113,8 @@ namespace Content.Client.Ghost
private void OnGhostRemove(EntityUid uid, GhostComponent component, ComponentRemove args)
{
_actions.RemoveAction(uid, component.DisableLightingAction);
_actions.RemoveAction(uid, component.ToggleLightingAction);
_actions.RemoveAction(uid, component.ToggleFoVAction);
_actions.RemoveAction(uid, component.ToggleGhostsAction);
_lightManager.Enabled = true;

View File

@@ -308,7 +308,7 @@ namespace Content.Server.Ghost
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player == null)
shell.WriteLine("You can only open the ghost roles UI on a client.");
shell.WriteLine("You can only toggle ghost visibility on a client.");
var entityManager = IoCManager.Resolve<IEntityManager>();

View File

@@ -3,8 +3,13 @@ ghost-gui-ghost-warp-button = Ghost Warp
ghost-gui-ghost-roles-button = Ghost Roles ({$count})
ghost-gui-toggle-ghost-visibility-name = Toggle Ghosts
ghost-gui-toggle-ghost-visibility-desc = Toggle the visibility of other 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-gui-toggle-ghost-visibility-popup = Toggled visibility of ghosts.
ghost-gui-toggle-lighting-manager-name = Toggle All Lighting
ghost-gui-toggle-lighting-manager-desc = Toggle all light rendering to better observe dark areas.
ghost-gui-toggle-lighting-manager-popup = Toggled all lighting.
ghost-gui-toggle-fov-name = Toggle FoV
ghost-gui-toggle-fov-desc = Toggles field-of-view in order to see what players see.
ghost-gui-toggle-fov-popup = Toggled field-of-view.
ghost-target-window-title = Ghost Warp
ghost-target-window-current-button = Warp: {$name}