CS2GameState made immutable

This commit is contained in:
glax 2024-01-15 21:13:26 +01:00
parent 534ca30378
commit 8d865d49fd

View File

@ -14,4 +14,31 @@ public struct CS2GameState
$"\t{Map}\n" +
$"\t{Player}\n";
}
internal CS2GameState? UpdateGameStateForLocal(CS2GameState? previousLocalState)
{
if (previousLocalState is null)
return this.Player?.SteamId == ProviderSteamId ? this : null;
if (this.Player?.SteamId != ProviderSteamId)
return this.WithPlayer(previousLocalState.Value.Player);
return this;
}
private CS2GameState WithPlayer(Player? player)
{
this.Player = player;
return this;
}
private CS2GameState WithMap(Map? map)
{
this.Map = map;
return this;
}
private CS2GameState WithTimestamp(int timestamp)
{
this.Timestamp = timestamp;
return this;
}
}