using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Il2Cpp; using MelonLoader; using Microsoft.CodeAnalysis; using MultiSide; using MultiSide.shared; using Photon.Client; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(ModController), "Multiside", "1.0.2", "gameknight963", null)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Multiside")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6347de5dc2cc3a2238ced384127693269050d1ee")] [assembly: AssemblyProduct("Multiside")] [assembly: AssemblyTitle("Multiside")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MultiSide { public static class Config { public static readonly string DefaultRoom = "KoolRoom"; public static readonly AppSettings settings = new AppSettings { AppIdRealtime = "301df3f0-b282-4a33-b588-60e22cdf7d87", AppVersion = "1.0.2", FixedRegion = "us", Protocol = (ConnectionProtocol)0, NetworkLogging = (LogLevel)3 }; } public static class HelperFunctions { public static GameObject CreateKiri() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ModController.CoolLogger.Msg("adding new player"); Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "Version 1.9 POST") { throw new InvalidOperationException("Problem detected, dont call it in this scene"); } GameObject val = GameObject.Find("Kiri"); GameObject val2 = Object.Instantiate(val); GameObject gameObject = ((Component)val2.transform.Find("Zero/PLAYER Armature/Rig Root/Hips/Spine/Chest/Neck2/Neck1/Head/CameraHoldHead/playerCamera")).gameObject; try { ((Behaviour)gameObject.GetComponent()).enabled = false; kiriMoveBasic component = val2.GetComponent(); if (component != null) { ((Behaviour)component).enabled = false; } MonoBehaviour val3 = ((IEnumerable)val2.GetComponents()).FirstOrDefault((Func)((MonoBehaviour mb) => ((object)mb).GetType().Name == "BhopMovement")); if (val3 != null) { ((Behaviour)val3).enabled = false; } kiriLook component2 = ((Component)val2.transform.Find("PsuedoHead")).gameObject.GetComponent(); if (component2 != null) { ((Behaviour)component2).enabled = false; } Rigidbody component3 = val2.GetComponent(); if (component3 != null) { component3.isKinematic = true; } } catch (NullReferenceException) { ModController.CoolLogger.Error("Null exception while creating new player. One of the components disabled may not exist"); } return val2; } public static string[] GetModList() { return MelonTypeBase.RegisteredMelons.Select((MelonMod m) => ((MelonBase)m).Info.Name).ToArray(); } } public class ModController : MelonMod { private const float _updateInterval = 0.1f; private float _sendTimer = 0.1f; public static GameObject? Kiri { get; private set; } public static Instance CoolLogger { get; private set; } public override void OnInitializeMelon() { CoolLogger = ((MelonBase)this).LoggerInstance; PhotonManager.Instance.Init(); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (!(sceneName != "Version 1.9 POST")) { Kiri = GameObject.Find("Kiri"); PhotonManager.Instance.client.OpJoinRandomRoom((JoinRandomRoomArgs)null); } } public override void OnUpdate() { PhotonManager.Instance.Service(); PhotonManager.Instance.UpdatePlayerTransforms(); } public override void OnFixedUpdate() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (PhotonManager.Instance.client == null) { ((MelonBase)this).LoggerInstance.Msg("client null"); } if (PhotonManager.Instance.client?.LocalPlayer == null) { ((MelonBase)this).LoggerInstance.Msg("LocalPlayer null"); } if (PhotonManager.Instance.client != null && PhotonManager.Instance.client.LocalPlayer != null && !((Object)(object)Kiri == (Object)null)) { _sendTimer += Time.fixedUnscaledDeltaTime; if (_sendTimer > 0.1f) { _sendTimer = 0f; PlayerPositionData data = new PlayerPositionData(PhotonManager.Instance.client.LocalPlayer.ActorNumber, Kiri.transform.position, Kiri.transform.rotation); PhotonManager.Instance.SendPlayerData(data); } } } } public static class ModListChecker { public static readonly string Channel = "multiside.modlist"; public static void Init() { if (NetworkRegistry.Provider != null) { NetworkRegistry.Provider.OnReceived += OnReceived; NetworkRegistry.Provider.OnPlayerJoined += OnPlayerJoined; } } private static void OnPlayerJoined(int actor) { INetworkProvider provider = NetworkRegistry.Provider; if (provider != null) { provider.SendTo(actor, Channel, (object)HelperFunctions.GetModList(), true); } } private static void OnReceived(int actor, string channel, object data) { if (channel != Channel) { return; } string[] array = (string[])data; string[] modList = HelperFunctions.GetModList(); string[] array2 = modList.Except(array).ToArray(); string[] array3 = array.Except(modList).ToArray(); if (array2.Any() || array3.Any()) { ModController.CoolLogger.Warning($"Mod mismatch with player {actor}!"); if (array3.Any()) { ModController.CoolLogger.Warning(" You are missing: " + string.Join(", ", array3)); } if (array2.Any()) { ModController.CoolLogger.Warning(" They are missing: " + string.Join(", ", array2)); } } } } public class PhotonCallbacks : IConnectionCallbacks, IMatchmakingCallbacks, IOnEventCallback, IInRoomCallbacks { public void OnConnected() { ModController.CoolLogger.Msg("Connected to Photon server"); } public void OnConnectedToMaster() { ModController.CoolLogger.Msg("Connected to master server"); } public void OnDisconnected(DisconnectCause cause) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) ModController.CoolLogger.Msg($"Disconnected from server: {cause}"); } public void OnJoinedRoom() { foreach (KeyValuePair player in PhotonManager.Instance.client.CurrentRoom.Players) { Player value = player.Value; if (value.ActorNumber != PhotonManager.Instance.client.LocalPlayer.ActorNumber) { ModController.CoolLogger.Msg($"Spawning existing player {value.NickName} ({value.ActorNumber})"); GameObject value2 = HelperFunctions.CreateKiri(); PhotonManager.Instance.playerObjects[value.ActorNumber] = value2; } } ModListChecker.Init(); INetworkProvider provider = NetworkRegistry.Provider; if (provider != null) { provider.Send(ModListChecker.Channel, (object)HelperFunctions.GetModList(), true); } ModController.CoolLogger.Msg("Joined room successfully"); PhotonManager.Instance.FireRoomJoined(); } public void OnJoinRandomFailed(short returnCode, string message) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown ModController.CoolLogger.Msg($"Join random room failed: {returnCode} - {message}"); ModController.CoolLogger.Msg("No valid room found, creating default room"); RoomOptions roomOptions = new RoomOptions { MaxPlayers = 20, IsVisible = true }; EnterRoomArgs val = new EnterRoomArgs { RoomName = Config.DefaultRoom, RoomOptions = roomOptions }; PhotonManager.Instance.client.OpCreateRoom(val); } public void OnEvent(EventData photonEvent) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown object customData = photonEvent.CustomData; switch (photonEvent.Code) { case 0: { PhotonHashtable val2 = (PhotonHashtable)customData; int id = (int)val2[(object)"actor"]; float[] array = (float[])val2[(object)"pos"]; float[] array2 = (float[])val2[(object)"rot"]; Vector3 pos = default(Vector3); ((Vector3)(ref pos))..ctor(array[0], array[1], array[2]); Quaternion rot = default(Quaternion); ((Quaternion)(ref rot))..ctor(array2[0], array2[1], array2[2], array2[3]); PlayerPositionData posData = new PlayerPositionData(id, pos, rot); PhotonManager.Instance.UpdatePlayer(posData); break; } case 99: { PhotonHashtable val = (PhotonHashtable)customData; string channel = (string)val[(object)"channel"]; object data = val[(object)"data"]; PhotonManager.Instance.RouteReceived(photonEvent.Sender, channel, data); break; } default: ModController.CoolLogger.Msg($"Unknown event code: {photonEvent.Code}"); break; } } public void OnPlayerEnteredRoom(Player newPlayer) { ModController.CoolLogger.Msg($"Player entered room: {newPlayer.NickName} ({newPlayer.ActorNumber})"); GameObject value = HelperFunctions.CreateKiri(); PhotonManager.Instance.playerObjects[newPlayer.ActorNumber] = value; PhotonManager.Instance.FirePlayerJoined(newPlayer.ActorNumber); } public void OnPlayerLeftRoom(Player otherPlayer) { ModController.CoolLogger.Msg($"Player left room: {otherPlayer.NickName} ({otherPlayer.ActorNumber})"); if (PhotonManager.Instance.playerObjects.TryGetValue(otherPlayer.ActorNumber, out GameObject value)) { Object.Destroy((Object)(object)value); PhotonManager.Instance.playerObjects.Remove(otherPlayer.ActorNumber); PhotonManager.Instance.FirePlayerLeft(otherPlayer.ActorNumber); } } public void OnMasterClientSwitched(Player newMasterClient) { ModController.CoolLogger.Msg($"Master client switched: {newMasterClient.NickName} ({newMasterClient.ActorNumber})"); } public void OnCreatedRoom() { } public void OnCreateRoomFailed(short returnCode, string message) { } public void OnJoinRoomFailed(short returnCode, string message) { } public void OnLeftRoom() { } public void OnFriendListUpdate(List friendList) { } public void OnPlayerPropertiesUpdate(Player targetPlayer, PhotonHashtable changedProps) { } public void OnRoomPropertiesUpdate(PhotonHashtable propertiesThatChanged) { } public void OnCustomAuthenticationFailed(string debugMessage) { } public void OnCustomAuthenticationResponse(Dictionary data) { } public void OnRegionListReceived(RegionHandler regionHandler) { } } public class PhotonManager : INetworkProvider { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static SerializeStreamMethod <>9__27_0; public static DeserializeStreamMethod <>9__27_1; internal short b__27_0(StreamBuffer outStream, object obj) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (Vector3)obj; byte[] array = new byte[12]; Buffer.BlockCopy(BitConverter.GetBytes(val.x), 0, array, 0, 4); Buffer.BlockCopy(BitConverter.GetBytes(val.y), 0, array, 4, 4); Buffer.BlockCopy(BitConverter.GetBytes(val.z), 0, array, 8, 4); outStream.Write(array, 0, 12); return 12; } internal object b__27_1(StreamBuffer inStream, short length) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) byte[] array = new byte[12]; inStream.Read(array, 0, 12); return (object)new Vector3(BitConverter.ToSingle(array, 0), BitConverter.ToSingle(array, 4), BitConverter.ToSingle(array, 8)); } } public RealtimeClient client = new RealtimeClient(Config.settings.Protocol); public PhotonCallbacks callbacks = new PhotonCallbacks(); public Dictionary playerObjects = new Dictionary(); public Dictionary _targetPositions = new Dictionary(); public Dictionary _targetRotations = new Dictionary(); public static PhotonManager Instance { get; private set; } = new PhotonManager(); public bool IsConnected { get { RealtimeClient obj = client; return obj != null && obj.IsConnected; } } public IReadOnlyList ConnectedActors => playerObjects.Keys.ToList(); public bool IsMasterClient => client.LocalPlayer.IsMasterClient; public int MasterClientActorNumber => client.CurrentRoom.MasterClientId; public IReadOnlyDictionary PlayerObjects => playerObjects; public int LocalActorNumber => client.LocalPlayer.ActorNumber; public GameObject? LocalPlayerObject => ModController.Kiri; public bool IsInRoom { get { RealtimeClient obj = client; return obj != null && obj.InRoom; } } public event Action? OnReceived; public event Action? OnPlayerJoined; public event Action? OnPlayerLeft; public event Action? OnRoomJoined; public void FireRoomJoined() { this.OnRoomJoined?.Invoke(); } public void Init() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown ModController.CoolLogger.Msg("Initializing!"); client.ConnectUsingSettings(Config.settings); client.AddCallbackTarget((object)callbacks); Type typeFromHandle = typeof(Vector3); object obj2 = <>c.<>9__27_0; if (obj2 == null) { SerializeStreamMethod val = delegate(StreamBuffer outStream, object obj) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Vector3 val3 = (Vector3)obj; byte[] array2 = new byte[12]; Buffer.BlockCopy(BitConverter.GetBytes(val3.x), 0, array2, 0, 4); Buffer.BlockCopy(BitConverter.GetBytes(val3.y), 0, array2, 4, 4); Buffer.BlockCopy(BitConverter.GetBytes(val3.z), 0, array2, 8, 4); outStream.Write(array2, 0, 12); return 12; }; <>c.<>9__27_0 = val; obj2 = (object)val; } object obj3 = <>c.<>9__27_1; if (obj3 == null) { DeserializeStreamMethod val2 = delegate(StreamBuffer inStream, short length) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) byte[] array = new byte[12]; inStream.Read(array, 0, 12); return (object)new Vector3(BitConverter.ToSingle(array, 0), BitConverter.ToSingle(array, 4), BitConverter.ToSingle(array, 8)); }; <>c.<>9__27_1 = val2; obj3 = (object)val2; } PhotonPeer.RegisterType(typeFromHandle, (byte)86, (SerializeStreamMethod)obj2, (DeserializeStreamMethod)obj3); NetworkRegistry.Register((INetworkProvider)(object)this); } public GameObject? GetPlayerObject(int actor) { GameObject value; return playerObjects.TryGetValue(actor, out value) ? value : null; } public void SendPlayerData(PlayerPositionData data) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00a8: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) float[] value = new float[3] { data.position.x, data.position.y, data.position.z }; float[] value2 = new float[4] { data.rotation.x, data.rotation.y, data.rotation.z, data.rotation.w }; PhotonHashtable val = new PhotonHashtable(); ((Dictionary)val).Add((object)"actor", (object)data.actorNumber); ((Dictionary)val).Add((object)"pos", (object)value); ((Dictionary)val).Add((object)"rot", (object)value2); PhotonHashtable val2 = val; RealtimeClient obj = client; RaiseEventArgs val3 = new RaiseEventArgs { Receivers = (ReceiverGroup)0 }; SendOptions val4 = default(SendOptions); ((SendOptions)(ref val4)).Reliability = false; obj.OpRaiseEvent((byte)0, (object)val2, val3, val4); } public void Send(string channel, object data, bool reliable = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0021: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) PhotonHashtable val = new PhotonHashtable(); ((Dictionary)val).Add((object)"channel", (object)channel); ((Dictionary)val).Add((object)"data", data); PhotonHashtable val2 = val; RealtimeClient obj = client; RaiseEventArgs val3 = new RaiseEventArgs { Receivers = (ReceiverGroup)0 }; SendOptions val4 = default(SendOptions); ((SendOptions)(ref val4)).Reliability = reliable; obj.OpRaiseEvent((byte)99, (object)val2, val3, val4); } public void SendTo(int actor, string channel, object data, bool reliable = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0021: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) PhotonHashtable val = new PhotonHashtable(); ((Dictionary)val).Add((object)"channel", (object)channel); ((Dictionary)val).Add((object)"data", data); PhotonHashtable val2 = val; RealtimeClient obj = client; RaiseEventArgs val3 = new RaiseEventArgs { TargetActors = new int[1] { actor } }; SendOptions val4 = default(SendOptions); ((SendOptions)(ref val4)).Reliability = reliable; obj.OpRaiseEvent((byte)99, (object)val2, val3, val4); } public void UpdatePlayer(PlayerPositionData posData) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (playerObjects.TryGetValue(posData.actorNumber, out GameObject _)) { _targetPositions[posData.actorNumber] = posData.position; _targetRotations[posData.actorNumber] = posData.rotation; } } public void UpdatePlayerTransforms() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair playerObject in playerObjects) { int key = playerObject.Key; GameObject value = playerObject.Value; if (_targetPositions.TryGetValue(key, out var value2)) { value.transform.position = Vector3.Lerp(value.transform.position, value2, Time.unscaledDeltaTime * 10f); } if (_targetRotations.TryGetValue(key, out var value3)) { value.transform.rotation = Quaternion.Lerp(value.transform.rotation, value3, Time.unscaledDeltaTime * 10f); } } } public void RouteReceived(int actor, string channel, object data) { this.OnReceived?.Invoke(actor, channel, data); } public void FirePlayerJoined(int actor) { this.OnPlayerJoined?.Invoke(actor); } public void FirePlayerLeft(int actor) { this.OnPlayerLeft?.Invoke(actor); } public void Service() { RealtimeClient obj = client; if (obj != null) { obj.Service(); } } } [Serializable] public class PlayerPositionData { public int actorNumber; public Vector3 position; public Quaternion rotation; public PlayerPositionData(int id, Vector3 pos, Quaternion rot) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) actorNumber = id; position = pos; rotation = rot; } } }