Fix alerts mispredict + log spam (#36004)

tstalker alerted me to it and noticed the classic case of shallow copies.
This commit is contained in:
metalgearsloth
2025-03-22 22:41:16 +11:00
committed by GitHub
parent c2963d47a0
commit a9a6b98f99
2 changed files with 3 additions and 2 deletions

View File

@@ -52,7 +52,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
if (args.Current is not AlertComponentState cast) if (args.Current is not AlertComponentState cast)
return; return;
alerts.Comp.Alerts = cast.Alerts; alerts.Comp.Alerts = new(cast.Alerts);
UpdateHud(alerts); UpdateHud(alerts);
} }

View File

@@ -14,6 +14,7 @@ internal sealed class ServerAlertsSystem : AlertsSystem
private void OnGetState(Entity<AlertsComponent> alerts, ref ComponentGetState args) private void OnGetState(Entity<AlertsComponent> alerts, ref ComponentGetState args)
{ {
args.State = new AlertComponentState(alerts.Comp.Alerts); // TODO: Use sourcegen when clone-state bug fixed.
args.State = new AlertComponentState(new(alerts.Comp.Alerts));
} }
} }