Add a Walking alert (#32954)
* Initial commit * Review feedback changes * ProtoId * TempCommit * First attempt to have client alerts * Review changes
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Linq;
|
|||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
@@ -24,8 +25,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<AlertsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
|
SubscribeLocalEvent<AlertsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
|
||||||
SubscribeLocalEvent<AlertsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
|
SubscribeLocalEvent<AlertsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
|
||||||
|
SubscribeLocalEvent<AlertsComponent, ComponentHandleState>(OnHandleState);
|
||||||
SubscribeLocalEvent<AlertsComponent, AfterAutoHandleStateEvent>(ClientAlertsHandleState);
|
|
||||||
}
|
}
|
||||||
protected override void LoadPrototypes()
|
protected override void LoadPrototypes()
|
||||||
{
|
{
|
||||||
@@ -47,6 +47,16 @@ public sealed class ClientAlertsSystem : AlertsSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnHandleState(Entity<AlertsComponent> alerts, ref ComponentHandleState args)
|
||||||
|
{
|
||||||
|
if (args.Current is not AlertComponentState cast)
|
||||||
|
return;
|
||||||
|
|
||||||
|
alerts.Comp.Alerts = cast.Alerts;
|
||||||
|
|
||||||
|
UpdateHud(alerts);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void AfterShowAlert(Entity<AlertsComponent> alerts)
|
protected override void AfterShowAlert(Entity<AlertsComponent> alerts)
|
||||||
{
|
{
|
||||||
UpdateHud(alerts);
|
UpdateHud(alerts);
|
||||||
@@ -57,11 +67,6 @@ public sealed class ClientAlertsSystem : AlertsSystem
|
|||||||
UpdateHud(alerts);
|
UpdateHud(alerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClientAlertsHandleState(Entity<AlertsComponent> alerts, ref AfterAutoHandleStateEvent args)
|
|
||||||
{
|
|
||||||
UpdateHud(alerts);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateHud(Entity<AlertsComponent> entity)
|
private void UpdateHud(Entity<AlertsComponent> entity)
|
||||||
{
|
{
|
||||||
if (_playerManager.LocalEntity == entity.Owner)
|
if (_playerManager.LocalEntity == entity.Owner)
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
using Content.Shared.Alert;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Movement.Components;
|
using Content.Shared.Movement.Components;
|
||||||
using Content.Shared.Movement.Pulling.Components;
|
using Content.Shared.Movement.Pulling.Components;
|
||||||
using Content.Shared.Movement.Systems;
|
using Content.Shared.Movement.Systems;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Physics;
|
using Robust.Client.Physics;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Physics.Components;
|
using Robust.Shared.Physics.Components;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
@@ -14,6 +17,8 @@ public sealed class MoverController : SharedMoverController
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
|
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -135,4 +140,15 @@ public sealed class MoverController : SharedMoverController
|
|||||||
{
|
{
|
||||||
return _timing is { IsFirstTimePredicted: true, InSimulation: true };
|
return _timing is { IsFirstTimePredicted: true, InSimulation: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetSprinting(Entity<InputMoverComponent> entity, ushort subTick, bool walking)
|
||||||
|
{
|
||||||
|
// Logger.Info($"[{_gameTiming.CurTick}/{subTick}] Sprint: {enabled}");
|
||||||
|
base.SetSprinting(entity, subTick, walking);
|
||||||
|
|
||||||
|
if (walking && _cfg.GetCVar(CCVars.ToggleWalk))
|
||||||
|
_alerts.ShowAlert(entity, WalkingAlert, showCooldown: false, autoRemove: false);
|
||||||
|
else
|
||||||
|
_alerts.ClearAlert(entity, WalkingAlert);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Server.Alert;
|
namespace Content.Server.Alert;
|
||||||
|
|
||||||
internal sealed class ServerAlertsSystem : AlertsSystem
|
internal sealed class ServerAlertsSystem : AlertsSystem
|
||||||
{
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<AlertsComponent, ComponentGetState>(OnGetState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGetState(Entity<AlertsComponent> alerts, ref ComponentGetState args)
|
||||||
|
{
|
||||||
|
args.State = new AlertComponentState(alerts.Comp.Alerts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Alert;
|
namespace Content.Shared.Alert;
|
||||||
|
|
||||||
@@ -6,12 +7,23 @@ namespace Content.Shared.Alert;
|
|||||||
/// Handles the icons on the right side of the screen.
|
/// Handles the icons on the right side of the screen.
|
||||||
/// Should only be used for player-controlled entities.
|
/// Should only be used for player-controlled entities.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
// Component is not AutoNetworked due to supporting clientside-only alerts.
|
||||||
|
// Component state is handled manually to avoid the server overwriting the client list.
|
||||||
|
[RegisterComponent, NetworkedComponent]
|
||||||
public sealed partial class AlertsComponent : Component
|
public sealed partial class AlertsComponent : Component
|
||||||
{
|
{
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
[AutoNetworkedField]
|
|
||||||
public Dictionary<AlertKey, AlertState> Alerts = new();
|
public Dictionary<AlertKey, AlertState> Alerts = new();
|
||||||
|
|
||||||
public override bool SendOnlyToOwner => true;
|
public override bool SendOnlyToOwner => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class AlertComponentState : ComponentState
|
||||||
|
{
|
||||||
|
public Dictionary<AlertKey, AlertState> Alerts { get; }
|
||||||
|
public AlertComponentState(Dictionary<AlertKey, AlertState> alerts)
|
||||||
|
{
|
||||||
|
Alerts = alerts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Follower.Components;
|
using Content.Shared.Follower.Components;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
@@ -8,6 +9,7 @@ using Robust.Shared.GameStates;
|
|||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -21,6 +23,8 @@ namespace Content.Shared.Movement.Systems
|
|||||||
{
|
{
|
||||||
public bool CameraRotationLocked { get; set; }
|
public bool CameraRotationLocked { get; set; }
|
||||||
|
|
||||||
|
public static ProtoId<AlertPrototype> WalkingAlert = "Walking";
|
||||||
|
|
||||||
private void InitializeInput()
|
private void InitializeInput()
|
||||||
{
|
{
|
||||||
var moveUpCmdHandler = new MoverDirInputCmdHandler(this, Direction.North);
|
var moveUpCmdHandler = new MoverDirInputCmdHandler(this, Direction.North);
|
||||||
@@ -460,7 +464,7 @@ namespace Content.Shared.Movement.Systems
|
|||||||
component.LastInputSubTick = 0;
|
component.LastInputSubTick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSprinting(Entity<InputMoverComponent> entity, ushort subTick, bool walking)
|
public virtual void SetSprinting(Entity<InputMoverComponent> entity, ushort subTick, bool walking)
|
||||||
{
|
{
|
||||||
// Logger.Info($"[{_gameTiming.CurTick}/{subTick}] Sprint: {enabled}");
|
// Logger.Info($"[{_gameTiming.CurTick}/{subTick}] Sprint: {enabled}");
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ alerts-weightless-desc =
|
|||||||
Gravity has ceased affecting you, and you're floating around aimlessly. Find something sturdy to hold onto, or throw or shoot something in a direction opposite of you.
|
Gravity has ceased affecting you, and you're floating around aimlessly. Find something sturdy to hold onto, or throw or shoot something in a direction opposite of you.
|
||||||
Mag-boots or jetpacks would help you move with more control.
|
Mag-boots or jetpacks would help you move with more control.
|
||||||
|
|
||||||
|
alerts-walking-name = Walking
|
||||||
|
alerts-walking-desc = You are walking, moving at a slow pace.
|
||||||
|
|
||||||
alerts-stunned-name = [color=yellow]Stunned[/color]
|
alerts-stunned-name = [color=yellow]Stunned[/color]
|
||||||
alerts-stunned-desc = You're [color=yellow]stunned[/color]! Something is impairing your ability to move or interact with objects.
|
alerts-stunned-desc = You're [color=yellow]stunned[/color]! Something is impairing your ability to move or interact with objects.
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
- alertType: Ensnared
|
- alertType: Ensnared
|
||||||
- category: Buckled
|
- category: Buckled
|
||||||
- alertType: Pulling
|
- alertType: Pulling
|
||||||
|
- alertType: Walking
|
||||||
- category: Piloting
|
- category: Piloting
|
||||||
- alertType: Corporeal
|
- alertType: Corporeal
|
||||||
- alertType: Stun
|
- alertType: Stun
|
||||||
@@ -126,6 +127,14 @@
|
|||||||
name: alerts-weightless-name
|
name: alerts-weightless-name
|
||||||
description: alerts-weightless-desc
|
description: alerts-weightless-desc
|
||||||
|
|
||||||
|
- type: alert
|
||||||
|
id: Walking
|
||||||
|
icons:
|
||||||
|
- sprite: /Textures/Interface/Alerts/walking.rsi
|
||||||
|
state: walking
|
||||||
|
name: alerts-walking-name
|
||||||
|
description: alerts-walking-desc
|
||||||
|
|
||||||
- type: alert
|
- type: alert
|
||||||
id: Stun
|
id: Stun
|
||||||
icons:
|
icons:
|
||||||
|
|||||||
14
Resources/Textures/Interface/Alerts/walking.rsi/meta.json
Normal file
14
Resources/Textures/Interface/Alerts/walking.rsi/meta.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC-BY-SA-3.0",
|
||||||
|
"copyright": "Created by SlamBamActionman",
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "walking"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
Resources/Textures/Interface/Alerts/walking.rsi/walking.png
Normal file
BIN
Resources/Textures/Interface/Alerts/walking.rsi/walking.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Reference in New Issue
Block a user