//TODO: Checking for ussed MessageTypes ids. Possible? private static bool ProcessIncomingMessage_Prefix(Multiplayer __instance, ref IncomingMessage msg) { #if DEBUG if (msg.MessageType != 0) { ModEntry.ModLogger.Log($"MessageType: {msg.MessageType}"); } #endif // Incomming vanilla message MessageType //switch(msg.MessageType) { // // "playerIntroduction" never reaches to the 'Multiplayer' class // //case 2: // // __instance.PlayerConnected(msg); // // break; // //case 10: // // __instance.ReceivedChatMessage(msg); // // break; // // "disconnecting" never reaches to the 'Multiplayer' class when forced to disconnect // //case 19: // // __instance.PlayerDisconnected(msg); // // break; //} if (msg.MessageType == Message.TypeID && msg.Data.Length > 0) { String keyword = Message.Action.None.ToString(); try { //Check that this isnt other mods message by trying to read a 'key' keyword = msg.Reader.ReadString(); } catch (EndOfStreamException) { // Do nothing. If it does not contain the key, it may be anothers mod custom message or something went wrong } if (Enum.TryParse(keyword, out Message.Action action)) { if (Enum.IsDefined(typeof(Message.Action), action)) { switch (action) { case Message.Action.RequestEmojiTexture: __instance.ReceiveEmojiTextureRequest(msg); return(false); case Message.Action.SendEmojiTexture: __instance.ReceiveEmojiTexture(msg); return(false); case Message.Action.BroadcastEmojiTexture: __instance.ReceiveEmojiTextureBroadcast(msg); return(false); case Message.Action.SendEmojisTextureDataList: __instance.ReceiveEmojisTextureDataList(msg); return(false); } } } } // Allow to execute the vanilla method return(true); }