diff --git a/CS2GSI.sln.DotSettings b/CS2GSI.sln.DotSettings
new file mode 100644
index 0000000..8925a21
--- /dev/null
+++ b/CS2GSI.sln.DotSettings
@@ -0,0 +1,2 @@
+
+ CS
\ No newline at end of file
diff --git a/CS2GSI/CS2GSI.cs b/CS2GSI/CS2GSI.cs
index 47bb689..0b7dfa9 100644
--- a/CS2GSI/CS2GSI.cs
+++ b/CS2GSI/CS2GSI.cs
@@ -38,12 +38,12 @@ public class CS2GSI
if (_lastLocalGameState is not null && _allGameStates.Count > 0)
{
- List> generatedEvents = CS2EventGenerator.GenerateEvents(_lastLocalGameState.Value, newState, _allGameStates.Last());
+ List> generatedEvents = CS2EventGenerator.GenerateEvents(_lastLocalGameState, newState, _allGameStates.Last());
this._logger?.Log(LogLevel.Information, $"Generated {generatedEvents.Count} events:\n\t{string.Join("\n\t", generatedEvents)}");
InvokeEvents(generatedEvents);
}
this._lastLocalGameState = newState.UpdateGameStateForLocal(_lastLocalGameState);
- this._logger?.Log(LogLevel.Debug, $"Updated Local State:\n{_lastLocalGameState.ToString()}");
+ this._logger?.Log(LogLevel.Debug, $"\nUpdated Local State:\n{_lastLocalGameState}");
_allGameStates.Add(newState);
}
diff --git a/CS2GSI/GameState/CS2GameState.cs b/CS2GSI/GameState/CS2GameState.cs
index 2ff4b19..b321811 100644
--- a/CS2GSI/GameState/CS2GameState.cs
+++ b/CS2GSI/GameState/CS2GameState.cs
@@ -2,7 +2,7 @@
namespace CS2GSI.GameState;
-public struct CS2GameState
+public record CS2GameState : GameState
{
public string ProviderSteamId;
public int Timestamp;
@@ -12,11 +12,7 @@ public struct CS2GameState
public override string ToString()
{
- return $"{GetType().Name}\n" +
- $"..Time: {Timestamp}\tProviderSteamId: {ProviderSteamId}\n" +
- $"..{Map.ToString()?.Replace("\n", "\n...")}\n" +
- $"..{Round.ToString()?.Replace("\n", "\n...")}\n" +
- $"..{Player.ToString()?.Replace("\n", "\n...")}\n";
+ return base.ToString();
}
internal static CS2GameState ParseFromJObject(JObject jsonObject)
@@ -25,9 +21,9 @@ public struct CS2GameState
{
ProviderSteamId = jsonObject.SelectToken("provider.steamid")!.Value()!,
Timestamp = jsonObject.SelectToken("provider.timestamp")!.Value(),
- Map = GameState.Map.ParseFromJObject(jsonObject),
- Player = GameState.Player.ParseFromJObject(jsonObject),
- Round = GameState.Round.ParseFromJObject(jsonObject)
+ Map = Map.ParseFromJObject(jsonObject),
+ Player = Player.ParseFromJObject(jsonObject),
+ Round = Round.ParseFromJObject(jsonObject)
};
}
@@ -36,7 +32,7 @@ public struct CS2GameState
if (previousLocalState is null)
return this.Player?.SteamId == ProviderSteamId ? this : null;
if (this.Player?.SteamId != ProviderSteamId)
- return this.WithPlayer(previousLocalState.Value.Player);
+ return this.WithPlayer(previousLocalState.Player);
return this;
}
diff --git a/CS2GSI/GameState/GameState.cs b/CS2GSI/GameState/GameState.cs
new file mode 100644
index 0000000..3bf7b25
--- /dev/null
+++ b/CS2GSI/GameState/GameState.cs
@@ -0,0 +1,21 @@
+using System.Reflection;
+
+namespace CS2GSI.GameState;
+
+public abstract record GameState
+{
+ public override string ToString()
+ {
+ string ret = "";
+ foreach (FieldInfo field in GetType().GetFields())
+ {
+ string filler = GetType().GetFields().Last() != field ? "\u251c\u2500" : "\u2514\u2500";
+ string filler2 = GetType().GetFields().Last() != field ? "\u2502" : " ";
+ if (field.FieldType.BaseType == typeof(GameState))
+ ret += $"\b{filler}\u2510{field.Name}\n{field.GetValue(this)?.ToString()?.Replace("\b", $"\b{filler2} ")}";
+ else
+ ret += $"\b{filler} {field.Name}{new string('.', field.Name.Length > 25 ? 0 : 25-field.Name.Length)}{field.GetValue(this)}\n";
+ }
+ return ret;
+ }
+}
\ No newline at end of file
diff --git a/CS2GSI/GameState/GameStateTeam.cs b/CS2GSI/GameState/GameStateTeam.cs
index 01b810c..aeda6c9 100644
--- a/CS2GSI/GameState/GameStateTeam.cs
+++ b/CS2GSI/GameState/GameStateTeam.cs
@@ -2,18 +2,14 @@
namespace CS2GSI.GameState;
-public struct GameStateTeam
+public record GameStateTeam : GameState
{
public CS2Team Team;
public int Score, ConsecutiveRoundLosses, TimeoutsRemaining, MatchesWonThisSeries;
public override string ToString()
{
- return $"{GetType().Name}\n" +
- $"..Team {Team}\tScore: {Score}\n" +
- $"..ConsecutiveRoundLosses: {ConsecutiveRoundLosses}\n" +
- $"..TimeoutsRemaining: {TimeoutsRemaining}\n" +
- $"..MatchesWonThisSeries: {MatchesWonThisSeries}\n";
+ return base.ToString();
}
internal static GameStateTeam ParseFromJObject(JObject jsonObject, CS2Team team)
diff --git a/CS2GSI/GameState/Map.cs b/CS2GSI/GameState/Map.cs
index 132a962..c84b768 100644
--- a/CS2GSI/GameState/Map.cs
+++ b/CS2GSI/GameState/Map.cs
@@ -2,7 +2,7 @@
namespace CS2GSI.GameState;
-public struct Map
+public record Map : GameState
{
public string Mode, MapName;
public MapPhase Phase;
@@ -11,13 +11,7 @@ public struct Map
public override string ToString()
{
- return $"{GetType().Name}\n" +
- $"..Mode: {Mode} Map: {MapName}\n" +
- $"..Round: {Round}\n" +
- $"..Matches to Win Series: {NumMatchesToWinSeries}\n" +
- $"..Phase: {Phase}\n" +
- $"..{GameStateTeamCT.ToString().Replace("\n", "\n...")}\n" +
- $"..{GameStateTeamT.ToString().Replace("\n", "\n...")}\n";
+ return base.ToString();
}
internal static Map? ParseFromJObject(JObject jsonObject)
diff --git a/CS2GSI/GameState/Player.cs b/CS2GSI/GameState/Player.cs
index 470ba3c..f606a1d 100644
--- a/CS2GSI/GameState/Player.cs
+++ b/CS2GSI/GameState/Player.cs
@@ -2,7 +2,7 @@
namespace CS2GSI.GameState;
-public struct Player
+public record Player : GameState
{
public string SteamId, Name;
public PlayerActivity Activity;
@@ -13,12 +13,7 @@ public struct Player
public override string ToString()
{
- return $"{GetType().Name}\n" +
- $"..Name: {Name} SteamId: {SteamId}\n" +
- $"..Activity: {Activity}\n" +
- $"..Team: {Team}\n" +
- $"..{State.ToString()?.Replace("\n", "\n...")}\n" +
- $"..{MatchStats.ToString()?.Replace("\n", "\n...")}\n";
+ return base.ToString();
}
internal static Player? ParseFromJObject(JObject jsonObject)
diff --git a/CS2GSI/GameState/PlayerMatchStats.cs b/CS2GSI/GameState/PlayerMatchStats.cs
index d8f5349..56a3d02 100644
--- a/CS2GSI/GameState/PlayerMatchStats.cs
+++ b/CS2GSI/GameState/PlayerMatchStats.cs
@@ -2,16 +2,13 @@
namespace CS2GSI.GameState;
-public struct PlayerMatchStats
+public record PlayerMatchStats : GameState
{
public int Kills, Assists, Deaths, MVPs, Score;
public override string ToString()
{
- return $"{GetType().Name}\n" +
- $"..KAD: {Kills} {Assists} {Deaths}\n" +
- $"..MVPs: {MVPs}\n" +
- $"..Score: {Score}\n";
+ return base.ToString();
}
internal static PlayerMatchStats? ParseFromJObject(JObject jsonObject)
diff --git a/CS2GSI/GameState/PlayerState.cs b/CS2GSI/GameState/PlayerState.cs
index e1da95b..6ed673b 100644
--- a/CS2GSI/GameState/PlayerState.cs
+++ b/CS2GSI/GameState/PlayerState.cs
@@ -2,23 +2,14 @@
namespace CS2GSI.GameState;
-public struct PlayerState
+public record PlayerState : GameState
{
public int Health, Armor, Flashed, Smoked, Burning, Money, RoundKills, RoundHs, EquipmentValue;
public bool Helmet;
public override string ToString()
{
- return $"{GetType().Name}\n" +
- $"..Health: {Health}\n" +
- $"..Armor: {Armor}\n" +
- $"..Flashed: {Flashed}\n" +
- $"..Smoked: {Smoked}\n" +
- $"..Burning: {Burning}\n" +
- $"..Money: {Money}\n" +
- $"..RoundKills: {RoundKills}\n" +
- $"..RoundHs: {RoundHs}\n" +
- $"..EquipmentValue: {EquipmentValue}\n";
+ return base.ToString();
}
internal static PlayerState? ParseFromJObject(JObject jsonObject)
diff --git a/CS2GSI/GameState/Round.cs b/CS2GSI/GameState/Round.cs
index bc525a4..5ee4841 100644
--- a/CS2GSI/GameState/Round.cs
+++ b/CS2GSI/GameState/Round.cs
@@ -2,7 +2,7 @@
namespace CS2GSI.GameState;
-public struct Round
+public record Round : GameState
{
public RoundPhase Phase;
public BombStatus? Bomb;
@@ -10,10 +10,7 @@ public struct Round
public override string ToString()
{
- return $"{GetType().Name}\n" +
- $"..Phase: {Phase}\n" +
- $"..Winner: {WinnerTeam}\n" +
- $"..Bomb: {Bomb}\n";
+ return base.ToString();
}
internal static Round? ParseFromJObject(JObject jsonObject)