2024-01-15 20:04:37 +01:00
|
|
|
|
namespace CS2GSI.GameState;
|
|
|
|
|
|
|
|
|
|
public struct CS2GameState
|
|
|
|
|
{
|
2024-01-15 20:49:09 +01:00
|
|
|
|
public string ProviderSteamId;
|
2024-01-15 20:04:37 +01:00
|
|
|
|
public int Timestamp;
|
|
|
|
|
public Map? Map;
|
|
|
|
|
public Player? Player;
|
2024-01-15 20:39:38 +01:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{GetType()}\n" +
|
2024-01-15 20:49:09 +01:00
|
|
|
|
$"\tTime: {Timestamp}\tSteamId: {ProviderSteamId}\n" +
|
2024-01-15 20:39:38 +01:00
|
|
|
|
$"\t{Map}\n" +
|
|
|
|
|
$"\t{Player}\n";
|
|
|
|
|
}
|
2024-01-15 21:13:26 +01:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2024-01-15 20:04:37 +01:00
|
|
|
|
}
|