Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of EightPlayers v1.2.0
EightPlayers.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BoplFixedMath; using HarmonyLib; using Microsoft.CodeAnalysis; using Steamworks; using Steamworks.Data; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EightPlayers")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0")] [assembly: AssemblyProduct("EightPlayers")] [assembly: AssemblyTitle("EightPlayers")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 EightPlayers { internal static class ExtStart { public const int PacketSize = 59; public const int FirstExtSlot = 5; private const int SlotCount = 4; private const int HeaderSize = 7; private const int SlotSize = 13; private const byte Version = 1; public static bool Valid; public static ushort SeqNum; public static ulong HostId; public static readonly ulong[] Ids = new ulong[9]; public static readonly byte[] Colors = new byte[9]; public static readonly byte[] Teams = new byte[9]; public static readonly byte[] Ab1 = new byte[9]; public static readonly byte[] Ab2 = new byte[9]; public static readonly byte[] Ab3 = new byte[9]; private static readonly byte[] sendBuffer = new byte[59]; public static bool AppliesTo(StartRequestPacket p) { //IL_000c: 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) if (Valid && SeqNum == p.seqNum) { return HostId == p.p1_id; } return false; } public static void Clear() { Valid = false; HostId = 0uL; for (int i = 0; i < Ids.Length; i++) { Ids[i] = 0uL; Colors[i] = (Teams[i] = (Ab1[i] = (Ab2[i] = (Ab3[i] = 0)))); } } public static void GetSlot(StartRequestPacket p, int id, out ulong steamId, out byte color, out byte team, out byte a1, out byte a2, out byte a3) { //IL_001e: 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_002f: 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_0041: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0099: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) switch (id) { case 1: steamId = p.p1_id; color = p.p1_color; team = p.p1_team; a1 = p.p1_ability1; a2 = p.p1_ability2; a3 = p.p1_ability3; break; case 2: steamId = p.p2_id; color = p.p2_color; team = p.p2_team; a1 = p.p2_ability1; a2 = p.p2_ability2; a3 = p.p2_ability3; break; case 3: steamId = p.p3_id; color = p.p3_color; team = p.p3_team; a1 = p.p3_ability1; a2 = p.p3_ability2; a3 = p.p3_ability3; break; case 4: steamId = p.p4_id; color = p.p4_color; team = p.p4_team; a1 = p.p4_ability1; a2 = p.p4_ability2; a3 = p.p4_ability3; break; case 5: case 6: case 7: case 8: steamId = Ids[id]; color = Colors[id]; team = Teams[id]; a1 = Ab1[id]; a2 = Ab2[id]; a3 = Ab3[id]; break; default: steamId = 0uL; color = (team = (a1 = (a2 = (a3 = 0)))); break; } } public static ulong SteamIdOf(StartRequestPacket p, int id) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GetSlot(p, id, out var steamId, out var _, out var _, out var _, out var _, out var _); return steamId; } public static void FillFromLobby(ushort seqNum, List<SteamConnection> connected) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Clear(); SeqNum = seqNum; HostId = SteamClient.SteamId.Value; for (int i = 3; i < connected.Count && i < 7; i++) { int num = i + 2; SteamConnection val = connected[i]; Ids[num] = val.id.Value; Colors[num] = (byte)val.lobby_color; Teams[num] = val.lobby_team; Ab1[num] = val.lobby_ability1; Ab2[num] = val.lobby_ability2; Ab3[num] = val.lobby_ability3; } Valid = connected.Count > 3; } public static void Broadcast(List<SteamConnection> connected) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) Encode(sendBuffer); for (int i = 0; i < connected.Count; i++) { ((Connection)(ref ((ConnectionManager)connected[i]).Connection)).SendMessage(sendBuffer, (SendType)8); } } private static void Encode(byte[] d) { d[0] = 66; d[1] = 56; d[2] = 80; d[3] = 1; d[4] = (byte)(SeqNum >> 8); d[5] = (byte)SeqNum; d[6] = 4; int num = 7; for (int i = 5; i < 9; i++) { ulong num2 = Ids[i]; for (int num3 = 7; num3 >= 0; num3--) { d[num++] = (byte)(num2 >> num3 * 8); } d[num++] = Colors[i]; d[num++] = Teams[i]; d[num++] = Ab1[i]; d[num++] = Ab2[i]; d[num++] = Ab3[i]; } } public static bool IsExtPacket(byte[] d, int size) { if (size == 59 && d[0] == 66 && d[1] == 56 && d[2] == 80) { return d[3] == 1; } return false; } public static void Decode(byte[] d, ulong hostId) { Clear(); HostId = hostId; SeqNum = (ushort)((d[4] << 8) | d[5]); int num = 7; for (int i = 5; i < 9; i++) { ulong num2 = 0uL; for (int j = 0; j < 8; j++) { num2 = (num2 << 8) | d[num++]; } Ids[i] = num2; Colors[i] = d[num++]; Teams[i] = d[num++]; Ab1[i] = d[num++]; Ab2[i] = d[num++]; Ab3[i] = d[num++]; } Valid = true; } public static int LocalPlayerId(StartRequestPacket p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) ulong value = SteamClient.SteamId.Value; for (int i = 1; i <= 8; i++) { if (SteamIdOf(p, i) == value) { return i; } } return 0; } } [HarmonyPatch] internal static class GameplayPatches { [HarmonyPostfix] [HarmonyPatch(typeof(GameSessionHandler), "Awake")] private static void GameSessionHandler_Awake(GameSessionHandler __instance) { Palette.ExtendLoadedAssets(); Vec2[] teamSpawns = __instance.teamSpawns; if (teamSpawns != null && teamSpawns.Length != 0 && teamSpawns.Length < 8) { __instance.teamSpawns = SpawnPlanner.ExtendTeamSpawns(__instance); GameSessionHandler.playerSpawns_readonly = __instance.teamSpawns; } } [HarmonyPrefix] [HarmonyPatch(typeof(GameSessionHandler), "SpawnPlayers")] private static void GameSessionHandler_SpawnPlayersPrefix(GameSessionHandler __instance) { Palette.ExtendLoadedAssets(); SpawnPlanner.Prepare(__instance); } [HarmonyFinalizer] [HarmonyPatch(typeof(GameSessionHandler), "SpawnPlayers")] private static void GameSessionHandler_SpawnPlayersFinalizer() { SpawnPlanner.Finish(); } [HarmonyTranspiler] [HarmonyPatch(typeof(GameSessionHandler), "SpawnPlayers")] private static IEnumerable<CodeInstruction> GameSessionHandler_SpawnPlayers(IEnumerable<CodeInstruction> instructions) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(SpawnPlanner), "NextPosition", (Type[])null, (Type[])null); bool flag = false; bool flag2 = false; for (int i = 0; i < list.Count; i++) { if (i + 1 < list.Count && list[i].opcode == OpCodes.Ldc_I4_4 && list[i + 1].opcode == OpCodes.Newarr && list[i + 1].operand as Type == typeof(int)) { list[i] = CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldc_I4, (object)8), list[i]); flag = true; } else if (!flag2 && list[i].opcode == OpCodes.Call && list[i].operand is MethodInfo { Name: "InstantiateFixed" } methodInfo2 && methodInfo2.ReturnType == typeof(SlimeController)) { list.Insert(i, new CodeInstruction(OpCodes.Call, (object)methodInfo)); flag2 = true; i++; } } if (!flag) { Plugin.Log.LogWarning((object)"SpawnPlayers: team counter array not found, teams 5-8 may fail to spawn."); } if (!flag2) { Plugin.Log.LogWarning((object)"SpawnPlayers: player spawn call not found, players may spawn on top of each other."); } return list; } } [HarmonyPatch] internal static class HostExt { private static readonly Queue<InputPacket[]> inputBuffer = new Queue<InputPacket[]>(); private static InputPacket[] previousFrame = NewFrame(); public static bool Active { get; private set; } private static InputPacket[] NewFrame() { return (InputPacket[])(object)new InputPacket[9]; } public static bool HasClient(Host host, SteamId steamId, int playerId) { //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) List<Client> clients = host.clients; if (clients == null) { return false; } for (int i = 0; i < clients.Count; i++) { if (clients[i].PlayerId == playerId && clients[i].Id.Value == steamId.Value) { return true; } } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(Host), "Init")] private static void Host_Init(Host __instance, List<Client> clients, int localPlayerId) { inputBuffer.Clear(); previousFrame = NewFrame(); bool flag = localPlayerId > 4; if (clients != null) { foreach (Client client in clients) { flag |= client.PlayerId > 4; } } if (flag != Active) { Plugin.Log.LogInfo((object)(flag ? "Using 8-player lockstep loop." : "Using vanilla lockstep loop.")); } Active = flag; } [HarmonyPrefix] [HarmonyPatch(typeof(Host), "Update")] private static bool Host_Update(Host __instance) { if (!Active || __instance.PlayReplayInEditor || GameLobby.isPlayingAReplay) { return true; } Update(__instance); return false; } private static void Update(Host h) { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) List<Client> clients = h.clients; if (clients != null && clients.Count > 0) { for (int num = clients.Count - 1; num >= 0; num--) { bool flag = false; foreach (SteamConnection connectedPlayer in SteamManager.instance.connectedPlayers) { if (connectedPlayer.id.Value == clients[num].Id.Value) { flag = true; } } if (!flag) { Host.disconnectedPlayerName = clients[num].steamConnection.steamName; Host.disconnectedPlayerId = clients[num].PlayerId; Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).buildIndex < 6 && GameLobby.isOnlineGame) { clients.Clear(); Debug.Log((object)"A client was disconnected, abandoning lobby"); GameSessionHandler.LeaveGame(true, false); return; } clients.RemoveAt(num); } } if (clients.Count == 0) { GameSessionHandler.LeaveGame(false, false); return; } } if (!h.hasBeenInitialized) { return; } ProcessNetworkPackets(h); if (!h.allClientsSynced) { if (h.timeSinceLastBroadcast > 1f / 60f) { h.BroadcastInputPacket(); h.timeSinceLastBroadcast = 0f; } h.timeSinceLastBroadcast += Time.deltaTime; return; } float num2 = 8f * (float)GameTime.FixedTimeStep; h.timePassed += Mathf.Min(Time.deltaTime, num2); bool flag2 = false; int team = PlayerHandler.Get().GetPlayer(h.localPlayerId).Team; bool flag3 = false; for (int i = 0; i < clients.Count; i++) { Player player = PlayerHandler.Get().GetPlayer(clients[i].PlayerId); if (player != null && player.Team != team) { flag3 = true; } } if (!flag3) { SteamManager.ForceBacktoAbilitySelect(); } if (h.localPlayerId != 1 && clients.Count != 0) { Client val = clients[0]; for (int j = 0; j < clients.Count; j++) { if (clients[j].PlayerId == 1) { val = clients[j]; break; } } if (val.newTimePassed) { float num3 = val.latestTimePassedReceived + (float)val.lagEstimateMillis * 0.001f; val.newTimePassed = false; float num4 = num3 - h.timePassed; h.timePassedDeltas.Add(num4); num4 = h.EstimateTimePassedDelta(); if (num4 > h.catchupWindow || num4 < 0f - h.catchupWindow) { h.UpdateTimePassed(num4); flag2 = true; } } } while (true) { double num5 = (double)Updater.SimulationTicks * (double)GameTime.FixedTimeStep; if ((double)h.timePassed - num5 < (double)GameTime.FixedTimeStep) { break; } if (inputBuffer.Count == 0) { WaitForInputs(h, clients, flag2); return; } h.timeSpentHalted = 0f; InputPacket[] array = inputBuffer.Dequeue(); if (h.AdaptiveInputDelayBuffer) { uint num6 = 0u; int num7 = 0; for (int k = 1; k <= 8; k++) { if (array[k].seqNumber > num6) { num6 = array[k].seqNumber; } if (previousFrame[k].targetDelayBufferSize > num7) { num7 = previousFrame[k].targetDelayBufferSize; } } if (num6 % 32 == 0 && num7 > 0) { h.targetDelayBufferSize = num7; } if (h.targetDelayBufferSize > Host.delayBufferSize) { Host.delayBufferSize++; h.BroadcastInputPacket(); h.BroadcastInputPacket(); } else if (h.targetDelayBufferSize < Host.delayBufferSize) { Host.delayBufferSize--; } else { h.BroadcastInputPacket(); } } else { h.BroadcastInputPacket(); } h.lastRebroadcastTime = Time.unscaledTime; for (int l = 1; l <= 8; l++) { Player player2 = PlayerHandler.Get().GetPlayer(l); if (player2 != null) { player2.OverrideInputWithNetworkInput(array[l]); } } previousFrame = array; try { Updater.TickSimulation(GameTime.FixedTimeStep); } catch (Exception ex) { Debug.LogError((object)("Exception caught in simulation. loading next level as recovery: e = " + ex)); h.simulationTicksPassed++; GameSessionHandler.EndGameImmediately(); return; } h.simulationTicksPassed++; if (h.broadcastChecksums && !GameSessionHandler.GameIsPaused) { h.SendChecksumToPlayer1(h.simulationTicksPassed); } if (Updater.LoadedALevelThisUpdate) { Updater.LoadedALevelThisUpdate = false; break; } } if (clients.Count > 0) { h.renderDebugText(flag2); } } private static void WaitForInputs(Host h, List<Client> clients, bool isCatchingUp) { if (h.allClientsSynced && clients.Count > 0) { h.timeSpentHalted += Time.deltaTime; float num = Time.unscaledTime - h.lastRebroadcastTime; int index = 0; for (int i = 0; i < clients.Count; i++) { if (clients[i].inputReceivedTimeStamp < clients[index].inputReceivedTimeStamp) { index = i; } } float num2 = Time.unscaledTime - clients[index].inputReceivedTimeStamp; if (num2 > 10f) { Debug.LogError((object)("Disconnecting player " + clients[index].PlayerId)); Host.disconnectedPlayerName = clients[index].steamConnection.steamName; Host.disconnectedPlayerId = clients[index].PlayerId; GameSessionHandler.LeaveGame(true, false); return; } if (num2 > 0.53333f) { if (num >= 0.25f) { h.RebroadcastLastInputPacket(); h.lastRebroadcastTime = Time.unscaledTime; } } else if (num >= 1f / 62f) { h.RebroadcastLastInputPacket(); h.lastRebroadcastTime = Time.unscaledTime; } } if (clients.Count > 0) { h.renderDebugText(isCatchingUp); } h.timePassed -= Time.deltaTime; } private static void ProcessNetworkPackets(Host h) { //IL_0110: 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_0151: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) List<Client> clients = h.clients; bool flag = true; for (int i = 0; i < clients.Count; i++) { clients[i].ProcessNetworkPackets(Time.unscaledTime, h.inputHistory, h.AdaptiveInputDelayBuffer, (byte)h.localPlayerId); flag &= clients[i].HasReceivedSyncAck; flag &= clients[i].HasSentSyncAck; } if (flag && !h.allClientsSynced) { h.allClientsSynced = true; for (int j = 0; j < Host.delayBufferSize; j++) { inputBuffer.Enqueue(NewFrame()); } } if (!h.allClientsSynced) { return; } uint num = uint.MaxValue; for (int k = 0; k < clients.Count; k++) { if (clients[k].InputPacketsReceived < num) { num = clients[k].InputPacketsReceived; } } if (h.inputPacketsSent < num) { num = h.inputPacketsSent; } int num2 = (int)num - h.UpdatesPlacedInDelayBuffer; for (int l = 0; l < num2; l++) { InputPacket[] array = NewFrame(); for (int m = 0; m < clients.Count; m++) { InputPacket val = clients[m].inputHistory.Dequeue(); int playerId = clients[m].PlayerId; if (playerId >= 1 && playerId <= 8) { array[playerId] = val; } } InputPacket val2 = h.sentPacketHistory.Dequeue(); if (h.localPlayerId >= 1 && h.localPlayerId <= 8) { array[h.localPlayerId] = val2; } inputBuffer.Enqueue(array); h.UpdatesPlacedInDelayBuffer++; } try { if (h.localPlayerId == 1) { for (int n = 0; n < clients.Count; n++) { clients[n].CheckForDesyncs(); } } } catch (Exception ex) { Debug.LogError((object)("Desync occured, ending game " + ex)); GameSessionHandler.EndGameImmediately(); } } } internal static class LobbyLayout { private const string WrapperName = "EightPlayers_Wrapper"; private const float FreeSteps = 3.4f; public static void Apply(CharacterSelectHandler_online handler) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown CSBox_online[] networkPlayerBoxes = handler.networkPlayerBoxes; int num = 7; if (networkPlayerBoxes == null || networkPlayerBoxes.Length == 0 || networkPlayerBoxes.Length >= num) { return; } Transform parent = ((Component)networkPlayerBoxes[0]).transform.parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val == (Object)null) { return; } List<RectTransform> list = new List<RectTransform>(); CSBox_online[] array = networkPlayerBoxes; foreach (CSBox_online val2 in array) { if ((Object)(object)((Component)val2).transform.parent == (Object)(object)val) { list.Add((RectTransform)((Component)val2).transform); } } List<CSBox_online> list2 = new List<CSBox_online>(networkPlayerBoxes); List<RectTransform> list3 = new List<RectTransform>(); int num2 = 0; while (list2.Count < num) { CSBox_online val3 = networkPlayerBoxes[num2 % networkPlayerBoxes.Length]; CSBox_online val4 = Object.Instantiate<CSBox_online>(val3, ((Component)val3).transform.parent); ((Object)val4).name = ((Object)val3).name + "_EP" + list2.Count; val4.isVisible = false; val4.connectedPlayer = null; CopyAnimationState(((Component)val3).gameObject, ((Component)val4).gameObject); list2.Add(val4); list3.Add((RectTransform)((Component)val4).transform); num2++; } handler.networkPlayerBoxes = list2.ToArray(); ArrangeRow(val, list, list3); Plugin.Log.LogInfo((object)$"Lobby now has {list2.Count} remote player slots."); } private static void ArrangeRow(RectTransform parent, List<RectTransform> original, List<RectTransform> clones) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0208: 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_0211: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) if (original.Count < 2) { return; } Dictionary<RectTransform, Vector2> rest = new Dictionary<RectTransform, Vector2>(); foreach (RectTransform item in original) { rest[item] = RestPosition(item); } foreach (RectTransform clone in clones) { rest[clone] = RestPosition(clone); } List<RectTransform> list = new List<RectTransform>(original); list.Sort((RectTransform a, RectTransform b) => rest[a].x.CompareTo(rest[b].x)); list.AddRange(clones); float x = rest[list[0]].x; float num = (rest[list[original.Count - 1]].x - x) / (float)(original.Count - 1); if (num <= 1f) { return; } float num2 = 0f; Rect rect; foreach (RectTransform item2 in original) { float num3 = num2; rect = item2.rect; num2 = Mathf.Max(num3, ((Rect)(ref rect)).width * Mathf.Abs(((Transform)item2).localScale.x)); } float num4 = Plugin.LobbyBoxScale.Value; if (num4 <= 0f) { num4 = (3.4f * num + num2) / ((float)(list.Count - 1) * num + num2); } num4 = Mathf.Clamp(num4, 0.3f, 1f); Plugin.Log.LogInfo((object)$"Lobby row: first x={x:0}, step={num:0}, box width={num2:0}, boxes={list.Count}, scale={num4:0.00}"); float num5 = x - num2 * 0.5f; rect = parent.rect; Vector2 center = ((Rect)(ref rect)).center; for (int num6 = 0; num6 < list.Count; num6++) { RectTransform val = list[num6]; Vector2 val2 = rest[val]; float num7 = x + (float)num6 * num; Vector2 translation = new Vector2(num5 + (num7 - num5) * num4, val2.y) - center - num4 * (val2 - center); Wrap(val, num4, translation); KeepSlideDistance(val, num4); } } private static void Wrap(RectTransform box, float scale, Vector2 translation) { //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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00e0: 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_0030: 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) Transform parent = ((Transform)box).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (!((Object)(object)val == (Object)null)) { if (((Object)val).name == "EightPlayers_Wrapper") { ((Transform)val).localScale = new Vector3(scale, scale, 1f); val.anchoredPosition = translation; return; } GameObject val2 = new GameObject("EightPlayers_Wrapper", new Type[1] { typeof(RectTransform) }); RectTransform val3 = (RectTransform)val2.transform; ((Transform)val3).SetParent((Transform)(object)val, false); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.pivot = new Vector2(0.5f, 0.5f); val3.offsetMin = Vector2.zero; val3.offsetMax = Vector2.zero; ((Transform)val3).SetSiblingIndex(((Transform)box).GetSiblingIndex()); val2.layer = ((Component)box).gameObject.layer; ((Transform)box).SetParent((Transform)(object)val3, false); ((Transform)val3).localScale = new Vector3(scale, scale, 1f); val3.anchoredPosition = translation; } } private static void KeepSlideDistance(RectTransform box, float scale) { //IL_0095: 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_00a4: 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_00c2: 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_00f5: 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) if (scale >= 0.999f) { return; } AnimateInOutUI[] components = ((Component)box).GetComponents<AnimateInOutUI>(); foreach (AnimateInOutUI val in components) { if (val.originalHeights == null || val.animatedTransforms == null || val.originalHeights.Length == 0) { continue; } float num = val.originalHeights[0]; float startHeight = val.startHeight; val.startHeight = num + (val.startHeight - num) / scale; val.endHeight = num + (val.endHeight - num) / scale; RectTransform[] animatedTransforms = val.animatedTransforms; foreach (RectTransform val2 in animatedTransforms) { if (!((Object)(object)val2 == (Object)null)) { Vector2 anchoredPosition = val2.anchoredPosition; if (val.horizontalInstead && Mathf.Abs(anchoredPosition.x - startHeight) < 0.01f) { val2.anchoredPosition = new Vector2(val.startHeight, anchoredPosition.y); } else if (!val.horizontalInstead && Mathf.Abs(anchoredPosition.y - startHeight) < 0.01f) { val2.anchoredPosition = new Vector2(anchoredPosition.x, val.startHeight); } } } } } private static Vector2 RestPosition(RectTransform r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_0068: Unknown result type (might be due to invalid IL or missing references) Vector2 result = Vector2.op_Implicit(((Transform)r).localPosition); AnimateInOutUI[] components = ((Component)r).GetComponents<AnimateInOutUI>(); foreach (AnimateInOutUI val in components) { if (val.originalHeights == null || val.animatedTransforms == null) { continue; } int num = Array.IndexOf(val.animatedTransforms, r); if (num >= 0 && num < val.originalHeights.Length) { if (val.horizontalInstead) { result.x += val.originalHeights[num] - r.anchoredPosition.x; } else { result.y += val.originalHeights[num] - r.anchoredPosition.y; } } } return result; } private static void CopyAnimationState(GameObject source, GameObject clone) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) AnimateInOutUI[] componentsInChildren = source.GetComponentsInChildren<AnimateInOutUI>(true); AnimateInOutUI[] componentsInChildren2 = clone.GetComponentsInChildren<AnimateInOutUI>(true); for (int i = 0; i < componentsInChildren.Length && i < componentsInChildren2.Length; i++) { if (componentsInChildren[i].originalHeights != null) { componentsInChildren2[i].originalHeights = (float[])componentsInChildren[i].originalHeights.Clone(); } if (componentsInChildren[i].animatedTransforms == null || componentsInChildren2[i].animatedTransforms == null) { continue; } for (int j = 0; j < componentsInChildren[i].animatedTransforms.Length && j < componentsInChildren2[i].animatedTransforms.Length; j++) { if ((Object)(object)componentsInChildren[i].animatedTransforms[j] != (Object)null && (Object)(object)componentsInChildren2[i].animatedTransforms[j] != (Object)null) { componentsInChildren2[i].animatedTransforms[j].anchoredPosition = componentsInChildren[i].animatedTransforms[j].anchoredPosition; } } } } } [HarmonyPatch] internal static class NetPatches { private static float nextLimitCheck; private const string VersionKey = "EightPlayers"; private static ulong warnedLobby; private static readonly byte[] receiveBuffer = new byte[2048]; private const byte InGameAckFlag = 128; private static bool encodingInGameAck; [HarmonyPostfix] [HarmonyPatch(typeof(SteamManager), "Update")] private static void SteamManager_Update(SteamManager __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!(Time.unscaledTime < nextLimitCheck) && SteamClient.IsValid) { nextLimitCheck = Time.unscaledTime + 2f; Plugin.RaiseLobbyLimit(__instance.currentLobby); CheckModVersion(__instance); } } private static void CheckModVersion(SteamManager manager) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) try { Lobby currentLobby = manager.currentLobby; SteamId id = ((Lobby)(ref currentLobby)).Id; if (!((SteamId)(ref id)).IsValid) { return; } string data = ((Lobby)(ref currentLobby)).GetData("EightPlayers"); if (((Lobby)(ref currentLobby)).IsOwnedBy(SteamClient.SteamId)) { if (data != "1.2.0") { ((Lobby)(ref currentLobby)).SetData("EightPlayers", "1.2.0"); } } else if (!(data == "1.2.0") && warnedLobby != ((Lobby)(ref currentLobby)).Id.Value && GameSession.inMenus) { warnedLobby = ((Lobby)(ref currentLobby)).Id.Value; if (string.IsNullOrEmpty(data)) { Plugin.Log.LogWarning((object)"The lobby host does not seem to have EightPlayers installed. Do not pick teams 5-8 or the new colors in this lobby."); return; } Plugin.Log.LogError((object)("EightPlayers version mismatch: you have 1.2.0, the host has " + data + ". Leaving the lobby.")); ErrorHandlingTextDisconnect.SetMainMenuLogMessage("EightPlayers version mismatch\nYou have 1.2.0\nThe host has " + data); manager.LeaveLobby(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Mod version check failed: " + ex.Message)); } } [HarmonyPrefix] [HarmonyPatch(typeof(SteamManager), "HostGame")] private static void SteamManager_HostGame(SteamManager __instance) { List<SteamConnection> connectedPlayers = __instance.connectedPlayers; ExtStart.FillFromLobby(__instance.nextStartGameSeq, connectedPlayers); if (ExtStart.Valid) { ExtStart.Broadcast(connectedPlayers); Plugin.Log.LogInfo((object)$"Hosting a {connectedPlayers.Count + 1} player game."); } } [HarmonyPrefix] [HarmonyPatch(typeof(SteamManager), "HostNextLevel")] private static void SteamManager_HostNextLevel(SteamManager __instance) { //IL_0000: 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) if (!ExtStart.AppliesTo(SteamManager.startParameters)) { return; } List<SteamConnection> connectedPlayers = __instance.connectedPlayers; foreach (Player item in PlayerHandler.Get().PlayerList()) { if (item.Id < 5 || item.Id > 8) { continue; } foreach (SteamConnection item2 in connectedPlayers) { if (item2.id.Value == item.steamId.Value) { ExtStart.Ab1[item.Id] = item2.lobby_ability1; ExtStart.Ab2[item.Id] = item2.lobby_ability2; ExtStart.Ab3[item.Id] = item2.lobby_ability3; break; } } } ExtStart.Broadcast(connectedPlayers); } [HarmonyPrefix] [HarmonyPatch(typeof(SteamManager), "ForceLoadNextLevel")] private static void SteamManager_ForceLoadNextLevel() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) StartRequestPacket startParameters = SteamManager.startParameters; if (!ExtStart.AppliesTo(startParameters)) { return; } foreach (Player item in PlayerHandler.Get().PlayerList()) { int id = item.Id; if (id >= 5 && id <= 8) { SteamManager.ChangePlayerAbilites(item, ExtStart.Ab1[id], ExtStart.Ab2[id], ExtStart.Ab3[id], (int)startParameters.nrOfAbilites, SteamManager.instance.abilityIcons); } } } [HarmonyPrefix] [HarmonyPatch(typeof(SteamManager), "InitNetworkClient")] private static bool SteamManager_InitNetworkClient(SteamManager __instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0068: Expected O, but got Unknown StartRequestPacket startParameters = SteamManager.startParameters; if (!ExtStart.AppliesTo(startParameters)) { return true; } int num = ExtStart.LocalPlayerId(startParameters); List<Client> list = new List<Client>(); foreach (SteamConnection connectedPlayer in __instance.connectedPlayers) { for (int i = 1; i <= 8; i++) { if (i <= startParameters.nrOfPlayers && connectedPlayer.id.Value == ExtStart.SteamIdOf(startParameters, i)) { list.Add(new Client(i, connectedPlayer)); break; } } } __instance.networkClient.Init(list, num, startParameters.currentLevel, __instance.startFrameBuffer, __instance.checkForDesyncs); SteamManager.networkClientHandle = __instance.networkClient; return false; } [HarmonyPrefix] [HarmonyPatch(typeof(CharacterSelectHandler_online), "ForceStartGame")] private static bool CharacterSelectHandler_online_ForceStartGame(PlayerColors pcs) { //IL_0005: 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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Palette.ExtendLoadedAssets(); StartRequestPacket startParameters = SteamManager.startParameters; if (GameLobby.isPlayingAReplay || !ExtStart.AppliesTo(startParameters)) { return true; } if ((Object)(object)pcs == (Object)null) { pcs = CharacterSelectHandler_online.selfRef.playerColors; } Updater.ReInit(); Updater.InitSeed(startParameters.seed); List<Player> list = new List<Player>(); int num = 0; for (int i = 1; i <= 8; i++) { ExtStart.GetSlot(startParameters, i, out var _, out var color, out var team, out var a, out var a2, out var a3); if (a != 0 && startParameters.nrOfPlayers > num) { list.Add(CharacterSelectHandler_online.InitPlayer(i, color, team, a, a2, a3, (int)startParameters.nrOfAbilites, pcs)); num++; } } int num2 = ExtStart.LocalPlayerId(startParameters); Player val = null; foreach (Player item in list) { item.steamId = SteamId.op_Implicit(ExtStart.SteamIdOf(startParameters, item.Id)); if (item.Id == num2) { val = item; } } if (val == null) { Plugin.Log.LogError((object)"Local player is missing from the start request; falling back to the game's own handling."); return true; } val.IsLocalPlayer = true; val.inputDevice = CharacterSelectHandler_online.localPlayerInit.inputDevice; val.UsesKeyboardAndMouse = CharacterSelectHandler_online.localPlayerInit.usesKeyboardMouse; val.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(); SceneManager.LoadScene("Level1"); if (!WinnerTriangleCanvas.HasBeenSpawned) { SceneManager.LoadScene("winnerTriangle", (LoadSceneMode)1); } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(Client), "SendAck")] private static void Client_SendAck(ref byte localPlayerId) { if (localPlayerId > 4 && localPlayerId <= 8) { localPlayerId |= 128; } } [HarmonyPrefix] [HarmonyPatch(typeof(Host), "ReadPacket")] private static void Host_ReadPacketPrefix() { encodingInGameAck = true; } [HarmonyFinalizer] [HarmonyPatch(typeof(Host), "ReadPacket")] private static void Host_ReadPacketFinalizer() { encodingInGameAck = false; } [HarmonyPostfix] [HarmonyPatch(typeof(NetworkTools), "EncodeAckForNetwork")] private static void NetworkTools_EncodeAckForNetwork(byte[] data) { if (encodingInGameAck && data[0] > 4 && data[0] <= 8) { data[0] |= 128; } } [HarmonyPrefix] [HarmonyPatch(typeof(SteamSocket), "OnMessage")] private static bool SteamSocket_OnMessage(NetIdentity identity, IntPtr data, int size) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (size != 6 && size != 59) { return true; } SteamId steamId = ((NetIdentity)(ref identity)).SteamId; if (!((SteamId)(ref steamId)).IsValid || (Object)(object)SteamManager.instance == (Object)null) { return true; } Marshal.Copy(data, receiveBuffer, 0, size); SteamId steamId2 = ((NetIdentity)(ref identity)).SteamId; if (size == 6) { if ((receiveBuffer[0] & 0x80) == 0) { return true; } byte b = (byte)(receiveBuffer[0] & -129); Host networkClientHandle = SteamManager.networkClientHandle; if (b > 4 && b <= 8 && (Object)(object)networkClientHandle != (Object)null && networkClientHandle.hasBeenInitialized && HostExt.HasClient(networkClientHandle, steamId2, b)) { receiveBuffer[0] = b; networkClientHandle.ReadPacket(receiveBuffer, size); } return false; } if (!ExtStart.IsExtPacket(receiveBuffer, size)) { return true; } Lobby currentLobby = SteamManager.instance.currentLobby; Friend val = new Friend(steamId2); if (((Friend)(ref val)).IsIn(((Lobby)(ref currentLobby)).Id) && ((Lobby)(ref currentLobby)).IsOwnedBy(steamId2)) { ExtStart.Decode(receiveBuffer, steamId2.Value); } return false; } } internal static class Palette { private static readonly float[] CandidateHues = new float[12] { 0.78f, 0.5f, 0.92f, 0.08f, 0.36f, 0.62f, 0.16f, 0f, 0.85f, 0.44f, 0.7f, 0.27f }; private static List<PlayerColor> createdPlayerColors; private static List<TeamColor> createdTeamColors; public static void ExtendLoadedAssets() { TeamColors[] array = Resources.FindObjectsOfTypeAll<TeamColors>(); for (int i = 0; i < array.Length; i++) { ExtendTeams(array[i]); } PlayerColors[] array2 = Resources.FindObjectsOfTypeAll<PlayerColors>(); for (int i = 0; i < array2.Length; i++) { ExtendColors(array2[i]); } BeamColorList[] array3 = Resources.FindObjectsOfTypeAll<BeamColorList>(); for (int i = 0; i < array3.Length; i++) { ExtendBeamColors(array3[i]); } } private static void ExtendBeamColors(BeamColorList beams) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)beams == (Object)null || beams.beamColors == null || beams.beamColors.Length == 0) { return; } int num = 8; PlayerColors[] array = Resources.FindObjectsOfTypeAll<PlayerColors>(); foreach (PlayerColors val in array) { if ((Object)(object)val != (Object)null && val.playerColors != null) { num = Mathf.Max(num, val.playerColors.Length); } } int num2 = beams.beamColors.Length; if (num2 < num) { List<BeamColors> list = new List<BeamColors>(beams.beamColors); while (list.Count < num) { list.Add(beams.beamColors[num2 - 1]); } beams.beamColors = list.ToArray(); Plugin.Log.LogInfo((object)$"Extended beam colors '{((Object)beams).name}' from {num2} to {num}."); } } private static void ExtendTeams(TeamColors teams) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_00b4: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00d0: 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_00dc: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)teams == (Object)null || teams.teamColors == null || teams.teamColors.Length == 0 || teams.teamColors.Length >= 8) { return; } int num = teams.teamColors.Length; if (createdTeamColors == null) { List<float> list = new List<float>(); TeamColor[] teamColors = teams.teamColors; foreach (TeamColor val in teamColors) { AddHue(list, val.fill); } TeamColor val2 = teams.teamColors[0]; createdTeamColors = new List<TeamColor>(); foreach (float item2 in PickHues(list, 8 - num)) { createdTeamColors.Add(new TeamColor { fill = WithHue(val2.fill, item2), border = WithHue(val2.border, item2), saturated = WithHue(val2.saturated, item2) }); } } List<TeamColor> list2 = new List<TeamColor>(teams.teamColors); int num2 = 0; while (list2.Count < 8 && num2 < createdTeamColors.Count) { TeamColor item = createdTeamColors[num2]; item.team = list2.Count; list2.Add(item); num2++; } teams.teamColors = list2.ToArray(); Plugin.Log.LogInfo((object)$"Extended team colors '{((Object)teams).name}' from {num} to {teams.teamColors.Length}."); } private static void ExtendColors(PlayerColors colors) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0093: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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) if ((Object)(object)colors == (Object)null || colors.playerColors == null || colors.playerColors.Length == 0 || colors.playerColors.Length >= 8) { return; } int num = colors.playerColors.Length; if (createdPlayerColors == null) { List<float> list = new List<float>(); PlayerColor[] playerColors = colors.playerColors; foreach (PlayerColor val in playerColors) { if ((Object)(object)val.playerMaterial != (Object)null) { AddHue(list, KeyColor(val.playerMaterial)); } } PlayerColor val2 = colors.playerColors[0]; float num2 = HueOf(KeyColor(val2.playerMaterial)); createdPlayerColors = new List<PlayerColor>(); int num3 = 0; foreach (float item3 in PickHues(list, 8 - num)) { float shift = item3 - num2; PlayerColor item = new PlayerColor { playerMaterial = ShiftedCopy(val2.playerMaterial, shift, "EightPlayers_Player_" + num3), uiMaterial = ShiftedCopy(val2.uiMaterial, shift, "EightPlayers_UI_" + num3) }; createdPlayerColors.Add(item); num3++; } } List<PlayerColor> list2 = new List<PlayerColor>(colors.playerColors); int num4 = 0; while (list2.Count < 8 && num4 < createdPlayerColors.Count) { PlayerColor item2 = createdPlayerColors[num4]; item2.colorIndex = list2.Count; list2.Add(item2); num4++; } colors.playerColors = list2.ToArray(); Plugin.Log.LogInfo((object)$"Extended player colors '{((Object)colors).name}' from {num} to {colors.playerColors.Length}."); } private static IEnumerable<float> PickHues(List<float> existing, int count) { List<float> taken = new List<float>(existing); List<float> remaining = new List<float>(CandidateHues); for (int i = 0; i < count; i++) { if (remaining.Count <= 0) { break; } int index = 0; float num = -1f; for (int j = 0; j < remaining.Count; j++) { float num2 = MinHueDistance(remaining[j], taken); if (num2 > num + 0.0001f) { num = num2; index = j; } } float num3 = remaining[index]; remaining.RemoveAt(index); taken.Add(num3); yield return num3; } } private static float MinHueDistance(float hue, List<float> others) { float num = 1f; foreach (float other in others) { float num2 = Mathf.Abs(hue - other); num2 = Mathf.Min(num2, 1f - num2); num = Mathf.Min(num, num2); } return num; } private static void AddHue(List<float> hues, Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) float item = default(float); float num = default(float); float num2 = default(float); Color.RGBToHSV(c, ref item, ref num, ref num2); if (num > 0.15f && num2 > 0.1f) { hues.Add(item); } } private static float HueOf(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) float result = default(float); float num = default(float); float num2 = default(float); Color.RGBToHSV(c, ref result, ref num, ref num2); return result; } private static Color KeyColor(Material m) { //IL_0009: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m == (Object)null) { return Color.white; } if (m.HasProperty("_MainColor")) { return m.GetColor("_MainColor"); } if (m.HasProperty("_ShadowColor")) { return m.GetColor("_ShadowColor"); } if (!m.HasProperty("_Color")) { return Color.white; } return m.color; } private static Color WithHue(Color c, float hue) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(c, ref num, ref num2, ref num3); Color result = Color.HSVToRGB(hue, num2, num3); result.a = c.a; return result; } private static Color ShiftHue(Color c, float shift) { //IL_0000: 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_0030: 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_0014: Unknown result type (might be due to invalid IL or missing references) float num2 = default(float); float num3 = default(float); float num = default(float); Color.RGBToHSV(c, ref num, ref num2, ref num3); if (num2 < 0.05f) { return c; } num = Mathf.Repeat(num + shift, 1f); Color result = Color.HSVToRGB(num, num2, num3, true); result.a = c.a; return result; } private static Material ShiftedCopy(Material source, float shift, string name) { //IL_000c: 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_0019: Expected O, but got Unknown //IL_003b: 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_0057: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null) { return null; } Material val = new Material(source) { name = name }; Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)32; Shader shader = val.shader; int propertyCount = shader.GetPropertyCount(); for (int i = 0; i < propertyCount; i++) { if ((int)shader.GetPropertyType(i) == 0) { string propertyName = shader.GetPropertyName(i); val.SetColor(propertyName, ShiftHue(val.GetColor(propertyName), shift)); } } return val; } } [BepInPlugin("com.eightplayers.boplbattle", "EightPlayers", "1.2.0")] [BepInProcess("BoplBattle.exe")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.eightplayers.boplbattle"; public const string Name = "EightPlayers"; public const string Version = "1.2.0"; public const int MaxPlayers = 8; public const int MaxTeams = 8; internal static ManualLogSource Log; internal static ConfigEntry<float> LobbyBoxScale; private Harmony harmony; private void Awake() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; LobbyBoxScale = ((BaseUnityPlugin)this).Config.Bind<float>("Lobby UI", "BoxScaleOverride", 0f, "Scale of the character boxes in the online lobby (0.3 - 1.0). 0 = pick automatically so the 7 remote player boxes fit next to yours."); Constants.MAX_PLAYERS = 8; harmony = new Harmony("com.eightplayers.boplbattle"); harmony.PatchAll(typeof(Plugin).Assembly); SceneManager.sceneLoaded += OnSceneLoaded; SteamMatchmaking.OnLobbyCreated += OnLobbyCreated; Palette.ExtendLoadedAssets(); Log.LogInfo((object)string.Format("{0} {1} loaded: online lobbies support up to {2} players and {3} teams.", "EightPlayers", "1.2.0", 8, 8)); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; SteamMatchmaking.OnLobbyCreated -= OnLobbyCreated; } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { Palette.ExtendLoadedAssets(); } private static void OnLobbyCreated(Result result, Lobby lobby) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) if ((int)result == 1) { RaiseLobbyLimit(lobby); } } internal static void RaiseLobbyLimit(Lobby lobby) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) try { SteamId id = ((Lobby)(ref lobby)).Id; if (((SteamId)(ref id)).IsValid && ((Lobby)(ref lobby)).IsOwnedBy(SteamClient.SteamId) && ((Lobby)(ref lobby)).MaxMembers < 8) { ((Lobby)(ref lobby)).MaxMembers = 8; Log.LogInfo((object)$"Raised lobby member limit to {8}."); } } catch (Exception ex) { Log.LogWarning((object)("Could not raise lobby member limit: " + ex.Message)); } } } internal static class SpawnPlanner { private struct Platform { public Vec2 center; public Vec2 right; public Vec2 up; public Fix ex; public Fix ey; public Fix radius; public bool spawnable; public Fix keepAway; } internal enum PlatformKind { Normal, NoSpawn, Hazard } private static Vec2[] plan; private static int planIndex; internal static PlatformKind Classify(string name, string tag) { if (tag == "boulder") { return PlatformKind.Hazard; } if (name != null && name.StartsWith("PoyrazMod_", StringComparison.Ordinal)) { if (name.StartsWith("PoyrazMod_DeepMine", StringComparison.Ordinal)) { return PlatformKind.Hazard; } if (name.EndsWith("_Vent", StringComparison.Ordinal) || name.EndsWith("_Tentacle", StringComparison.Ordinal)) { return PlatformKind.Hazard; } if (name.EndsWith("_Seabed", StringComparison.Ordinal) || name.EndsWith("_DeepSand", StringComparison.Ordinal)) { return PlatformKind.NoSpawn; } } return PlatformKind.Normal; } internal static bool IsSwimLevelObject(string name) { return name?.StartsWith("PoyrazMod_Aqua_", StringComparison.Ordinal) ?? false; } public static Vec2[] ExtendTeamSpawns(GameSessionHandler h) { //IL_0007: 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_0017: 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_001f: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vec2[] teamSpawns = h.teamSpawns; Fix teammateSpawnSpacing = h.teammateSpawnSpacing; bool swimLevel; List<Platform> platforms = ReadPlatforms(h, out swimLevel); return ComputeSites(teamSpawns, platforms, teammateSpawnSpacing, (int)h.levelType == 2, swimLevel, SceneBounds.WaterHeight); } private static Vec2[] ComputeSites(Vec2[] vanilla, List<Platform> platforms, Fix spacing, bool spaceLevel, bool swimLevel, Fix waterHeight) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_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_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) //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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_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_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_0086: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d0: 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_00ea: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0169: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01b1: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: 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_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: 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_025b: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) int num = vanilla.Length; List<Vec2> list = new List<Vec2>(vanilla); Fix clearance = SpawnClearance(vanilla, platforms); Fix val = (Fix)4L; Fix val2 = waterHeight + val; Fix item = SceneBounds.Camera_YMin + val; bool flag = false; Vec2[] array = vanilla; foreach (Vec2 val3 in array) { flag |= val3.y < val2; } List<Fix> list2 = new List<Fix>(); if (!flag) { list2.Add(val2); } if (flag || swimLevel) { list2.Add(item); } Fix val4 = vanilla[0].x; Fix val5 = vanilla[0].x; array = vanilla; foreach (Vec2 val6 in array) { val4 = Fix.Min(val4, val6.x); val5 = Fix.Max(val5, val6.x); } Fix val7 = Fix.Max((val5 - val4) * (Fix)0.5f, (Fix)15L); val4 = Fix.Max(val4 - val7, SceneBounds.Camera_XMin + val); val5 = Fix.Min(val5 + val7, SceneBounds.Camera_XMax - val); int num2 = 0; List<KeyValuePair<Fix, Fix>> list3 = new List<KeyValuePair<Fix, Fix>>(); foreach (Fix item2 in list2) { list3.Add(new KeyValuePair<Fix, Fix>(item2, spacing * (Fix)8L)); } foreach (Fix item3 in list2) { list3.Add(new KeyValuePair<Fix, Fix>(item3, spacing * (Fix)3L)); } foreach (KeyValuePair<Fix, Fix> item4 in list3) { Fix val8 = item4.Value * item4.Value; List<Vec2> list4 = Candidates(platforms, clearance, spacing, spaceLevel, item4.Key, val4, val5); while (list.Count < 8) { int num3 = -1; Fix val9 = Fix.Zero; for (int j = 0; j < list4.Count; j++) { Fix val10 = MinDistSqr(list4[j], list); if (num3 < 0 || val10 > val9) { num3 = j; val9 = val10; } } if (num3 < 0 || val9 < val8) { break; } list.Add(list4[num3]); list4.RemoveAt(num3); num2++; } } for (int k = list.Count; k < 8; k++) { Vec2 val11 = vanilla[k % num]; Fix val12 = spacing * (Fix)(3L * (long)(k / num)); list.Add(new Vec2(val11.x - val12, val11.y)); } Plugin.Log.LogInfo((object)$"Spawns: {num2} extra spawn point(s) placed on platforms, {8 - num - num2} beside existing spawns."); return list.ToArray(); } private static List<Platform> ReadPlatforms(GameSessionHandler h, out bool swimLevel) { //IL_006a: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0084: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00c4: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) List<Platform> list = new List<Platform>(); swimLevel = false; StickyRoundedRectangle[] grounds = h.grounds; if (grounds == null) { return list; } Vec2 val2 = default(Vec2); Vec2 up = default(Vec2); for (int i = 0; i < grounds.Length; i++) { StickyRoundedRectangle val = grounds[i]; if (!((Object)(object)val == (Object)null) && !((MonoUpdatable)val).IsDestroyed) { DPhysicsRoundedRect component = ((Component)val).GetComponent<DPhysicsRoundedRect>(); FixTransform component2 = ((Component)val).GetComponent<FixTransform>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null)) { ((Vec2)(ref val2))..ctor(h.startRotations[i]); ((Vec2)(ref up))..ctor(-val2.y, val2.x); Vec2 val3 = component.CalcExtents(); string name = ((Object)((Component)val).gameObject).name; swimLevel |= IsSwimLevelObject(name); list.Add(MakePlatform(h.targetPositions[i] + Vec2.ComplexMul(component2.offset, val2), val2, up, Fix.Abs(val3.x), Fix.Abs(val3.y), component.radius, Classify(name, ((Component)val).gameObject.tag))); } } } return list; } private static Platform MakePlatform(Vec2 center, Vec2 right, Vec2 up, Fix ex, Fix ey, Fix radius, PlatformKind kind) { //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_0003: 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) //IL_0014: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_003a: 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_004b: 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_0054: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) bool flag = Fix.Max(ex, ey) + radius < (Fix)1.5f; return new Platform { center = center, right = right, up = up, ex = ex, ey = ey, radius = radius, spawnable = (kind == PlatformKind.Normal && !flag), keepAway = ((kind == PlatformKind.Hazard) ? ((Fix)4L) : Fix.Zero) }; } private static Fix Distance(Platform p, Vec2 point) { //IL_0000: 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_0007: 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_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) //IL_0018: 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_0023: 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_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_0034: 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_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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0095: 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_009c: 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) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Vec2 val = point - p.center; Fix val2 = Fix.Abs(Vec2.Dot(val, p.right)) - p.ex; Fix val3 = Fix.Abs(Vec2.Dot(val, p.up)) - p.ey; Fix val4 = Fix.Max(val2, Fix.Zero); Fix val5 = Fix.Max(val3, Fix.Zero); Fix val6 = val4 * val4 + val5 * val5; Fix val7 = ((val6 > Fix.Zero) ? Fix.Sqrt(val6) : Fix.Zero); Fix val8 = Fix.Min(Fix.Max(val2, val3), Fix.Zero); return val7 + val8 - p.radius; } private static Fix SpawnClearance(Vec2[] vanilla, List<Platform> platforms) { //IL_0005: 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) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0024: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0065: 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) Fix val = (Fix)0.75f; Fix val2 = (Fix)4L; bool flag = false; foreach (Vec2 point in vanilla) { foreach (Platform platform in platforms) { if (platform.spawnable) { Fix val3 = Distance(platform, point); if (val3 > Fix.Zero && val3 < val2) { val2 = val3; flag = true; } } } } if (!flag) { return (Fix)1.5f; } return Fix.Max(val2, val); } private static List<Vec2> Candidates(List<Platform> platforms, Fix clearance, Fix spacing, bool spaceLevel, Fix floor, Fix minX, Fix maxX) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_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_001f: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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) //IL_00e3: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: 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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: 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_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027c: 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_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) List<Vec2> list = new List<Vec2>(); Fix val = (Fix)4L; Fix val2 = (Fix)0.95f; Fix val3 = clearance * (Fix)0.9f; List<Fix> list2 = new List<Fix>(); Vec2 val11 = default(Vec2); for (int i = 0; i < platforms.Count; i++) { Platform platform = platforms[i]; if (!platform.spawnable) { continue; } for (int num = 0; num < 4; num++) { Vec2 val4 = (Vec2)(num switch { 2 => new Vec2(-platform.up.x, -platform.up.y), 1 => platform.right, 0 => platform.up, _ => new Vec2(-platform.right.x, -platform.right.y), }); int num2; Vec2 val5; if (num != 0) { num2 = ((num == 2) ? 1 : 0); if (num2 == 0) { val5 = platform.up; goto IL_00e8; } } else { num2 = 1; } val5 = platform.right; goto IL_00e8; IL_00e8: Vec2 val6 = val5; Fix val7 = ((num2 != 0) ? platform.ex : platform.ey); Fix val8 = ((num2 != 0) ? platform.ey : platform.ex); if (spaceLevel || !(val4.y < val2)) { list2.Clear(); list2.Add(Fix.Zero); Fix val9 = val7 - spacing; if (val9 > spacing) { list2.Add(val9); list2.Add(-val9); } if (val9 > spacing * (Fix)4L) { list2.Add(val9 * (Fix)0.5f); list2.Add(-val9 * (Fix)0.5f); } Fix val10 = val8 + platform.radius + clearance; foreach (Fix item in list2) { ((Vec2)(ref val11))..ctor(platform.center.x + val4.x * val10 + val6.x * item, platform.center.y + val4.y * val10 + val6.y * item); if (val11.x < minX || val11.x > maxX || val11.y > SceneBounds.Camera_YMax - val || val11.y < floor) { continue; } bool flag = false; for (int j = 0; j < platforms.Count; j++) { if (flag) { break; } flag = j != i && Distance(platforms[j], val11) < val3 + platforms[j].keepAway; } if (!flag) { list.Add(val11); } } } } } return list; } private static Fix MinDistSqr(Vec2 point, List<Vec2> others) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //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_0023: 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_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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_003a: 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_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due t