Compare commits
2 Commits
04be9d6fab
...
386c211de5
Author | SHA1 | Date | |
---|---|---|---|
386c211de5 | |||
eda66a2334 |
@ -28,4 +28,5 @@ public enum CS2Event : byte {
|
|||||||
OnBombExploded = 24,
|
OnBombExploded = 24,
|
||||||
AnyEvent = 25,
|
AnyEvent = 25,
|
||||||
AnyMessage = 26,
|
AnyMessage = 26,
|
||||||
|
OnActivityChange = 27
|
||||||
}
|
}
|
@ -16,6 +16,9 @@ internal static class CS2EventGenerator
|
|||||||
if(events.Count > 0)
|
if(events.Count > 0)
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.AnyEvent, new CS2EventArgs(events.Count)));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.AnyEvent, new CS2EventArgs(events.Count)));
|
||||||
|
|
||||||
|
if (lastGameState.Player?.Activity != newGameState.Player?.Activity)
|
||||||
|
events.Add(new(CS2Event.OnActivityChange, new CS2EventArgs(newGameState.Player?.Activity)));
|
||||||
|
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.AnyMessage, new CS2EventArgs()));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.AnyMessage, new CS2EventArgs()));
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using CS2GSI.GameState;
|
using CS2GSI.GameState;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace CS2GSI;
|
namespace CS2GSI;
|
||||||
@ -36,6 +37,13 @@ public class CS2GSI
|
|||||||
JObject jsonObject = JObject.Parse(messageJson);
|
JObject jsonObject = JObject.Parse(messageJson);
|
||||||
CS2GameState newState = CS2GameState.ParseFromJObject(jsonObject);
|
CS2GameState newState = CS2GameState.ParseFromJObject(jsonObject);
|
||||||
this._logger?.Log(LogLevel.Debug, $"{Resources.Received_State}:\n{newState.ToString()}");
|
this._logger?.Log(LogLevel.Debug, $"{Resources.Received_State}:\n{newState.ToString()}");
|
||||||
|
#if DEBUG
|
||||||
|
long time = DateTime.Now.ToFileTime();
|
||||||
|
Directory.CreateDirectory("states");
|
||||||
|
File.WriteAllText(Path.Join("states", $"{time}.json"), JsonConvert.SerializeObject(newState, Formatting.Indented, new Newtonsoft.Json.Converters.StringEnumConverter()));
|
||||||
|
Directory.CreateDirectory("messages");
|
||||||
|
File.WriteAllText(Path.Join("messages", $"{time}.json"), messageJson);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (_lastLocalGameState is not null && _allGameStates.Count > 0)
|
if (_lastLocalGameState is not null && _allGameStates.Count > 0)
|
||||||
{
|
{
|
||||||
@ -91,6 +99,7 @@ public class CS2GSI
|
|||||||
CS2Event.OnBombExploded => this.OnBombExploded,
|
CS2Event.OnBombExploded => this.OnBombExploded,
|
||||||
CS2Event.AnyEvent => this.AnyEvent,
|
CS2Event.AnyEvent => this.AnyEvent,
|
||||||
CS2Event.AnyMessage => this.AnyMessage,
|
CS2Event.AnyMessage => this.AnyMessage,
|
||||||
|
CS2Event.OnActivityChange => this.OnActivityChange,
|
||||||
_ => throw new ArgumentException(Resources.Unknown_Event, nameof(cs2Event))
|
_ => throw new ArgumentException(Resources.Unknown_Event, nameof(cs2Event))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -125,6 +134,7 @@ public class CS2GSI
|
|||||||
OnBombDefused,
|
OnBombDefused,
|
||||||
OnBombExploded,
|
OnBombExploded,
|
||||||
AnyEvent,
|
AnyEvent,
|
||||||
AnyMessage;
|
AnyMessage,
|
||||||
|
OnActivityChange;
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user