From 592fee31ca775e52145623049abed02ccc3f9d1c Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 16 Jan 2024 00:25:47 +0100 Subject: [PATCH] Add Round Win/Loss Events --- CS2GSI/CS2EventGenerator.cs | 6 ++++++ CS2GSI/CS2GSI.cs | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/CS2GSI/CS2EventGenerator.cs b/CS2GSI/CS2EventGenerator.cs index 3a4f6d8..359f5f9 100644 --- a/CS2GSI/CS2EventGenerator.cs +++ b/CS2GSI/CS2EventGenerator.cs @@ -32,6 +32,12 @@ internal static class CS2EventGenerator if(newGameState.Round?.Phase == Round.RoundPhase.Over && lastGameState.Round?.Phase == Round.RoundPhase.Live) events.Add(new ValueTuple(CS2Event.OnRoundOver, new CS2EventArgs())); + + if(newGameState.Round?.WinnerTeam is not null && newGameState.Round?.WinnerTeam == previousPlayerState.Player?.Team) + events.Add(new ValueTuple(CS2Event.OnRoundWin, new CS2EventArgs())); + + if(newGameState.Round?.WinnerTeam is not null && newGameState.Round?.WinnerTeam != previousPlayerState.Player?.Team) + events.Add(new ValueTuple(CS2Event.OnRoundLoss, new CS2EventArgs())); } if(newGameState.Map?.Phase == Map.MapPhase.Live && lastGameState.Map?.Phase != Map.MapPhase.Live) diff --git a/CS2GSI/CS2GSI.cs b/CS2GSI/CS2GSI.cs index b671096..60e5d99 100644 --- a/CS2GSI/CS2GSI.cs +++ b/CS2GSI/CS2GSI.cs @@ -84,6 +84,12 @@ public class CS2GSI case CS2Event.OnRoundOver: OnRoundOver?.Invoke(cs2Event.Item2); break; + case CS2Event.OnRoundWin: + OnRoundWin?.Invoke(cs2Event.Item2); + break; + case CS2Event.OnRoundLoss: + OnRoundLoss?.Invoke(cs2Event.Item2); + break; case CS2Event.OnDamageTaken: OnDamageTaken?.Invoke(cs2Event.Item2); break; @@ -150,6 +156,8 @@ public class CS2GSI OnSmoked, OnRoundStart, OnRoundOver, + OnRoundWin, + OnRoundLoss, OnDamageTaken, OnMatchStart, OnMatchOver, @@ -179,6 +187,8 @@ public class CS2GSI OnSmoked, OnRoundStart, OnRoundOver, + OnRoundWin, + OnRoundLoss, OnDamageTaken, OnMatchStart, OnMatchOver,