Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of Bopl8Players v0.3.4
plugins/Bopl8Players/Bopl8Players.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BoplFixedMath; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Collections; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Experimental.Rendering; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("Bopl8Players")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Eight-player online lobbies for Bopl Battle 2.5.1.")] [assembly: AssemblyFileVersion("0.3.4.0")] [assembly: AssemblyInformationalVersion("0.3.4+621dd6c2ea92cc93f863f4606c3b649043443a32")] [assembly: AssemblyProduct("Bopl8Players")] [assembly: AssemblyTitle("Bopl8Players")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [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 MorePlayers { [HarmonyPatch(typeof(CharacterSelectHandler_online))] [HarmonyPatch("ForceStartGame")] public static class CharacterSelecterHandler_online_ForceStartGamePatch { [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(CharacterSelectHandler_online), "InitPlayer")] public static Player InitPlayer(int id, byte color, byte team, byte ability1, byte ability2, byte ability3, int nrOfAbilities, PlayerColors playerColors) { throw new NotImplementedException("It's a stub"); } public static bool Prefix([CanBeNull] PlayerColors pcs) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) CharacterSelectHandler_online val = AccessTools.StaticFieldRefAccess<CharacterSelectHandler_online, CharacterSelectHandler_online>("selfRef"); if ((Object)(object)pcs == (Object)null) { pcs = val.playerColors; } MultiStartRequestPacket startParameters = SteamManagerExtended.startParameters; Updater.ReInit(); List<Player> list = new List<Player>(); Updater.InitSeed(startParameters.seed); Main.Log.LogInfo((object)$"SteamID: {SteamClient.SteamId}"); for (int i = 0; i < startParameters.nrOfPlayers; i++) { Main.Log.LogInfo((object)$"Initializing player {i}: [id: {startParameters.p_ids[i]}, color: {startParameters.p_colors[i]}, team: {startParameters.p_teams[i]}, ability1: {startParameters.p_ability1s[i]}, ability2: {startParameters.p_ability2s[i]}, ability3: {startParameters.p_ability3s[i]}]"); list.Add(InitPlayer(i + 1, startParameters.p_colors[i], startParameters.p_teams[i], startParameters.p_ability1s[i], startParameters.p_ability2s[i], startParameters.p_ability3s[i], startParameters.nrOfAbilites, pcs)); } Player val2 = null; if (GameLobby.isPlayingAReplay) { for (int j = 0; j < list.Count; j++) { if (list[j].Id == 1) { val2 = list[j]; break; } } } else { int num = Array.IndexOf(startParameters.p_ids, SteamId.op_Implicit(SteamClient.SteamId)); Main.Log.LogInfo((object)("SteamIdIndex: " + num)); if (num != -1) { val2 = list[num]; } } if (val2 == null) { Main.Log.LogError((object)"Failed to find local player on ForceStart."); return false; } for (int k = 0; k < list.Count; k++) { list[k].steamId = SteamId.op_Implicit(startParameters.p_ids[k]); } val2.IsLocalPlayer = true; val2.inputDevice = CharacterSelectHandler_online.localPlayerInit.inputDevice; val2.UsesKeyboardAndMouse = CharacterSelectHandler_online.localPlayerInit.usesKeyboardMouse; val2.CustomKeyBinding = CharacterSelectHandler_online.localPlayerInit.keybindOverride; CharacterSelectHandler_online.startButtonAvailable = false; PlayerHandler.Get().SetPlayerList(list); SteamManager.instance.StartHostedGame(); AudioManager obj = AudioManager.Get(); if (obj != null) { obj.Play("startGame"); } GameSession.Init(); if (GameLobby.isPlayingAReplay) { SceneManager.LoadScene(startParameters.currentLevel + 6); } else { SceneManager.LoadScene("Level1"); } if (!WinnerTriangleCanvas.HasBeenSpawned) { SceneManager.LoadScene("winnerTriangle", (LoadSceneMode)1); } return false; } } internal static class SteamConnectionStats { private static readonly PropertyInfo Api = AccessTools.Property(typeof(SteamNetworkingSockets), "Internal"); private static readonly Type StatusType = typeof(Connection).Assembly.GetType("Steamworks.Data.SteamNetworkingQuickConnectionStatus"); private static readonly MethodInfo Query = ((Api == null) ? null : AccessTools.Method(Api.PropertyType, "GetQuickConnectionStatus", (Type[])null, (Type[])null)); private static bool warned; internal static object Read(Connection connection) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) try { if (Query == null || StatusType == null) { return null; } object value = Api.GetValue(null, null); if (value == null) { return null; } object[] array = new object[2] { connection, Activator.CreateInstance(StatusType) }; return ((bool)Query.Invoke(value, array)) ? array[1] : null; } catch (Exception ex) { if (!warned) { Main.Log.LogWarning((object)("Steam connection telemetry unavailable: " + ex.GetType().Name)); } warned = true; return null; } } internal static T Field<T>(object status, string name) { return (T)AccessTools.Field(StatusType, name).GetValue(status); } internal static string Delivery(float quality) { if (!float.IsNaN(quality) && !float.IsInfinity(quality) && !(quality < 0f) && !(quality > 1f)) { return (quality * 100f).ToString("0.0") + "%"; } return "n/a"; } } [HarmonyPatch(typeof(MainMenu), "Start")] internal static class ConnectionDiagnosticsStartup { internal static void Postfix() { ConnectionDiagnostics.EnsureCreated(); } } internal sealed class ConnectionDiagnostics : MonoBehaviour { internal static ConfigEntry<bool> Enabled; private static ConnectionDiagnostics instance; private readonly List<string> rows = new List<string>(); private float nextSample; private float frameTime; private string header; private GUIStyle style; internal static void EnsureCreated() { //IL_0013: 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) //IL_001e: Expected O, but got Unknown if (!((Object)(object)instance != (Object)null)) { GameObject val = new GameObject("Bopl8 Connection Diagnostics"); Object.DontDestroyOnLoad((Object)val); instance = val.AddComponent<ConnectionDiagnostics>(); } } private void Update() { //IL_011f: Unknown result type (might be due to invalid IL or missing references) frameTime = Mathf.Lerp(frameTime, Time.unscaledDeltaTime, 0.05f); if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f8Key).wasPressedThisFrame) { Enabled.Value = !Enabled.Value; } if (Time.unscaledTime < nextSample) { return; } nextSample = Time.unscaledTime + 0.5f; rows.Clear(); SteamManager val = SteamManager.instance; if ((Object)(object)val == (Object)null || !GameLobby.isOnlineGame) { return; } Host networkClient = val.networkClient; bool flag = !GameSession.inMenus && (Object)(object)networkClient != (Object)null && networkClient.hasBeenInitialized; header = $"CONNECTIONS (F8 hide) Your FPS: {((frameTime > 0f) ? (1f / frameTime) : 0f):0}"; foreach (SteamConnection peer in val.connectedPlayers) { object obj = (((ConnectionManager)peer).Connected ? SteamConnectionStats.Read(((ConnectionManager)peer).Connection) : null); string text = ((obj == null) ? "n/a" : ((SteamConnectionStats.Field<int>(obj, "Ping") < 0) ? "n/a" : (SteamConnectionStats.Field<int>(obj, "Ping") + " ms"))); string text2 = ((obj == null) ? "n/a / n/a" : (SteamConnectionStats.Delivery(SteamConnectionStats.Field<float>(obj, "ConnectionQualityLocal")) + " / " + SteamConnectionStats.Delivery(SteamConnectionStats.Field<float>(obj, "ConnectionQualityRemote")))); string text3 = ""; if (flag && networkClient.clients != null) { Client val2 = networkClient.clients.Find((Client c) => c.steamConnection == peer); if (val2 != null) { float num = Mathf.Max(0f, Time.unscaledTime - val2.inputReceivedTimeStamp); bool flag2 = networkClient.allClientsSynced && HostPatch.InputBuffer.Count == 0 && val2.inputHistory.Count == 0; text3 = $" inputs {num * 1000f:0} ms ago" + (flag2 ? " [WAITING]" : ""); } } string text4 = (peer.steamName ?? "Unknown").Replace('\n', ' ').Replace('\r', ' '); if (text4.Length > 24) { text4 = text4.Substring(0, 24); } rows.Add(text4 + ": " + text + " delivery " + text2 + text3); } } private void OnGUI() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) if (Enabled != null && Enabled.Value && GameLobby.isOnlineGame && rows.Count != 0) { if (style == null) { style = new GUIStyle(GUI.skin.label) { fontSize = 14, richText = false }; } float num = Mathf.Min(780, Screen.width - 24); Rect val = default(Rect); ((Rect)(ref val))..ctor((float)Screen.width - num - 12f, 12f, num, (float)(62 + rows.Count * 23)); GUI.Box(val, GUIContent.none); GUI.Label(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 6f, num - 20f, 23f), header, style); for (int i = 0; i < rows.Count; i++) { GUI.Label(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 29f + (float)(i * 23), num - 20f, 23f), rows[i], style); } GUI.Label(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 31f + (float)(rows.Count * 23), num - 20f, 25f), "Delivery = in-order success: received here / reported by peer. Poor link ≠ proof whose internet is at fault.", style); } } } [HarmonyPatch(typeof(GameSessionHandler))] [HarmonyPatch("LoadNextLevelScene")] public class GameSessionHandlerPatch_LoadNextLevelScene { [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { Main.Log.LogInfo((object)"Patching GameSessionHandler.LoadNextLevelScene"); FieldInfo fromA = AccessTools.Field(typeof(SteamManager), "startParameters"); FieldInfo toA = AccessTools.Field(typeof(SteamManagerExtended), "startParameters"); FieldInfo fromB = AccessTools.Field(typeof(StartRequestPacket), "seed"); FieldInfo toB = AccessTools.Field(typeof(MultiStartRequestPacket), "seed"); return Main.PatchFieldLoad(fromA, fromB, toA, toB, instructions); } } [HarmonyPatch(typeof(GameSessionHandler))] [HarmonyPatch("SpawnPlayers")] public class GameSessionHandlerPatch_SpawnPlayers { private static void Prefix() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) List<Player> list = PlayerHandler.Get().PlayerList(); Main.Log.LogInfo((object)$"Spawning {list.Count} players:"); foreach (Player item in list) { Main.Log.LogInfo((object)$"Player {item.Id} ({item.steamId})"); } } } public class HostPatch { public static Queue<MultiInputPacket> InputBuffer = new Queue<MultiInputPacket>(); public static MultiInputPacket previousInputPacket; public static uint GetMaxSeqNumber(MultiInputPacket packet) { if (packet.inputPackets.Count != 0) { return packet.inputPackets.Max((KeyValuePair<int, InputPacket> p) => p.Value.seqNumber); } return 0u; } public static int GetMaxPreviousTargetDelayBufferSize() { if (previousInputPacket.inputPackets.Count != 0) { return previousInputPacket.inputPackets.Max((KeyValuePair<int, InputPacket> p) => p.Value.targetDelayBufferSize); } return 0; } } [HarmonyPatch(typeof(Host))] [HarmonyPatch("Start")] public class HostPatch_Start { public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { Main.Log.LogInfo((object)"Patching Host.Start"); FieldInfo fromA = AccessTools.Field(typeof(SteamManager), "startParameters"); FieldInfo toA = AccessTools.Field(typeof(SteamManagerExtended), "startParameters"); FieldInfo fromB = AccessTools.Field(typeof(StartRequestPacket), "nrOfAbilites"); FieldInfo toB = AccessTools.Field(typeof(MultiStartRequestPacket), "nrOfAbilites"); return Main.PatchFieldLoad(fromA, fromB, toA, toB, instructions); } } [HarmonyPatch(typeof(Host))] [HarmonyPatch("ReInit")] public class HostPatch_ReInit { public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { Main.Log.LogInfo((object)"Patching Host.ReInit"); FieldInfo fromA = AccessTools.Field(typeof(SteamManager), "startParameters"); FieldInfo toA = AccessTools.Field(typeof(SteamManagerExtended), "startParameters"); FieldInfo fromB = AccessTools.Field(typeof(StartRequestPacket), "frameBufferSize"); FieldInfo toB = AccessTools.Field(typeof(MultiStartRequestPacket), "frameBufferSize"); return Main.PatchFieldLoad(fromA, fromB, toA, toB, instructions); } } [HarmonyPatch(typeof(Host))] [HarmonyPatch("Init")] public class HostPatch_Init { public static void Prefix() { Main.Log.LogInfo((object)"Host::Init::Prefix"); HostPatch.InputBuffer.Clear(); HostPatch.previousInputPacket = new MultiInputPacket(); } } [HarmonyPatch(typeof(Host))] [HarmonyPatch("ProcessNetworkPackets")] public class HostPatch_ProcessNetworkPackets { private static void AddDefaultPacket() { Main.Log.LogInfo((object)"Adding default packet"); HostPatch.InputBuffer.Enqueue(new MultiInputPacket()); } private static void AddInputPacket(List<Client> clients, Queue<InputPacket> sentPacketHistory, int localPlayerId) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) MultiInputPacket item = new MultiInputPacket(); foreach (Client client in clients) { InputPacket value = client.inputHistory.Dequeue(); item.inputPackets.Add(client.PlayerId, value); } item.inputPackets.Add(localPlayerId, sentPacketHistory.Dequeue()); HostPatch.InputBuffer.Enqueue(item); } private static IEnumerable<CodeInstruction> DebugLogInstructions(string message) { yield return new CodeInstruction(OpCodes.Ldstr, (object)message); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HostPatch_ProcessNetworkPackets), "LogText", (Type[])null, (Type[])null)); } private static void LogText(string message) { Main.Log.LogInfo((object)message); } [HarmonyDebug] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { Main.Log.LogInfo((object)"Patching Host.ProcessNetworkPackets"); FieldInfo delayBufferSizeFieldInfo = AccessTools.Field(typeof(Host), "delayBufferSize"); FieldInfo updatesPlacedInDelayBufferFieldInfo = AccessTools.Field(typeof(Host), "UpdatesPlacedInDelayBuffer"); IEnumerator<CodeInstruction> enumerator = instructions.GetEnumerator(); Label? last_br = null; Label? label = default(Label?); while (enumerator.MoveNext()) { CodeInstruction current = enumerator.Current; if (CodeInstructionExtensions.Branches(current, ref label)) { last_br = label; } if (current.opcode == OpCodes.Ldloca_S) { CodeInstruction val = current; List<Label> list = CodeInstructionExtensions.ExtractLabels(val); List<CodeInstruction> instructionsSkipped = new List<CodeInstruction> { val }; if (list.Count == 0) { yield return val; continue; } if (!enumerator.MoveNext()) { Main.Log.LogError((object)"Expected to find next instruction after Ldloca_S"); yield return val; yield break; } CodeInstruction current2 = enumerator.Current; instructionsSkipped.Add(current2); if (CodeInstructionExtensions.Is(current2, OpCodes.Initobj, (MemberInfo)typeof(InputPacketQuad))) { Main.Log.LogInfo((object)"Found possible start of loop. Searching for end..."); bool flag = false; while (enumerator.MoveNext()) { CodeInstruction current3 = enumerator.Current; instructionsSkipped.Add(current3); if (current3.opcode == OpCodes.Blt && list.Contains((Label)current3.operand)) { Main.Log.LogInfo((object)"Found End of loop"); flag = true; break; } } if (flag) { if (!last_br.HasValue) { Main.Log.LogError((object)"What this shouldn't be null?!"); } if (instructionsSkipped.Any((CodeInstruction val2) => CodeInstructionExtensions.LoadsField(val2, delayBufferSizeFieldInfo, false))) { Main.Log.LogInfo((object)"Found 'fill InputBuffer with default InputPacket' loop"); Label label2 = generator.DefineLabel(); yield return CodeInstructionExtensions.WithLabels(CodeInstruction.Call(typeof(HostPatch_ProcessNetworkPackets), "AddDefaultPacket", (Type[])null, (Type[])null), new Label[1] { label2 }); yield return new CodeInstruction(OpCodes.Ldloc_3, (object)null); yield return new CodeInstruction(OpCodes.Ldc_I4_1, (object)null); yield return new CodeInstruction(OpCodes.Add, (object)null); yield return new CodeInstruction(OpCodes.Stloc_3, (object)null); yield return CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldloc_3, (object)null), new Label[1] { last_br.Value }); yield return new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Host), "delayBufferSize")); yield return new CodeInstruction(OpCodes.Blt_S, (object)label2); } else if (instructionsSkipped.Any((CodeInstruction val2) => CodeInstructionExtensions.LoadsField(val2, updatesPlacedInDelayBufferFieldInfo, false))) { object local_i = instructionsSkipped[instructionsSkipped.Count - 3].operand; object local_m = instructionsSkipped[instructionsSkipped.Count - 2].operand; Main.Log.LogInfo((object)$"Local_i: {local_i}"); Main.Log.LogInfo((object)$"Local_m: {local_m}"); Main.Log.LogInfo((object)"Found InputPacket creation loop"); Label label2 = generator.DefineLabel(); yield return CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_0, (object)null), new Label[1] { label2 }); yield return new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Host), "clients")); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Host), "sentPacketHistory")); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Host), "localPlayerId")); yield return CodeInstruction.Call(typeof(HostPatch_ProcessNetworkPackets), "AddInputPacket", (Type[])null, (Type[])null); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Host), "UpdatesPlacedInDelayBuffer")); yield return new CodeInstruction(OpCodes.Ldc_I4_1, (object)null); yield return new CodeInstruction(OpCodes.Add, (object)null); yield return new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(Host), "UpdatesPlacedInDelayBuffer")); yield return new CodeInstruction(OpCodes.Ldloc_S, local_i); yield return new CodeInstruction(OpCodes.Ldc_I4_1, (object)null); yield return new CodeInstruction(OpCodes.Add, (object)null); yield return new CodeInstruction(OpCodes.Stloc_S, local_i); yield return CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldloc_S, local_i), new Label[1] { last_br.Value }); yield return new CodeInstruction(OpCodes.Ldloc_S, local_m); yield return new CodeInstruction(OpCodes.Blt_S, (object)label2); } else { instructionsSkipped[instructionsSkipped.Count - 7].labels.Add((Label)instructionsSkipped[instructionsSkipped.Count - 1].operand); for (int i = instructionsSkipped.Count - 7; i < instructionsSkipped.Count; i++) { yield return instructionsSkipped[i]; } } continue; } foreach (CodeInstruction item in instructionsSkipped) { yield return item; } yield break; } foreach (CodeInstruction item2 in instructionsSkipped) { yield return item2; } } else { yield return current; } } enumerator.Dispose(); } } [HarmonyPatch(typeof(Host))] [HarmonyPatch("Update")] public class HostPatch_Update { public static int GetCount() { return HostPatch.InputBuffer.Count; } public static MultiInputPacket Dequeue() { return HostPatch.InputBuffer.Dequeue(); } public static int GetTargetDelayBufferSize(MultiInputPacket packet, int currentTargetDelayBufferSize) { if (HostPatch.GetMaxSeqNumber(packet) % 32 == 0) { int maxPreviousTargetDelayBufferSize = HostPatch.GetMaxPreviousTargetDelayBufferSize(); if (maxPreviousTargetDelayBufferSize > 0) { return maxPreviousTargetDelayBufferSize; } } return currentTargetDelayBufferSize; } public static void OverrideInputWithNetworkInput(MultiInputPacket packet) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) List<Player> list = PlayerHandler.Get().PlayerList(); for (int i = 0; i < list.Count; i++) { if (packet.inputPackets.TryGetValue(list[i].Id, out var value)) { list[i].OverrideInputWithNetworkInput(value); } } HostPatch.previousInputPacket = packet; } public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { Main.Log.LogInfo((object)"Patching Host.Update"); FieldInfo inputBufferFieldInfo = AccessTools.Field(typeof(Host), "InputBuffer"); MethodInfo getCountMethodInfo = AccessTools.Method(inputBufferFieldInfo.FieldType, "get_Count", (Type[])null, (Type[])null); MethodInfo dequeueMethodInfo = AccessTools.Method(inputBufferFieldInfo.FieldType, "Dequeue", (Type[])null, (Type[])null); IEnumerator<CodeInstruction> enumerator = instructions.GetEnumerator(); LocalBuilder mipl = generator.DeclareLocal(typeof(MultiInputPacket)); bool foundInputBuffer = false; Label? label = default(Label?); while (enumerator.MoveNext()) { CodeInstruction instruction = enumerator.Current; if (CodeInstructionExtensions.LoadsField(instruction, inputBufferFieldInfo, false)) { Main.Log.LogInfo((object)"Found InputBuffer field load instruction"); foundInputBuffer = true; if (!enumerator.MoveNext()) { Main.Log.LogError((object)"Expected to find next instruction after InputBuffer field load instruction"); yield return instruction; continue; } instruction = enumerator.Current; if (CodeInstructionExtensions.Calls(instruction, getCountMethodInfo)) { Main.Log.LogInfo((object)"Patching InputBuffer.getCount"); yield return new CodeInstruction(OpCodes.Pop, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HostPatch_Update), "GetCount", (Type[])null, (Type[])null)); continue; } if (CodeInstructionExtensions.Calls(instruction, dequeueMethodInfo)) { Main.Log.LogInfo((object)"Patching InputBuffer.Dequeue"); yield return new CodeInstruction(OpCodes.Pop, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HostPatch_Update), "Dequeue", (Type[])null, (Type[])null)); if (!enumerator.MoveNext() && enumerator.Current.opcode == OpCodes.Stloc_S) { Main.Log.LogError((object)"Expected a store local instruction."); break; } yield return new CodeInstruction(OpCodes.Stloc, (object)mipl); while (enumerator.MoveNext()) { instruction = enumerator.Current; if (!(instruction.opcode == OpCodes.Ldarg_0)) { continue; } if (!enumerator.MoveNext()) { Main.Log.LogError((object)"Expected to find next instruction after Ldarg_0"); yield return instruction; continue; } instruction = enumerator.Current; if (!CodeInstructionExtensions.LoadsField(instruction, AccessTools.Field(typeof(Host), "AdaptiveInputDelayBuffer"), false)) { continue; } Main.Log.LogInfo((object)"Found AdaptiveInputDelayBuffer check"); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return instruction; if (!enumerator.MoveNext()) { Main.Log.LogError((object)"Invalid input instruction stream."); continue; } instruction = enumerator.Current; yield return instruction; if (!CodeInstructionExtensions.Branches(instruction, ref label)) { Main.Log.LogError((object)"Assumption about branch after AdaptiveInputDelayBuffer was incorrect."); continue; } while (enumerator.MoveNext()) { instruction = enumerator.Current; if (CodeInstructionExtensions.StoresField(instruction, AccessTools.Field(typeof(Host), "targetDelayBufferSize"))) { break; } } yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldloc, (object)mipl); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Host), "targetDelayBufferSize")); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HostPatch_Update), "GetTargetDelayBufferSize", (Type[])null, (Type[])null)); yield return new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(Host), "targetDelayBufferSize")); break; } continue; } Main.Log.LogError((object)"Failed to patch InputBuffer reference out."); } if (foundInputBuffer && CodeInstructionExtensions.Calls(instruction, AccessTools.Method(typeof(PlayerHandler), "Get", (Type[])null, (Type[])null))) { Main.Log.LogInfo((object)"Patching PlayerHandler.Get calls"); while (enumerator.MoveNext() && !CodeInstructionExtensions.StoresField(enumerator.Current, AccessTools.Field(typeof(Host), "previousInputQuad"))) { } if (enumerator.Current == null) { Main.Log.LogError((object)"Failed to find previousInputQuad store"); break; } yield return new CodeInstruction(OpCodes.Ldloc, (object)mipl); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HostPatch_Update), "OverrideInputWithNetworkInput", (Type[])null, (Type[])null)); } else { yield return instruction; } } } } internal sealed class LobbyMotion : MonoBehaviour { private sealed class PlatformGeometry { internal readonly float FlatHalfWidth; internal readonly float Radius; internal readonly float WaterHeight; internal readonly RoundedRect Shape; internal float CenterY => 0f - Radius - 0.01f; internal float HalfWidth => FlatHalfWidth + Radius; internal PlatformGeometry(float flatHalfWidth, float radius, float waterHeight) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) FlatHalfWidth = flatHalfWidth; Radius = radius; WaterHeight = waterHeight; Shape = new RoundedRect { box = new Box { center = (Vec2)new Vector2(0f, CenterY), right = (Vec2)new Vector2(flatHalfWidth, 0f), up = (Vec2)new Vector2(0f, 0.01f), inverseExtents = (Vec2)new Vector2(1f / flatHalfWidth, 100f) }, radius = (Fix)radius }; } } private sealed class RemoteMotion { internal ushort Sequence; internal readonly List<MotionSample> Samples = new List<MotionSample>(8); internal byte? RespawnCount; internal ReviveSequence Revive; internal bool HoldingRespawn; } private readonly struct ReviveSequence { internal readonly Vector2 Origin; internal readonly float Started; internal readonly float Arrives; internal bool Exists => Arrives > Started; internal ReviveSequence(Vector2 origin, float started) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Origin = origin; Started = started; float num = Vector2.Distance(origin, new Vector2(0f, 7.921875f)); Arrives = started + 1f + Mathf.Ceil(num / 0.5f) * (1f / 60f); } internal bool IsActive(float time) { if (Exists && time >= Started) { return time < Arrives + 1.7500001f; } return false; } } private readonly struct MotionSample { internal readonly float Time; internal readonly MotionPose Pose; internal MotionSample(float time, MotionPose pose) { Time = time; Pose = pose; } } private readonly struct MotionPose { internal readonly Vector2 Position; internal readonly Vector2 Velocity; internal readonly bool Grounded; internal readonly float Angle; internal readonly float Facing; internal MotionPose(Vector2 position, bool grounded, float angle, Vector2 velocity = default(Vector2), float facing = 0f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Position = position; Velocity = velocity; Grounded = grounded; Angle = angle; Facing = facing; } internal static MotionPose Interpolate(MotionPose from, MotionPose to, float blend) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0037: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) MotionPose motionPose = ((blend < 0.5f) ? from : to); Vector2 velocity = ((from.Grounded == to.Grounded) ? Vector2.Lerp(from.Velocity, to.Velocity, blend) : motionPose.Velocity); return new MotionPose(Vector2.Lerp(from.Position, to.Position, blend), motionPose.Grounded, Mathf.LerpAngle(from.Angle, to.Angle, blend), velocity, motionPose.Facing); } } internal sealed class PracticePhysics : IDisposable, IPlayerIdHolder { private readonly GameObject root; private readonly PlayerPhysics player; private readonly PlayerBody body; private readonly StickyRoundedRectangle platform; private readonly PlatformGeometry geometry; private float submerged; private Vector2 sunkPosition; private readonly bool playSounds; internal float Radius => (float)player.radius; internal float WaterHeight => geometry.WaterHeight; internal float MaxSpeed => (float)player.Speed; internal float Acceleration => (float)player.accel; internal bool IsGrounded { get { if (submerged == 0f) { return player.IsGrounded(); } return false; } } internal float Angle { get { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!IsGrounded) { return 0f; } return (float)body.rotation * 57.29578f; } } internal bool TouchesWater => submerged > 0f; internal Vector2 Position { get { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!(submerged > 0f)) { return (Vector2)(body.position - body.up * player.radius); } return sunkPosition; } } internal Vector2 Velocity { get { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!IsGrounded) { return (Vector2)body.Velocity; } return (Vector2)(platform.forwardsDirection(body) * player.groundedSpeed); } } internal Vector2 AnimationVelocity { get { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!IsGrounded) { return (Vector2)body.selfImposedVelocity; } return Velocity; } } internal float Facing { get; private set; } internal bool ShouldPlaySound { get { if (playSounds && (Object)(object)AudioManager.instance != (Object)null) { return Array.Exists(AudioManager.instance.sounds, (Sound sound) => sound.name == "slimeJump1" && (Object)(object)sound.source != (Object)null); } return false; } } internal PracticePhysics(Transform parent = null, bool useLongPlatform = false) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) playSounds = (Object)(object)parent != (Object)null; geometry = (useLongPlatform ? LongPlatform : SmallPlatform); root = new GameObject("Lobby motion simulation"); root.SetActive(false); if ((Object)(object)parent != (Object)null) { root.transform.SetParent(parent, false); } GameObject val = new GameObject(useLongPlatform ? "LongRect" : "SmallCapsule"); val.transform.SetParent(root.transform, false); FixTransform val2 = val.AddComponent<FixTransform>(); val2.position = geometry.Shape.box.center; val2.rotation = Fix.Zero; DPhysicsRoundedRect val3 = val.AddComponent<DPhysicsRoundedRect>(); val3.startExtents = new Vec2((Fix)geometry.FlatHalfWidth, (Fix)0.01f); val3.startRadius = (Fix)geometry.Radius; val3.fixTrans = val2; BoplBody val4 = val.AddComponent<BoplBody>(); val4.fixTrans = val2; val3.body = val4; platform = val.AddComponent<StickyRoundedRectangle>(); platform.groundBody = val4; platform.rr = val3; platform.platformType = (PlatformType)0; platform.UpdateBounds(); SlimeController? obj = Array.Find(Resources.FindObjectsOfTypeAll<SlimeController>(), delegate(SlimeController slime) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Scene scene = ((Component)slime).gameObject.scene; return !((Scene)(ref scene)).IsValid() && (Object)(object)slime.animData != (Object)null && ((Object)slime.animData).name == "MCAnimData"; }); if ((Object)(object)obj == (Object)null) { Object.Destroy((Object)(object)root); throw new InvalidOperationException("Bopl's player prefab is unavailable in the online lobby."); } SlimeController val5 = Object.Instantiate<SlimeController>(obj, root.transform, false); player = ((Component)val5).GetComponent<PlayerPhysics>(); body = ((Component)val5).GetComponent<PlayerBody>(); body.fixTransform = ((Component)val5).GetComponent<FixTransform>(); body.fixTransform.scale = Fix.One; body.rotation = Fix.Zero; player.body = body; player.playerIdHolder = (IPlayerIdHolder)(object)this; body.physics = player; Reset(0f); } internal void Reset(float spawnX) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) submerged = 0f; Facing = 1f; body.rotation = Fix.Zero; body.position = new Vec2((Fix)spawnX, player.radius); player.AttachToGround(platform, body.position); player.groundedSpeed = Fix.Zero; } internal void PlaceAtReviveOrb() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0067: Unknown result type (might be due to invalid IL or missing references) submerged = 0f; Facing = 1f; player.attachedGround = null; player.UnGround(true, false); body.position = new Vec2(Fix.Zero, (Fix)7.921875f); body.externalVelocity = (body.selfImposedVelocity = Vec2.zero); } internal void LeaveReviveOrb() { //IL_0006: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002a: Unknown result type (might be due to invalid IL or missing references) body.selfImposedVelocity = Vec2.up * player.jumpStrength * (Fix)0.25f; } internal bool Step(Vector2 input, bool jump) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) if (submerged > 0f) { submerged += 1f / 60f; sunkPosition.y = Mathf.Max(WaterHeight - 1.1f, sunkPosition.y - 0.20000002f); return submerged >= 0.25f; } Fix fixedTimeStep = GameTime.FixedTimeStep; bool flag = player.IsGrounded(); PracticePhysics activePhysics = LobbyMotion.activePhysics; LobbyMotion.activePhysics = this; try { if (!flag) { player.AddGravityFactor(); player.VelocityBasedRaycasts(true, fixedTimeStep); } bool num = player.IsGrounded(); bool flag2 = num && body.up.y < Fix.Zero; if (num) { Vec2 val = (Vec2)input; Fix val2 = player.InputGroundAlignment(Vec2.NormalizedSafe(val)); bool flag3 = Vec2.Dot(val, body.up) < Fix.Zero; if (Vec2.Magnitude(val) >= Constants.DEADZONE && (Fix.Abs(val2) >= Constants.GROUNDALIGNMENTDEADZONE || (flag3 && Fix.Abs(val2) >= (Fix)0.01f))) { Facing = Fix.Sign(val2); } if (jump) { player.Jump(); } } player.Move((Vec2)input, fixedTimeStep, false); if (player.IsGrounded()) { player.LocalPlatformPos = platform.moveAlongSurface(body, player.radius, player.groundedSpeed, fixedTimeStep, player.LocalPlatformPos); } ((MonoUpdatable)body).UpdateSim(fixedTimeStep); ((MonoUpdatable)player).LateUpdateSim(fixedTimeStep); if (!player.IsGrounded()) { if (flag2) { Facing = 0f - Facing; } if (Mathf.Abs(input.x) > (float)Constants.MIN_TURNSPEED) { Facing = Mathf.Sign(input.x); } } else if (!flag && body.up.y < Fix.Zero) { Facing = 0f - Facing; } } finally { LobbyMotion.activePhysics = activePhysics; } if ((float)(body.position.y - player.radius) <= WaterHeight) { sunkPosition = new Vector2((float)body.position.x, WaterHeight); submerged = 1f / 60f; } return false; } public int GetPlayerId() { return 1; } public void SetPlayerId(int playerId) { } public Material GetPlayerMaterial() { return null; } public void Dispose() { Object.Destroy((Object)(object)root); } internal RaycastInformation Raycast(Vec2 origin, Vec2 direction, Fix distance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) Fix val = default(Fix); Fix val2 = default(Fix); if (!Raycast.RayCastRoundedRect(origin, direction, geometry.Shape, ref val, ref val2) || val > distance) { return new RaycastInformation { nearDist = Fix.MaxValue }; } return new RaycastInformation { nearDist = val, farDist = val2, nearPos = origin + val * direction, farPos = origin + val2 * direction, pp = new PhysicsParent { fixTrans = platform.rr.fixTrans } }; } internal bool Owns(PlayerPhysics component) { return (Object)(object)component == (Object)(object)player; } } [HarmonyPatch(typeof(PlayerPhysics), "checkForWall")] private static class PracticeTerrainPatch { private static bool Prefix(PlayerPhysics __instance, Vec2 __0, Vec2 __1, Fix __2, ref RaycastInformation __result) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) if (activePhysics == null || !activePhysics.Owns(__instance)) { return true; } __result = activePhysics.Raycast(__0, __1, __2); return false; } } [HarmonyPatch(typeof(PlayerPhysics), "UnGround")] private static class PracticeJumpSoundPatch { private static void Prefix(PlayerPhysics __instance, ref bool __1) { if (activePhysics != null && activePhysics.Owns(__instance) && !activePhysics.ShouldPlaySound) { __1 = false; } } } private const float SendInterval = 1f / 30f; private const float HeartbeatInterval = 0.4f; private const float RemoteTimeout = 1.5f; private const int LegacyPositionPacketSize = 10; private const int PositionPacketSize = 16; private const byte MessageType = 7; private const byte PoseMessageType = 6; private const byte RespawnMessageType = 5; private const byte FirstSignedMessageType = 3; private const byte OldMessageType = 2; private const byte HorizontalSteps = 200; private const float NativeHorizontalExtent = 2f; private const float VerticalSteps = 100f; private const int VerticalOrigin = 96; private const byte RespawningY = byte.MaxValue; private const byte Airborne = byte.MaxValue; private const float NativeVerticalSteps = 60f; private const float PositionSteps = 16000f; private const int PositionLimit = 32000; private const short RespawnPosition = short.MaxValue; private const float RemoteBuffer = 0.1f; private const float RemotePrediction = 0.05f; internal const float FixedStep = 1f / 60f; internal const float IslandHalfWidth = 18f; internal const float JumpViewportHeight = 6f; internal const float SmallPlatformWaterHeight = -3.15f; internal const float ReviveCenterY = 7.921875f; internal const float ReviveWispSeconds = 1f; internal const float RespawnSeconds = 1.7500001f; private const float ReviveParticleSpeed = 30f; private const float RespawnDelay = 0.25f; private const float PlatformHalfHeight = 0.01f; private const float DefaultPlayerRadius = 0.76f; private static readonly PlatformGeometry SmallPlatform = new PlatformGeometry(3.16f, 2.65f, -3.15f); private static readonly PlatformGeometry LongPlatform = new PlatformGeometry(17.02f, 4.4f, -4.8f); internal CharacterSelectHandler_online Handler; internal bool UseLongPlatform; private readonly Dictionary<SteamId, RemoteMotion> remote = new Dictionary<SteamId, RemoteMotion>(); private readonly byte[] outgoing = new byte[16] { 77, 66, 80, 50, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; private PracticePhysics physics; private SteamId lobbyId; private MotionPose previousLocal; private MotionPose local; private float spawnX; private float accumulator; private bool wasReady; private bool previousJump; private bool jumpQueued; private float nextSend; private float nextHeartbeat; private bool sentMovement; private ushort sequence; private byte respawnCount; private ReviveSequence localRevive; [ThreadStatic] private static PracticePhysics activePhysics; private PlatformGeometry Geometry { get { if (!UseLongPlatform) { return SmallPlatform; } return LongPlatform; } } internal float WaterHeight => Geometry.WaterHeight; internal float PlatformCenterY => Geometry.CenterY; internal float PlatformHalfWidth => Geometry.HalfWidth; internal float PlayerRadius { get { if (physics == null) { return 0.76f; } return physics.Radius; } } private MotionPose ReviveOrbPose => new MotionPose(Normalize(new Vector2(0f, 7.921875f - PlayerRadius)), grounded: false, 0f); internal static LobbyMotion ForSelector(CharacterSelectBox selector) { CharacterSelectHandler_online selfRef = CharacterSelectHandler_online.selfRef; if (!InLobby(selfRef) || !((Object)(object)selfRef.characterSelectBox == (Object)(object)selector)) { return null; } return ((Component)selfRef).GetComponent<LobbyMotion>(); } private void Update() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) if (!InLobby(Handler)) { return; } SteamManager instance = SteamManager.instance; if ((Object)(object)instance == (Object)null || !SteamClient.IsValid) { return; } SteamId id = ((Lobby)(ref instance.currentLobby)).Id; if (!((SteamId)(ref id)).IsValid) { return; } MatchLobby(((Lobby)(ref instance.currentLobby)).Id); bool flag = CharacterSelectHandler_online.IsLocalPlayerReady(); if (flag != wasReady) { ResetLocalMotion(); wasReady = flag; } if (!flag) { return; } float unscaledTime = Time.unscaledTime; Vector2 input = Vector2.zero; bool jump = false; if (CanUseControls()) { ReadControls(Handler.characterSelectBox, out input, out jump); } jumpQueued |= jump && !previousJump; previousJump = jump; if (localRevive.Exists) { jumpQueued = false; if (unscaledTime >= localRevive.Arrives && physics.TouchesWater) { physics.PlaceAtReviveOrb(); local = (previousLocal = ReadLocalPose()); nextSend = 0f; } if (localRevive.IsActive(unscaledTime)) { SendMotion(instance.connectedPlayers, unscaledTime); return; } physics.LeaveReviveOrb(); localRevive = default(ReviveSequence); } accumulator = Mathf.Min(accumulator + Time.unscaledDeltaTime, 0.1f); while (accumulator >= 1f / 60f) { previousLocal = local; bool num = physics.Step(input, jumpQueued); local = ReadLocalPose(); jumpQueued = false; accumulator -= 1f / 60f; if (num) { localRevive = new ReviveSequence(new Vector2(physics.Position.x, WaterHeight), unscaledTime); previousLocal = local; respawnCount++; accumulator = (nextSend = 0f); break; } } SendMotion(instance.connectedPlayers, unscaledTime); } private MotionPose ReadLocalPose() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) return new MotionPose(Normalize(physics.Position), physics.IsGrounded, physics.Angle, physics.AnimationVelocity, physics.Facing); } private bool CanUseControls() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 if (!InLobby(Handler)) { return false; } CharacterSelectBox characterSelectBox = Handler.characterSelectBox; OnlineInviteMenu component = ((Component)Handler).GetComponent<OnlineInviteMenu>(); if ((Object)(object)characterSelectBox != (Object)null && ((Behaviour)characterSelectBox).enabled && (int)characterSelectBox.menuState == 3) { if (!((Object)(object)component == (Object)null)) { return !component.BlocksInput; } return true; } return false; } internal bool ClaimsMenuButton(ButtonControl button) { if (!CanUseControls()) { return false; } CharacterSelectBox characterSelectBox = Handler.characterSelectBox; InputControl[] keybindOverride = characterSelectBox.playerInit.keybindOverride; if (!characterSelectBox.UseskeyboardMouse) { Gamepad currentGamePad = characterSelectBox.currentGamePad; if (currentGamePad != null) { if (button != currentGamePad.buttonSouth && button != BoundButton(keybindOverride, 0, currentGamePad.buttonSouth) && button != currentGamePad.leftStick.left) { return button == currentGamePad.leftStick.right; } return true; } return false; } Keyboard current = Keyboard.current; if (button != BoundButton(keybindOverride, 4, (ButtonControl)(object)((current != null) ? current.wKey : null)) && button != BoundButton(keybindOverride, 5, (ButtonControl)(object)((current != null) ? current.aKey : null)) && button != BoundButton(keybindOverride, 6, (ButtonControl)(object)((current != null) ? current.sKey : null)) && button != BoundButton(keybindOverride, 7, (ButtonControl)(object)((current != null) ? current.dKey : null))) { return button == BoundButton(keybindOverride, 0, (ButtonControl)(object)((current != null) ? current.spaceKey : null)); } return true; } private static bool InLobby(CharacterSelectHandler_online handler) { if (GameSession.inMenus && (Object)(object)handler != (Object)null && ((Behaviour)handler).isActiveAndEnabled && !handler.isStartingAGame) { return handler.goingBackOperation == null; } return false; } private void MatchLobby(SteamId current) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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) if (SteamId.op_Implicit(lobbyId) != SteamId.op_Implicit(current)) { remote.Clear(); respawnCount = 0; spawnX = SpawnOffset(SteamClient.SteamId).x * 18f; wasReady = false; ResetLocalMotion(); lobbyId = current; } } private void ResetLocalMotion() { if (physics == null) { physics = new PracticePhysics(((Component)this).transform, UseLongPlatform); } physics.Reset(spawnX); local = (previousLocal = ReadLocalPose()); accumulator = 0f; jumpQueued = (previousJump = false); nextSend = (nextHeartbeat = 0f); sentMovement = false; localRevive = default(ReviveSequence); } private static void ReadControls(CharacterSelectBox selector, out Vector2 input, out bool jump) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) InputControl[] keybindOverride = selector.playerInit.keybindOverride; if (selector.UseskeyboardMouse) { Keyboard current = Keyboard.current; input = new Vector2((float)(Pressed(BoundButton(keybindOverride, 7, (ButtonControl)(object)((current != null) ? current.dKey : null))) - Pressed(BoundButton(keybindOverride, 5, (ButtonControl)(object)((current != null) ? current.aKey : null)))), (float)(Pressed(BoundButton(keybindOverride, 4, (ButtonControl)(object)((current != null) ? current.wKey : null))) - Pressed(BoundButton(keybindOverride, 6, (ButtonControl)(object)((current != null) ? current.sKey : null))))); ButtonControl obj = BoundButton(keybindOverride, 0, (ButtonControl)(object)((current != null) ? current.spaceKey : null)); jump = obj != null && obj.isPressed; return; } Gamepad currentGamePad = selector.currentGamePad; if (currentGamePad == null) { input = Vector2.zero; jump = false; return; } Vector2 val = ((InputControl<Vector2>)(object)currentGamePad.leftStick).ReadValue(); if (InputProfile.inputVectors == null) { InputProfile.GenerateInputVectorTable(); } byte b = InputProfile.JoyStickAngleByteFromVector((Vec2)val); input = (Vector2)InputProfile.inputVectorFromByte(b); ButtonControl obj2 = BoundButton(keybindOverride, 0, currentGamePad.buttonSouth); jump = obj2 != null && obj2.isPressed; } private static int Pressed(ButtonControl button) { return (button != null && button.isPressed) ? 1 : 0; } private static ButtonControl BoundButton(InputControl[] bindings, int index, ButtonControl fallback) { return (ButtonControl)(((object)((bindings != null && index < bindings.Length) ? /*isinst with value type is only supported in some contexts*/: null)) ?? ((object)fallback)); } private void OnDestroy() { physics?.Dispose(); } private static Vector2 Normalize(Vector2 world) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) return new Vector2(world.x / 18f, world.y / 6f); } internal bool TouchesWater(Vector2 offset, float angle) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return offset.y * 6f + PlayerRadius * (Mathf.Cos(angle * ((float)Math.PI / 180f)) - 1f) <= WaterHeight + 0.03f; } internal static bool OnSurface(Vector2 offset, out float angle) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return OnSurface(offset, SmallPlatform, out angle); } private static bool OnSurface(Vector2 offset, PlatformGeometry geometry, out float angle) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) Vec2 val = (Vec2)new Vector2(offset.x * 18f, offset.y * 6f); RoundedRect shape = geometry.Shape; Vec2 closestPoint = ((RoundedRect)(ref shape)).GetClosestPoint(val); angle = 0f; if ((float)Vec2.Magnitude(val - closestPoint) > 0.13f) { return false; } float flatHalfWidth = geometry.FlatHalfWidth; float num = Mathf.Clamp((float)closestPoint.x - Mathf.Clamp((float)closestPoint.x, 0f - flatHalfWidth, flatHalfWidth), 0f - geometry.Radius, geometry.Radius); float num2 = (float)closestPoint.y - Mathf.Clamp((float)closestPoint.y, geometry.CenterY - 0.01f, geometry.CenterY + 0.01f); angle = (0f - Mathf.Atan2(num, num2)) * 57.29578f; return true; } internal Vector2 GetOffset(int slot, SteamConnection peer) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) float respawnAge; return GetOffset(slot, peer, out respawnAge); } internal Vector2 GetOffset(int slot, SteamConnection peer, out float respawnAge) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) bool grounded; float angle; return GetPose(slot, peer, out respawnAge, out grounded, out angle); } internal Vector2 GetPose(int slot, SteamConnection peer, out float respawnAge, out bool grounded, out float angle) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) Vector2 velocity; float facing; return GetPose(slot, peer, out respawnAge, out grounded, out angle, out velocity, out facing); } internal Vector2 GetPose(int slot, SteamConnection peer, out float respawnAge, out bool grounded, out float angle, out Vector2 velocity, out float facing) { //IL_0100: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; respawnAge = float.PositiveInfinity; MotionPose motionPose; RemoteMotion value; if (slot == 0) { if (localRevive.IsActive(unscaledTime) && unscaledTime >= localRevive.Arrives) { respawnAge = unscaledTime - localRevive.Arrives; } motionPose = MotionPose.Interpolate(previousLocal, local, accumulator / (1f / 60f)); } else if (peer != null && ((ConnectionManager)peer).Connected && remote.TryGetValue(peer.id, out value)) { float num = unscaledTime - 0.1f; ReviveSequence revive = value.Revive; if (!revive.IsActive(num)) { motionPose = GetRemotePose(value, num); } else if (num < revive.Arrives) { motionPose = new MotionPose(Normalize(revive.Origin), grounded: false, 0f); } else { respawnAge = num - revive.Arrives; motionPose = ReviveOrbPose; } } else { motionPose = new MotionPose((peer != null && ((ConnectionManager)peer).Connected) ? SpawnOffset(peer.id) : Vector2.zero, grounded: true, 0f); } grounded = motionPose.Grounded; angle = motionPose.Angle; velocity = motionPose.Velocity; facing = motionPose.Facing; return motionPose.Position; } internal bool GetRevive(int slot, SteamConnection peer, out Vector2 origin, out float age, out float arrivalAge) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) float num = Time.unscaledTime; ReviveSequence reviveSequence; RemoteMotion value; if (slot == 0) { reviveSequence = localRevive; } else if (peer != null && ((ConnectionManager)peer).Connected && remote.TryGetValue(peer.id, out value)) { reviveSequence = value.Revive; num -= 0.1f; } else { reviveSequence = default(ReviveSequence); } origin = reviveSequence.Origin; age = num - reviveSequence.Started; arrivalAge = num - reviveSequence.Arrives; return reviveSequence.IsActive(num); } private static MotionPose GetRemotePose(RemoteMotion state, float renderTime) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) List<MotionSample> samples = state.Samples; while (samples.Count > 2 && samples[1].Time <= renderTime) { samples.RemoveAt(0); } if (samples.Count == 1) { return samples[0].Pose; } MotionSample motionSample = samples[0]; MotionSample motionSample2 = samples[1]; float num = motionSample2.Time - motionSample.Time; if (num <= 0f || num > 1.5f) { return motionSample2.Pose; } Vector2 val = motionSample2.Pose.Position - motionSample.Pose.Position; Vector2 val2 = new Vector2(val.x * 18f, val.y * 6f) / num; if (renderTime <= motionSample2.Time) { MotionPose motionPose = MotionPose.Interpolate(motionSample.Pose, motionSample2.Pose, Mathf.InverseLerp(motionSample.Time, motionSample2.Time, renderTime)); return new MotionPose(motionPose.Position, motionPose.Grounded, motionPose.Angle, val2); } if (state.HoldingRespawn || num > 0.1f || motionSample.Pose.Grounded != motionSample2.Pose.Grounded) { return motionSample2.Pose; } float num2 = Mathf.Min(renderTime - motionSample2.Time, 0.05f) / num; return new MotionPose(motionSample2.Pose.Position + val * num2, angle: motionSample2.Pose.Angle + Mathf.DeltaAngle(motionSample.Pose.Angle, motionSample2.Pose.Angle) * num2, grounded: motionSample2.Pose.Grounded, velocity: (renderTime - motionSample2.Time < 0.05f) ? val2 : Vector2.zero); } private Vector2 SpawnOffset(SteamId player) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) long num = (long)SteamId.op_Implicit(player) * -7046029254386353131L >>> 56; float num2 = Mathf.Min(Geometry.FlatHalfWidth, 9f); return new Vector2(((float)(ulong)num / 255f - 0.5f) * 1.6f * num2 / 18f, 0f); } private void SendMotion(List<SteamConnection> peers, float now) { //IL_01bd: Unknown result type (might be due to invalid IL or missing references) if (peers == null || peers.Count == 0 || now < nextSend) { return; } short num = EncodePosition(local.Position.x); short num2 = ((localRevive.IsActive(now) && now >= localRevive.Arrives) ? short.MaxValue : EncodePosition(local.Position.y)); byte b = (local.Grounded ? ((byte)Mathf.RoundToInt(127f * (Mathf.DeltaAngle(0f, local.Angle) / 180f + 1f))) : byte.MaxValue); bool flag = num != ReadPosition(outgoing, 8) || num2 != ReadPosition(outgoing, 10) || respawnCount != outgoing[12] || b != outgoing[13]; if (!flag && !sentMovement && now < nextHeartbeat) { return; } sequence++; outgoing[6] = (byte)sequence; outgoing[7] = (byte)(sequence >> 8); WritePosition(outgoing, 8, num); WritePosition(outgoing, 10, num2); outgoing[12] = respawnCount; outgoing[13] = b; sentMovement = flag; nextSend = now + 1f / 30f; nextHeartbeat = now + 0.4f; foreach (SteamConnection peer in peers) { if (((ConnectionManager)peer).Connected && !peer.beingKicked) { ((Connection)(ref ((ConnectionManager)peer).Connection)).SendMessage(outgoing, (SendType)4); } } } internal static bool TryHandlePacket(SteamManager manager, SteamId sender, byte[] packet) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (!HasMotionHeader(packet)) { return false; } CharacterSelectHandler_online selfRef = CharacterSelectHandler_online.selfRef; if (!InLobby(selfRef) || SteamId.op_Implicit(sender) == SteamId.op_Implicit(SteamClient.SteamId) || !manager.connectedPlayers.Exists((SteamConnection peer) => SteamId.op_Implicit(peer.id) == SteamId.op_Implicit(sender) && ((ConnectionManager)peer).Connected && !peer.beingKicked) || !TryDecode(packet, out var order, out var offset, out var respawns, out var respawning, out var groundAngle)) { return true; } LobbyMotion component = ((Component)selfRef).GetComponent<LobbyMotion>(); if ((Object)(object)component != (Object)null) { component.MatchLobby(((Lobby)(ref manager.currentLobby)).Id); component.Receive(sender, order, offset, Time.unscaledTime, respawns, respawning, groundAngle, packet[5] >= 6); } return true; } internal void Receive(SteamId sender, ushort order, Vector2 offset, float now, byte? respawns = null, bool respawning = false, float? groundAngle = null, bool hasPose = false) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) if (!remote.TryGetValue(sender, out var value)) { value = new RemoteMotion(); remote.Add(sender, value); } List<MotionSample> samples = value.Samples; MotionSample motionSample = ((samples.Count > 0) ? samples[samples.Count - 1] : default(MotionSample)); if (samples.Count > 0 && now - motionSample.Time < 1.5f && !IsNewer(order, value.Sequence)) { return; } bool flag = !respawning && offset.y * 6f <= WaterHeight + 0.04f; bool flag2 = samples.Count > 0 && motionSample.Pose.Position.y * 6f <= WaterHeight + 0.04f; bool num; if (!respawns.HasValue || !value.RespawnCount.HasValue) { if (!value.HoldingRespawn && respawning) { goto IL_0193; } if (!(!respawns.HasValue && flag2)) { goto IL_01db; } num = offset.y >= 0f; } else { num = respawns != value.RespawnCount; } if (num) { goto IL_0193; } goto IL_01db; IL_01ed: float angle = groundAngle.GetValueOrDefault(); bool grounded = groundAngle.HasValue || (!hasPose && OnSurface(offset, Geometry, out angle)); value.HoldingRespawn = respawning; samples.Add(new MotionSample(now, respawning ? ReviveOrbPose : new MotionPose(offset, grounded, angle))); if (samples.Count > 8) { samples.RemoveAt(0); } value.RespawnCount = respawns; value.Sequence = order; return; IL_0193: float num2 = (flag ? offset.x : motionSample.Pose.Position.x); value.Revive = new ReviveSequence(new Vector2(num2 * 18f, WaterHeight), now); if (!flag) { samples.Clear(); } goto IL_01ed; IL_01db: if (respawning && !value.HoldingRespawn) { samples.Clear(); } goto IL_01ed; } private static bool HasMotionHeader(byte[] packet) { if (packet.Length >= 6 && packet[0] == 77 && packet[1] == 66 && packet[2] == 80 && packet[3] == 50 && packet[4] == 1 && packet[5] >= 2) { return packet[5] <= 7; } return false; } internal static bool TryDecode(byte[] packet, out ushort order, out Vector2 offset) { byte? respawns; bool respawning; float? groundAngle; return TryDecode(packet, out order, out offset, out respawns, out respawning, out groundAngle); } internal static bool TryDecode(byte[] packet, out ushort order, out Vector2 offset, out byte? respawns, out bool respawning) { float? groundAngle; return TryDecode(packet, out order, out offset, out respawns, out respawning, out groundAngle); } internal static bool TryDecode(byte[] packet, out ushort order, out Vector2 offset, out byte? respawns, out bool respawning, out float? groundAngle) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) order = 0; offset = Vector2.zero; respawns = null; respawning = false; groundAngle = null; if (!HasMotionHeader(packet)) { return false; } if (packet[5] == 7) { if (packet.Length != 16 || packet[14] != 0 || packet[15] != 0) { return false; } short num = ReadPosition(packet, 8); short num2 = ReadPosition(packet, 10); bool flag = num == 0 && num2 == short.MaxValue; if (Mathf.Abs((int)num) > 32000 || (!flag && Mathf.Abs((int)num2) > 32000)) { return false; } order = (ushort)(packet[6] | (packet[7] << 8)); offset = new Vector2((float)num / 16000f, flag ? 0f : ((float)num2 / 16000f)); respawns = packet[12]; respawning = flag; if (packet[13] != byte.MaxValue) { groundAngle = DecodeAngle(packet[13]); } return true; } bool flag2 = packet[5] == 6; bool flag3 = packet[5] >= 5; int num3 = 10 + (flag3 ? 1 : 0) + (flag2 ? 1 : 0); if (packet.Length != num3 || packet[8] > 200) { return false; } bool flag4 = flag3 && packet[8] == 100 && packet[9] == byte.MaxValue; int num4 = ((packet[5] == 3) ? 55 : 96); if (!flag4 && packet[9] > ((packet[5] == 2) ? 200 : (num4 + 120))) { return false; } order = (ushort)(packet[6] | (packet[7] << 8)); float num5 = (flag4 ? 0f : ((packet[5] == 2) ? ((float)(int)packet[9] / 200f) : ((float)(packet[9] - num4) / (flag2 ? 60f : 100f)))); float num6 = ((float)(int)packet[8] * 0.01f - 1f) * (flag2 ? 2f : 1f); offset = new Vector2(num6, num5); if (flag3) { respawns = packet[10]; } respawning = flag4; if (flag2 && packet[11] != byte.MaxValue) { groundAngle = DecodeAngle(packet[11]); } return true; } private static short EncodePosition(float position) { return (short)Mathf.Clamp(Mathf.RoundToInt(position * 16000f), -32000, 32000); } private static short ReadPosition(byte[] packet, int index) { return (short)(packet[index] | (packet[index + 1] << 8)); } private static void WritePosition(byte[] packet, int index, short position) { packet[index] = (byte)position; packet[index + 1] = (byte)(position >> 8); } private static float DecodeAngle(byte angle) { return ((float)(int)angle / 127f - 1f) * 180f; } internal static bool IsNewer(ushort order, ushort previous) { ushort num = (ushort)(order - previous); if (num > 0) { return num < 32768; } return false; } } internal static class LobbyPlatformAssets { private readonly struct AssetObject { internal readonly long Start; internal readonly long End; internal AssetObject(long start, long end) { Start = start; End = end; } } private const string NativePlatform = "LongRect"; private const string LevelOneAssets = "sharedassets6.assets"; private const int TextureClassId = 28; private const int SpriteClassId = 213; private static Sprite widePlatform; private static bool triedReading; internal static Sprite GetLongPlatform() { if ((Object)(object)widePlatform != (Object)null) { return widePlatform; } Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>(); foreach (Sprite val in array) { if (((Object)val).name == "LongRect") { return widePlatform = val; } } if (triedReading) { return null; } triedReading = true; try { widePlatform = ReadLongPlatform(Application.dataPath); } catch (Exception ex) when (ex is IOException || ex is InvalidDataException || ex is UnauthorizedAccessException || ex is UnityException || ex is ArgumentException) { Main.Log.LogWarning((object)("The lobby could not read Bopl's LongRect artwork and will use SmallCapsule: " + ex.Message)); } return widePlatform; } private static Sprite ReadLongPlatform(string gameData) { //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Invalid comparison between Unknown and I4 //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Expected O, but got Unknown //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(Path.Combine(gameData, "sharedassets6.assets"))); Stream baseStream = binaryReader.BaseStream; baseStream.Position = 8L; if (ReadBigEndian(binaryReader, 4) != 22) { throw new InvalidDataException("Unexpected Unity asset format."); } baseStream.Position = 16L; if (binaryReader.ReadByte() != 0) { throw new InvalidDataException("Unexpected Unity asset byte order."); } baseStream.Position = 32L; long num = ReadBigEndian(binaryReader, 8); baseStream.Position = 48L; StringBuilder stringBuilder = new StringBuilder(); byte value; while (stringBuilder.Length < 64 && (value = binaryReader.ReadByte()) != 0) { stringBuilder.Append((char)value); } if (!stringBuilder.ToString().StartsWith("2022.3.", StringComparison.Ordinal) || binaryReader.ReadInt32() != 19 || binaryReader.ReadBoolean() || num > baseStream.Length) { throw new InvalidDataException("Unexpected Unity player metadata."); } int[] array = new int[ReadCount(binaryReader, 128)]; for (int i = 0; i < array.Length; i++) { array[i] = binaryReader.ReadInt32(); binaryReader.ReadBoolean(); binaryReader.ReadInt16(); baseStream.Position += ((array[i] == 114) ? 32 : 16); } AssetObject assetObject = default(AssetObject); AssetObject assetObject2 = default(AssetObject); int num2 = ReadCount(binaryReader, 1024); for (int j = 0; j < num2; j++) { Align(binaryReader); binaryReader.ReadInt64(); long num3 = num + binaryReader.ReadInt64(); uint num4 = binaryReader.ReadUInt32(); int num5 = binaryReader.ReadInt32(); if (num3 < num || num3 > baseStream.Length || num4 > baseStream.Length - num3 || num5 < 0 || num5 >= array.Length) { throw new InvalidDataException("Invalid Unity object entry."); } if (array[num5] != 28 && array[num5] != 213) { continue; } long position = baseStream.Position; baseStream.Position = num3; if (ReadString(binaryReader) == "LongRect") { AssetObject assetObject3 = new AssetObject(baseStream.Position, num3 + num4); if (array[num5] == 28) { assetObject = assetObject3; } else { assetObject2 = assetObject3; } } baseStream.Position = position; } if (assetObject.End == 0L || assetObject2.End == 0L) { throw new InvalidDataException("The named platform sprite and texture were not found."); } baseStream.Position = assetObject2.Start; Rect val = new Rect(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); baseStream.Position += 24L; float num6 = binaryReader.ReadSingle(); Vector2 val2 = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); if (baseStream.Position > assetObject2.End || !(num6 > 0f) || !(val2.x >= 0f) || !(val2.x <= 1f) || !(val2.y >= 0f) || !(val2.y <= 1f)) { throw new InvalidDataException("Invalid platform sprite geometry."); } baseStream.Position = assetObject.Start + 8; int num7 = binaryReader.ReadInt32(); int num8 = binaryReader.ReadInt32(); baseStream.Position += 8L; TextureFormat val3 = (TextureFormat)binaryReader.ReadInt32(); if (num7 <= 0 || num7 > 4096 || num8 <= 0 || num8 > 4096 || (int)val3 != 4 || ((Rect)(ref val)).x != 0f || ((Rect)(ref val)).y != 0f || ((Rect)(ref val)).width != (float)num7 || ((Rect)(ref val)).height != (float)num8) { throw new InvalidDataException("Unexpected LongRect texture format or dimensions."); } string text = "sharedassets6.assets.resS"; int num9 = checked(num7 * num8 * 4); int num10 = (4 + Encoding.UTF8.GetByteCount(text) + 3) & -4; long num11 = assetObject.End - num10 - 12; if (num11 < baseStream.Position) { throw new InvalidDataException("Missing LongRect texture stream record."); } baseStream.Position = num11; long num12 = binaryReader.ReadInt64(); uint num13 = binaryReader.ReadUInt32(); if (ReadString(binaryReader) != text || num12 < 0 || num13 < num9) { throw new InvalidDataException("Invalid LongRect texture stream record."); } using BinaryReader binaryReader2 = new BinaryReader(File.OpenRead(Path.Combine(gameData, text))); if (num12 > binaryReader2.BaseStream.Length || num13 > binaryReader2.BaseStream.Length - num12) { throw new InvalidDataException("LongRect texture stream exceeds the installed resource."); } binaryReader2.BaseStream.Position = num12; byte[] array2 = binaryReader2.ReadBytes(num9); if (array2.Length != num9) { throw new EndOfStreamException("LongRect texture data was incomplete."); } Texture2D val4 = new Texture2D(num7, num8, val3, false) { name = "LongRect", wrapMode = (TextureWrapMode)1 }; try { val4.LoadRawTextureData(array2); val4.Apply(false, true); Sprite obj = Sprite.Create(val4, val, val2, num6, 0u, (SpriteMeshType)0); ((Object)obj).name = "LongRect"; return obj; } catch { Object.Destroy((Object)(object)val4); throw; } } private static long ReadBigEndian(BinaryReader reader, int bytes) { long num = 0L; for (int i = 0; i < bytes; i++) { num = (num << 8) | reader.ReadByte(); } return num; } private static int ReadCount(BinaryReader reader, int max) { int num = reader.ReadInt32(); if (num < 0 || num > max) { throw new InvalidDataException("Invalid Unity metadata length."); } return num; } private static string ReadString(BinaryReader reader) { int num = ReadCount(reader, 256); byte[] array = reader.ReadBytes(num); if (array.Length != num) { throw new EndOfStreamException(); } Align(reader); return Encoding.UTF8.GetString(array); } private static void Align(BinaryReader reader) { reader.BaseStream.Position = (reader.BaseStream.Position + 3) & -4; } } [HarmonyPatch] internal static class LobbyPracticeInputPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(SelectColor), "Update", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(SelectAbility), "Update", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(CharacterSelectBox), "LateUpdate", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(CharacterSelectHandler_online), "Update", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo pressed = AccessTools.PropertyGetter(typeof(ButtonControl), "wasPressedThisFrame"); MethodInfo menuPressed = AccessTools.Method(typeof(LobbyPracticeInputPatch), "MenuPressed", (Type[])null, (Type[])null); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, pressed)) { CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_0, (object)null); val.labels.AddRange(instruction.labels); val.blocks.AddRange(instruction.blocks); yield return val; yield return new CodeInstruction(OpCodes.Call, (object)menuPressed); } else { yield return instruction; } } } private static bool MenuPressed(ButtonControl button, MonoBehaviour menu) { if (!button.wasPressedThisFrame) { return false; } CharacterSelectBox val = (CharacterSelectBox)(object)((menu is CharacterSelectBox) ? menu : null); CharacterSelectBox selector; if (val == null) { SelectColor val2 = (SelectColor)(object)((menu is SelectColor) ? menu : null); if (val2 == null) { SelectAbility val3 = (SelectAbility)(object)((menu is SelectAbility) ? menu : null); selector = ((val3 != null) ? val3.csb : ((CharacterSelectHandler_online)(((menu is CharacterSelectHandler_online) ? menu : null)?)).characterSelectBox); } else { selector = val2.csb; } } else { selector = val; } LobbyMotion lobbyMotion = LobbyMotion.ForSelector(selector); if (!((Object)(object)lobbyMotion == (Object)null)) { return !lobbyMotion.ClaimsMenuButton(button); } return true; } } internal sealed class LobbyWaterView : MonoBehaviour { private const string GradientShaderName = "Unlit/GradientColor"; private static readonly int[] WaveSequence = new int[10] { 2, 3, 4, 5, 6, 6, 8, 8, 9, 10 }; private RenderTexture surface; private Material waterGradient; private RawImage image; private Sprite[] waveFrames; private Image leftWave; private Image rightWave; private int currentWaveFrame = -1; internal static LobbyWaterView Build(RectTransform viewport, Vector2 center, Vector2 size, float shorelineHalfWidth = 0f, float unitsPerWorldUnit = 32f) { //IL_0006: 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) RectTransform val = OnlineInviteMenu.Rect("PracticeWater", (Transform)(object)viewport, center, size); LobbyWaterView lobbyWaterView = ((Component)val).gameObject.AddComponent<LobbyWaterView>(); lobbyWaterView.image = ((Component)val).gameObject.AddComponent<RawImage>(); (