Fix clientsided alerts being overwritten by server (#37033)
Initial commit
This commit is contained in:
@@ -52,8 +52,24 @@ public sealed class ClientAlertsSystem : AlertsSystem
|
|||||||
if (args.Current is not AlertComponentState cast)
|
if (args.Current is not AlertComponentState cast)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Save all client-sided alerts to later put back in
|
||||||
|
var clientAlerts = new Dictionary<AlertKey, AlertState>();
|
||||||
|
foreach (var alert in alerts.Comp.Alerts)
|
||||||
|
{
|
||||||
|
if (alert.Key.AlertType != null && TryGet(alert.Key.AlertType.Value, out var alertProto))
|
||||||
|
{
|
||||||
|
if (alertProto.ClientHandled)
|
||||||
|
clientAlerts[alert.Key] = alert.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
alerts.Comp.Alerts = new(cast.Alerts);
|
alerts.Comp.Alerts = new(cast.Alerts);
|
||||||
|
|
||||||
|
foreach (var alert in clientAlerts)
|
||||||
|
{
|
||||||
|
alerts.Comp.Alerts[alert.Key] = alert.Value;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateHud(alerts);
|
UpdateHud(alerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ public sealed partial class AlertPrototype : IPrototype
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SupportsSeverity => MaxSeverity != -1;
|
public bool SupportsSeverity => MaxSeverity != -1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If true, this alert is being handled by the client and will not be overwritten when handling server -> client states.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public bool ClientHandled = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event raised on the user when they click on this alert.
|
/// Event raised on the user when they click on this alert.
|
||||||
/// Can be null.
|
/// Can be null.
|
||||||
|
|||||||
@@ -134,6 +134,7 @@
|
|||||||
state: walking
|
state: walking
|
||||||
name: alerts-walking-name
|
name: alerts-walking-name
|
||||||
description: alerts-walking-desc
|
description: alerts-walking-desc
|
||||||
|
clientHandled: true
|
||||||
|
|
||||||
- type: alert
|
- type: alert
|
||||||
id: Stun
|
id: Stun
|
||||||
|
|||||||
Reference in New Issue
Block a user