using ExitGames.Client.Photon; using HarmonyLib; using Newtonsoft.Json; using Photon.Realtime; using PhotonLogger.Core; using System; using System.Collections.Generic; using System.Reflection; [HarmonyPatch] public class OnEventPatch { [Serializable] public class SerializableEventData { public byte Code { get; set; } public Dictionary Parameters { get; set; } } static MethodInfo TargetMethod() => typeof(LoadBalancingClient).GetRuntimeMethod("OnEvent", [ typeof(EventData) ]); static void Postfix(ref EventData photonEvent, ref LoadBalancingClient __instance) { var newMsg = new Message { Time = DateTimeOffset.UtcNow.ToUnixTimeSeconds(), Type = MessageType.Event, Server = __instance.CurrentServerAddress, Data = new SerializableEventData { Code = photonEvent.Code, Parameters = OperationNormalizer.NormalizeDictionaryValues( new Dictionary(photonEvent.Parameters.paramDict) ) } }; SocketProvider.Instance.Write(JsonConvert.SerializeObject(newMsg, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); } }