Decompiled source of Boosters v0.5.2
Boosters.dll
Decompiled 3 days 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.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using CellMenu; using DropServer.BoosterImplants; using GameData; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Collections.ObjectModel; using Il2CppSystem.Reflection; using InControl; using Microsoft.CodeAnalysis; using SNetwork; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Boosters")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e6d14461281b54e2af6268f2d8c923cb1c7a114d")] [assembly: AssemblyProduct("Boosters")] [assembly: AssemblyTitle("Boosters")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [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 Boosters { internal static class Art { private static Texture2D _sheetTex; private static Texture2D _dotTex; private static Texture2D _starTex; private static Texture2D _ringTex; private static Sprite _sheet; private static Sprite _dot; private static Sprite _star; private static Sprite _ring; private static Material _material; private static bool _warned; private static readonly float[] Px = new float[10]; private static readonly float[] Py = new float[10]; private static bool _points; public static Material Material { get { //IL_0045: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if (!Gone((Object)(object)_material)) { return _material; } Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { if (!_warned) { Plugin.L.LogWarning((object)"organizer: Unity's sprite shader not found; the page's sheets use the game's sprite material"); } _warned = true; return null; } _material = new Material(val) { hideFlags = (HideFlags)61, name = "Boosters sprites" }; return _material; } } private static bool Gone(Object o) { if (!(o == (Object)null)) { return ((Il2CppObjectBase)o).WasCollected; } return true; } public static Sprite Sheet() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (Gone((Object)(object)_sheetTex)) { _sheetTex = Texture(32, 32, RoundRect, "sheet"); _sheet = null; } if (Gone((Object)(object)_sheet)) { _sheet = Make(_sheetTex, 3f, new Vector4(12f, 12f, 12f, 12f)); } return _sheet; } public static Sprite Dot() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (Gone((Object)(object)_dotTex)) { _dotTex = Texture(4, 4, (int _, int _) => 1f, "dot"); _dot = null; } if (Gone((Object)(object)_dot)) { _dot = Make(_dotTex, 4f, Vector4.zero); } return _dot; } public static Sprite Star(bool filled) { //IL_00cc: 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) if (filled) { if (Gone((Object)(object)_starTex)) { _starTex = Texture(64, 64, (int x, int y) => StarAt(x, y, outline: false), "star"); _star = null; } if (Gone((Object)(object)_star)) { _star = Make(_starTex, 64f, Vector4.zero); } return _star; } if (Gone((Object)(object)_ringTex)) { _ringTex = Texture(64, 64, (int x, int y) => StarAt(x, y, outline: true), "star outline"); _ring = null; } if (Gone((Object)(object)_ring)) { _ring = Make(_ringTex, 64f, Vector4.zero); } return _ring; } public static Color Hex(string hex, float a = 1f) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) uint num = Convert.ToUInt32(hex.TrimStart('#'), 16); return new Color((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f, (float)(num & 0xFF) / 255f, a); } public static SpriteRenderer Renderer(Transform parent, string name, Sprite sprite, Color color, int layer, int sortingLayer, int order) { //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_000e: 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) GameObject val = new GameObject(name) { layer = layer }; val.transform.SetParent(parent, false); SpriteRenderer val2 = val.AddComponent<SpriteRenderer>(); val2.sprite = sprite; Material material = Material; if ((Object)(object)material != (Object)null) { ((Renderer)val2).sharedMaterial = material; } val2.color = color; ((Renderer)val2).sortingLayerID = sortingLayer; ((Renderer)val2).sortingOrder = order; return val2; } public static TextMeshPro Text(TextMeshPro template, Transform parent, string name, int layer, int sortingLayer, int order) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent); ((Object)val).name = name; val.layer = layer; val.SetActive(true); for (int num = val.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)val.transform.GetChild(num)).gameObject); } foreach (MonoBehaviour component3 in val.GetComponents<MonoBehaviour>()) { if ((Object)(object)component3 != (Object)null && (Object)(object)((Il2CppObjectBase)component3).TryCast<TextMeshPro>() == (Object)null) { Object.Destroy((Object)(object)component3); } } TextMeshPro component = val.GetComponent<TextMeshPro>(); ((TMP_Text)component).richText = true; ((Graphic)component).color = Color.white; ((TMP_Text)component).text = ""; MeshRenderer component2 = val.GetComponent<MeshRenderer>(); if ((Object)(object)component2 != (Object)null) { ((Renderer)component2).sortingLayerID = sortingLayer; ((Renderer)component2).sortingOrder = order; } return component; } public static void Layer(GameObject root, int layer) { if ((Object)(object)root == (Object)null) { return; } foreach (Transform componentsInChild in root.GetComponentsInChildren<Transform>(true)) { ((Component)componentsInChild).gameObject.layer = layer; } } private static Texture2D Texture(int w, int h, Func<int, int, float> alpha, string name) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0092: 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_00a0: 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_00b5: Expected O, but got Unknown byte[] array = new byte[w * h * 4]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int num = (i * w + j) * 4; int num2 = num + 1; byte b; array[num + 2] = (b = byte.MaxValue); array[num] = (array[num2] = b); array[num + 3] = (byte)Math.Round(Math.Clamp(alpha(j, i), 0f, 1f) * 255f); } } Texture2D val = new Texture2D(w, h, (TextureFormat)4, false) { name = "Boosters " + name, hideFlags = (HideFlags)61, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; val.LoadRawTextureData(Il2CppStructArray<byte>.op_Implicit(array)); val.Apply(false, true); return val; } private static Sprite Make(Texture2D t, float ppu, Vector4 border) { //IL_0019: 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_0030: Unknown result type (might be due to invalid IL or missing references) Sprite obj = Sprite.Create(t, new Rect(0f, 0f, (float)((Texture)t).width, (float)((Texture)t).height), new Vector2(0.5f, 0.5f), ppu, 0u, (SpriteMeshType)0, border); ((Object)obj).hideFlags = (HideFlags)61; return obj; } private static float RoundRect(int x, int y) { float num = (float)x + 0.5f; float num2 = (float)y + 0.5f; float num3 = Math.Max(Math.Max(10f - num, num - 22f), 0f); float num4 = Math.Max(Math.Max(10f - num2, num2 - 22f), 0f); float num5 = (float)Math.Sqrt(num3 * num3 + num4 * num4); return Math.Clamp(10f - num5 + 0.5f, 0f, 1f); } private static float StarAt(int x, int y, bool outline) { int num = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { float u = ((float)x + ((float)j + 0.5f) / 4f) / 64f - 0.5f; float v = ((float)y + ((float)i + 0.5f) / 4f) / 64f - 0.5f; if (InStar(u, v) && (!outline || EdgeDistance(u, v) < 0.075f)) { num++; } } } return (float)num / 16f; } private static void Points() { if (!_points) { _points = true; for (int i = 0; i < 10; i++) { double num = Math.PI / 2.0 + (double)i * Math.PI / 5.0; double num2 = ((i % 2 == 0) ? 0.48 : 0.2); Px[i] = (float)(Math.Cos(num) * num2); Py[i] = (float)(Math.Sin(num) * num2 - 0.025); } } } private static bool InStar(float u, float v) { Points(); bool flag = false; int num = 0; int num2 = 9; while (num < 10) { if (Py[num] > v != Py[num2] > v && u < (Px[num2] - Px[num]) * (v - Py[num]) / (Py[num2] - Py[num]) + Px[num]) { flag = !flag; } num2 = num++; } return flag; } private static float EdgeDistance(float u, float v) { Points(); float num = float.MaxValue; int num2 = 0; int num3 = 9; while (num2 < 10) { float num4 = Px[num3]; float num5 = Py[num3]; float num6 = Px[num2] - num4; float num7 = Py[num2] - num5; float num8 = Math.Clamp(((u - num4) * num6 + (v - num5) * num7) / (num6 * num6 + num7 * num7), 0f, 1f); float num9 = u - (num4 + num8 * num6); float num10 = v - (num5 + num8 * num7); num = Math.Min(num, (float)Math.Sqrt(num9 * num9 + num10 * num10)); num3 = num2++; } return num; } } internal static class Inventory { [HarmonyPatch(typeof(PersistentInventoryManager), "OnLevelCleanup")] private static class AfterLevel { private static void Postfix() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown try { if (Settings.AnyEquipped) { Settings.ForgetEquipped(); if (_said++ < 30) { Plugin.L.LogInfo((object)"boosters: the expedition is over: every booster off, as in the game (none put on again by the mod)"); } } } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("boosters: after the level's cleanup: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } l.LogError(val); } } } } [HarmonyPatch(typeof(PersistentInventoryManager), "_CommitPendingTransactions_b__36_0")] private static class Rebuilt { private static void Postfix() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown try { _dirty = true; Ensure(now: true); } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("boosters: after the game's rebuild: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } l.LogError(val); } } } } [HarmonyPatch(typeof(PersistentInventoryManager), "PrepareBoosterImplantForInjection")] private static class Prepared { private static void Postfix(uint instanceId) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected I4, but got Unknown try { BoosterImplantInventoryItem val = default(BoosterImplantInventoryItem); if (PersistentInventoryManager.TryGetBoosterImplant(instanceId, ref val) && val != null && val.Implant != null && val.Prepared) { Settings.SetEquipped((int)val.Implant.Category, IsMine(instanceId) ? instanceId : 0u); } } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("boosters: a booster put on: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } l.LogError(val2); } } } } [HarmonyPatch(typeof(PersistentInventoryManager), "UnPrepareBoosterImplant")] private static class Unprepared { private static void Postfix(BoosterImplantCategory category) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown Settings.SetEquipped((int)category, 0u); } } private const uint IdBase = 1879048192u; private const uint IdMask = 268435455u; private static readonly List<BoosterImplantInventoryItem>[] Mine = new List<BoosterImplantInventoryItem>[3] { new List<BoosterImplantInventoryItem>(), new List<BoosterImplantInventoryItem>(), new List<BoosterImplantInventoryItem>() }; private static readonly HashSet<uint> Ids = new HashSet<uint>(); private static readonly Dictionary<uint, (string Kind, (float Min, float Max)[] Ranges)> Made = new Dictionary<uint, (string, (float, float)[])>(); private static bool _built; private static float _buildAt; private static readonly Dictionary<IntPtr, (uint Id, float[] Values)> Rolled = new Dictionary<IntPtr, (uint, float[])>(); private static string _statsSaid; private static IntPtr _model; private static readonly IntPtr[] ListPtrs = new IntPtr[3]; private static readonly int[] Counts = new int[3]; private static int _version = -1; private static bool _dirty = true; private static float _lookAt; private static int _errors; private static int _said; private static bool? _mode; public static bool IsMine(uint instanceId) { return Ids.Contains(instanceId); } public static IReadOnlyList<BoosterImplantInventoryItem> Of(int category) { if (category < 0 || category >= 3) { return Array.Empty<BoosterImplantInventoryItem>(); } return Mine[category]; } public static string Kind(uint templateId, IEnumerable<uint> effects, IEnumerable<uint> conditions) { return $"{templateId}/{string.Join("+", effects.OrderBy((uint x) => x))}/{string.Join("+", conditions.OrderBy((uint x) => x))}"; } public static string Kind(BoosterImplant b) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (b == null) { return null; } List<uint> list = new List<uint>(); Il2CppStructArray<Effect> effects = b.Effects; int num = 0; while (effects != null && num < ((Il2CppArrayBase<Effect>)(object)effects).Length) { list.Add(((Il2CppArrayBase<Effect>)(object)effects)[num].Id); num++; } List<uint> list2 = new List<uint>(); Il2CppStructArray<uint> conditions = b.Conditions; int num2 = 0; while (conditions != null && num2 < ((Il2CppArrayBase<uint>)(object)conditions).Length) { list2.Add(((Il2CppArrayBase<uint>)(object)conditions)[num2]); num2++; } return Kind(b.TemplateId, list, list2); } public static void Update() { Ensure(); } private static bool Build() { //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected I4, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if (_built) { return true; } if (Time.unscaledTime < _buildAt) { return false; } _buildAt = Time.unscaledTime + 1f; Il2CppArrayBase<BoosterImplantTemplateDataBlock> allBlocks = GameDataBlockBase<BoosterImplantTemplateDataBlock>.GetAllBlocks(); if (allBlocks == null || allBlocks.Length == 0) { return false; } int[] array = new int[3]; int num = 0; foreach (BoosterImplantTemplateDataBlock item in allBlocks) { if (item == null || !((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)item).internalEnabled || item.Deprecated) { continue; } int num2 = (int)item.ImplantCategory; if (num2 < 0 || num2 > 2) { continue; } num++; List<(uint, float, float)> first = Effects(item.Effects); List<List<(uint, float, float)>> list = new List<List<(uint, float, float)>>(); List<List<BoosterImplantEffectInstance>> randomEffects = item.RandomEffects; int num3 = 0; while (randomEffects != null && num3 < randomEffects.Count) { List<(uint, float, float)> list2 = Effects(randomEffects[num3]); if (list2.Count > 0) { list.Add(list2); } num3++; } List<uint> list3 = Ids32(item.Conditions); List<uint> list4 = Ids32(item.RandomConditions); int uses = Math.Max(1, Mathf.RoundToInt(Math.Max(item.DurationRange.x, item.DurationRange.y))); foreach (List<(uint, float, float)> item2 in Combinations(list)) { List<(uint, float, float)> list5 = first.Concat(item2).ToList(); if (list5.Count == 0) { continue; } if (list4.Count == 0) { Add(num2, Make(((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)item).persistentID, uses, list5, list3), array); continue; } foreach (uint item3 in list4) { Add(num2, Make(((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)item).persistentID, uses, list5, list3.Append(item3).ToList()), array); } } } _built = true; ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(88, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("boosters: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(array.Sum()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" boosters made from the game's "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" booster templates ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(array[0]); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" muted, "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(array[1]); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" bold, "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(array[2]); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" aggressive)"); } l.LogInfo(val); return true; } private static void Add(int cat, BoosterImplantInventoryItem item, int[] counts) { if (item != null) { Mine[cat].Add(item); counts[cat]++; } } private static List<(uint Id, float Min, float Max)> Effects(List<BoosterImplantEffectInstance> list) { List<(uint, float, float)> list2 = new List<(uint, float, float)>(); int num = 0; while (list != null && num < list.Count) { BoosterImplantEffectInstance val = list[num]; if (val != null && val.BoosterImplantEffect != 0) { list2.Add((val.BoosterImplantEffect, Math.Min(val.MinValue, val.MaxValue), Math.Max(val.MinValue, val.MaxValue))); } num++; } return list2; } private static List<uint> Ids32(List<uint> list) { List<uint> list2 = new List<uint>(); int num = 0; while (list != null && num < list.Count) { if (list[num] != 0) { list2.Add(list[num]); } num++; } return list2; } private static IEnumerable<List<(uint Id, float Min, float Max)>> Combinations(List<List<(uint Id, float Min, float Max)>> groups) { IEnumerable<List<(uint, float, float)>> enumerable = new List<(uint, float, float)>[1] { new List<(uint, float, float)>() }; foreach (List<(uint, float, float)> g in groups) { enumerable = enumerable.SelectMany((List<(uint, float, float)> w) => g.Select<(uint, float, float), List<(uint, float, float)>>(((uint Id, float Min, float Max) e) => new List<(uint, float, float)>(w) { e })).ToList(); } return enumerable; } private static BoosterImplantInventoryItem Make(uint templateId, int uses, List<(uint Id, float Min, float Max)> fx, List<uint> conds) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown try { string text = Kind(templateId, fx.Select(((uint Id, float Min, float Max) e) => e.Id), conds); uint num = IdFor(text); BoosterImplantInventoryItem val = new BoosterImplantInventoryItem(); ((BoosterImplantBase)val).Id = num; ((BoosterImplantBase)val).TemplateId = templateId; ((BoosterImplantBase)val).UsesRemaining = uses; val.Flags = 1u; Il2CppStructArray<BoosterImplantEffect> val2 = new Il2CppStructArray<BoosterImplantEffect>((long)fx.Count); for (int num2 = 0; num2 < fx.Count; num2++) { ((Il2CppArrayBase<BoosterImplantEffect>)(object)val2)[num2] = new BoosterImplantEffect { Id = fx[num2].Id, Param = fx[num2].Max }; } ((BoosterImplantBase)val).Effects = val2; Il2CppStructArray<uint> val3 = new Il2CppStructArray<uint>((long)conds.Count); for (int num3 = 0; num3 < conds.Count; num3++) { ((Il2CppArrayBase<uint>)(object)val3)[num3] = conds[num3]; } ((BoosterImplantBase)val).Conditions = val3; BoosterImplantInventoryItem val4 = new BoosterImplantInventoryItem(val); Ids.Add(num); Made[num] = (text, fx.Select(((uint Id, float Min, float Max) e) => (Min: e.Min, Max: e.Max)).ToArray()); return val4; } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("boosters: template "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<uint>(templateId); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" not made: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message); } l.LogError(val5); } return null; } } private static uint IdFor(string kind) { uint num = 0x70000000 | (Fnv(kind) & 0xFFFFFFF); while (Ids.Contains(num)) { num = 0x70000000 | ((num + 1) & 0xFFFFFFF); } return num; } private static uint Fnv(string s) { uint num = 2166136261u; foreach (char c in s) { num = (num ^ c) * 16777619; } return num; } private static float RollOf(string kind, int index, float min, float max) { double num = (double)(Fnv(kind + "#" + index) & 0xFFFFFF) / 16777216.0; return Math.Clamp((float)(Math.Round(((double)min + (double)(max - min) * num) * 100.0) / 100.0), min, max); } public static float Best(BoosterImplantTemplateDataBlock t, uint effect) { if (t == null) { return 0f; } float num = Top(t.Effects, effect); List<List<BoosterImplantEffectInstance>> randomEffects = t.RandomEffects; int num2 = 0; while (num == 0f && randomEffects != null && num2 < randomEffects.Count) { num = Top(randomEffects[num2], effect); num2++; } return num; } private static float Top(List<BoosterImplantEffectInstance> list, uint effect) { int num = 0; while (list != null && num < list.Count) { BoosterImplantEffectInstance val = list[num]; if (val != null && val.BoosterImplantEffect == effect) { return Math.Max(val.MinValue, val.MaxValue); } num++; } return 0f; } private static void Stats(List<BoosterImplantInventoryItem>[] lists) { //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: 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) bool flag = Settings.Perfect.On; for (int i = 0; i < 3; i++) { foreach (BoosterImplantInventoryItem item in Mine[i]) { Il2CppStructArray<Effect> val = ((item.Implant != null) ? item.Implant.Effects : null); if (val != null && Made.TryGetValue(item.InstanceId, out (string, (float, float)[]) value)) { for (int j = 0; j < ((Il2CppArrayBase<Effect>)(object)val).Length && j < value.Item2.Length; j++) { var (min, num) = value.Item2[j]; Set(val, j, flag ? num : RollOf(value.Item1, j, min, num)); } } } } int num2 = 0; int num3 = 0; HashSet<IntPtr> seen = new HashSet<IntPtr>(); foreach (List<BoosterImplantInventoryItem> val2 in lists) { int num4 = 0; while (val2 != null && num4 < val2.Count) { BoosterImplantInventoryItem val3 = val2[num4]; BoosterImplant val4 = ((val3 != null) ? val3.Implant : null); if (val4 != null && !IsMine(val4.InstanceId) && val4.Effects != null) { num3++; Il2CppStructArray<Effect> effects = val4.Effects; seen.Add(((Il2CppObjectBase)val3).Pointer); (uint, float[]) value2; if (flag) { float[] array = new float[((Il2CppArrayBase<Effect>)(object)effects).Length]; bool flag2 = false; for (int l = 0; l < ((Il2CppArrayBase<Effect>)(object)effects).Length; l++) { float num5 = Best(val4.Template, ((Il2CppArrayBase<Effect>)(object)effects)[l].Id); array[l] = ((num5 > 0f) ? num5 : ((Il2CppArrayBase<Effect>)(object)effects)[l].Value); flag2 |= Math.Abs(array[l] - ((Il2CppArrayBase<Effect>)(object)effects)[l].Value) > 0.0001f; } if (flag2) { float[] array2 = new float[((Il2CppArrayBase<Effect>)(object)effects).Length]; for (int m = 0; m < ((Il2CppArrayBase<Effect>)(object)effects).Length; m++) { array2[m] = ((Il2CppArrayBase<Effect>)(object)effects)[m].Value; } Rolled[((Il2CppObjectBase)val3).Pointer] = (val4.InstanceId, array2); for (int n = 0; n < ((Il2CppArrayBase<Effect>)(object)effects).Length; n++) { Set(effects, n, array[n]); } } num2++; } else if (Rolled.TryGetValue(((Il2CppObjectBase)val3).Pointer, out value2)) { if (value2.Item1 == val4.InstanceId) { for (int num6 = 0; num6 < ((Il2CppArrayBase<Effect>)(object)effects).Length && num6 < value2.Item2.Length; num6++) { Set(effects, num6, value2.Item2[num6]); } } Rolled.Remove(((Il2CppObjectBase)val3).Pointer); } } num4++; } } foreach (IntPtr item2 in Rolled.Keys.Where((IntPtr item) => !seen.Contains(item)).ToList()) { Rolled.Remove(item2); } string text = $"{flag}/{num3}"; if (text != _statsSaid && _said++ < 30) { _statsSaid = text; Plugin.L.LogInfo((object)(flag ? $"boosters: stats: every booster at its best (Perfect boosters): the mod's {Ids.Count}, {num2} of your own" : $"boosters: stats: the mod's {Ids.Count} as rolled, your own {num3} with their own stats")); } } private static void Set(Il2CppStructArray<Effect> fx, int i, float v) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Effect val = ((Il2CppArrayBase<Effect>)(object)fx)[i]; if (!(Math.Abs(val.Value - v) < 1E-05f)) { val.Value = v; ((Il2CppArrayBase<Effect>)(object)fx)[i] = val; } } public static void Ensure(bool now = false) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Expected O, but got Unknown //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Expected O, but got Unknown if (Lists.Swapped) { return; } PersistentInventoryManager current = PersistentInventoryManager.Current; BoosterImplantInventoryModel val = (((Object)(object)current != (Object)null) ? current.m_boosterImplantInventory : null); Il2CppReferenceArray<Category> val2 = ((val != null) ? val.Categories : null); if (val2 == null || ((Il2CppArrayBase<Category>)(object)val2).Length < 3 || (!now && !Changed(val)) || !Build()) { return; } List<BoosterImplantInventoryItem>[] array = new List<BoosterImplantInventoryItem>[3]; for (int i = 0; i < 3; i++) { array[i] = ((((Il2CppArrayBase<Category>)(object)val2)[i] != null) ? ((Il2CppArrayBase<Category>)(object)val2)[i].Inventory : null); } bool flag = default(bool); try { Stats(array); } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("boosters: the stats: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex); } l.LogError(val3); } } bool flag2 = Settings.All.On; bool flag3 = !flag2 && GameStateManager.IsInExpedition; bool flag4 = (Object)(object)SNet.LocalPlayer != (Object)null; bool flag5 = false; bool flag6 = false; bool dirty = false; bool num = !GameStateManager.IsInExpedition; int num2; if (num && flag2) { bool? mode = _mode; flag = false; num2 = ((mode == flag) ? 1 : 0); } else { num2 = 0; } bool flag7 = (byte)num2 != 0; int num3; if (num && !flag2) { bool? mode = _mode; flag = true; num3 = ((mode == flag) ? 1 : 0); } else { num3 = 0; } bool flag8 = (byte)num3 != 0; if (num) { _mode = flag2; } if (flag7 || flag8) { Settings.ForgetEquipped(); } for (int j = 0; j < 3; j++) { List<BoosterImplantInventoryItem> val4 = array[j]; if (val4 == null) { continue; } if (flag7) { for (int k = 0; k < val4.Count; k++) { BoosterImplantInventoryItem val5 = val4[k]; if (val5 == null || !val5.Prepared || IsMine(val5.InstanceId)) { continue; } val5.Prepared = false; flag5 = true; if (_said++ < 30) { ManualLogSource l2 = Plugin.L; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(56, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("boosters: your own "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(Lists.Label(val5.Implant, rich: false)); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" taken off (All boosters unlocked on)"); } l2.LogInfo(val6); } } } if (flag2) { int num4 = 0; foreach (BoosterImplantInventoryItem item in Mine[j]) { if (!val4.Contains(item)) { val4.Add(item); num4++; } } flag6 = flag6 || num4 > 0; uint worn = Settings.Equipped(j); if (worn != 0 && IsMine(worn) && !AnyPrepared(val4) && !flag4) { dirty = true; } else { if (worn == 0 || !IsMine(worn) || AnyPrepared(val4)) { continue; } BoosterImplantInventoryItem val7 = ((IEnumerable<BoosterImplantInventoryItem>)Mine[j]).FirstOrDefault((Func<BoosterImplantInventoryItem, bool>)((BoosterImplantInventoryItem x) => x.InstanceId == worn)); if (val7 == null) { continue; } val7.Prepared = true; flag5 = true; if (_said++ < 30) { ManualLogSource l3 = Plugin.L; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("boosters: "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(Lists.Label(val7.Implant, rich: false)); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" put on again"); } l3.LogInfo(val6); } } } else { if (flag3) { continue; } for (int num5 = val4.Count - 1; num5 >= 0; num5--) { BoosterImplantInventoryItem val8 = val4[num5]; if (val8 != null && IsMine(val8.InstanceId)) { flag5 |= val8.Prepared; val8.Prepared = false; val4.RemoveAt(num5); flag6 = true; } } } } _model = ((Il2CppObjectBase)val).Pointer; for (int num6 = 0; num6 < 3; num6++) { ListPtrs[num6] = ((array[num6] != null) ? ((Il2CppObjectBase)array[num6]).Pointer : IntPtr.Zero); Counts[num6] = ((array[num6] != null) ? array[num6].Count : (-1)); } _version = Settings.Version; _dirty = dirty; if (flag6 && _said++ < 30) { Plugin.L.LogInfo((object)(flag2 ? "boosters: the mod's boosters are in the game's inventory" : "boosters: the mod's boosters taken out of the game's inventory (All boosters unlocked off)")); } try { if (flag5 && current.OnActiveBoosterImplantsChanged != null) { current.OnActiveBoosterImplantsChanged.Invoke(); } if ((flag5 || flag6) && current.OnBoosterImplantInventoryChanged != null) { current.OnBoosterImplantInventoryChanged.Invoke(); } } catch (Exception ex2) { if (_errors++ < 10) { ManualLogSource l4 = Plugin.L; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("boosters: telling the game of the change: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message); } l4.LogError(val3); } } } private static bool AnyPrepared(List<BoosterImplantInventoryItem> list) { for (int i = 0; i < list.Count; i++) { if (list[i] != null && list[i].Prepared) { return true; } } return false; } private static bool Changed(BoosterImplantInventoryModel m) { if (_dirty || Settings.Version != _version || ((Il2CppObjectBase)m).Pointer != _model) { return true; } Il2CppReferenceArray<Category> categories = m.Categories; for (int i = 0; i < 3; i++) { List<BoosterImplantInventoryItem> val = ((((Il2CppArrayBase<Category>)(object)categories)[i] != null) ? ((Il2CppArrayBase<Category>)(object)categories)[i].Inventory : null); if (val == null) { return false; } if (((Il2CppObjectBase)val).Pointer != ListPtrs[i] || val.Count != Counts[i]) { return true; } } if (Time.unscaledTime < _lookAt) { return false; } _lookAt = Time.unscaledTime + 1f; bool flag = Settings.All.On; if (_mode.HasValue && _mode != flag && !GameStateManager.IsInExpedition) { return true; } for (int j = 0; j < 3; j++) { if (Mine[j].Count > 0 && ((Il2CppArrayBase<Category>)(object)categories)[j].Inventory.Contains(Mine[j][0]) != flag) { return true; } } return false; } } internal static class Lists { private sealed class Stand { public Category Cat; public List<BoosterImplantInventoryItem> Real; public int Category; public int Limit = -1; public bool Swapped; } [HarmonyPatch(typeof(CM_PlayerLobbyBar), "UpdateBoosterSelectionPoup")] [HarmonyPriority(0)] private static class Shown { private static void Prefix(CM_PlayerLobbyBar __instance, BoosterImplantCategory category, out Stand __state) { //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected I4, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) __state = null; bool flag = default(bool); try { Inventory.Ensure(); PersistentInventoryManager current = PersistentInventoryManager.Current; Il2CppReferenceArray<Category> val = (((Object)(object)current != (Object)null && current.m_boosterImplantInventory != null) ? current.m_boosterImplantInventory.Categories : null); int num = (int)category; if (val == null || num < 0 || num >= ((Il2CppArrayBase<Category>)(object)val).Length || ((Il2CppArrayBase<Category>)(object)val)[num] == null || ((Il2CppArrayBase<Category>)(object)val)[num].Inventory == null) { return; } Stand stand = new Stand { Cat = ((Il2CppArrayBase<Category>)(object)val)[num], Real = ((Il2CppArrayBase<Category>)(object)val)[num].Inventory, Category = num }; int favourites; List<BoosterImplantInventoryItem> val2 = Ordered(stand.Real, num, out favourites); __state = stand; Il2CppStructArray<int> inventoryLimitPerCategory = BoosterImplantConstants.InventoryLimitPerCategory; if (inventoryLimitPerCategory != null && num < ((Il2CppArrayBase<int>)(object)inventoryLimitPerCategory).Length && val2.Count > ((Il2CppArrayBase<int>)(object)inventoryLimitPerCategory)[num]) { stand.Limit = ((Il2CppArrayBase<int>)(object)inventoryLimitPerCategory)[num]; ((Il2CppArrayBase<int>)(object)inventoryLimitPerCategory)[num] = val2.Count; } stand.Cat.Inventory = val2; stand.Swapped = true; _swaps++; if (Said[num]++ < 3 || _reopening) { ManualLogSource l = Plugin.L; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(28, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("list: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<BoosterImplantCategory>(category); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(val2.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" shown ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(favourites); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" favourites"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>((stand.Limit >= 0) ? $"; the game's {stand.Limit} slots made {val2.Count}" : ""); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")"); } l.LogInfo(val3); } } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l2 = Plugin.L; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(30, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("list: not made the mod's way: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex); } l2.LogError(val4); } } } private static void Finalizer(Stand __state) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown if (__state == null) { return; } if (__state.Swapped) { _swaps--; } try { if (__state.Swapped) { __state.Cat.Inventory = __state.Real; } if (__state.Limit >= 0) { ((Il2CppArrayBase<int>)(object)BoosterImplantConstants.InventoryLimitPerCategory)[__state.Category] = __state.Limit; } } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("list: the game's own list not put back: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } l.LogError(val); } } } } [HarmonyPatch(typeof(CM_LobbyScrollItem), "PlayIntro")] private static class Quick { private static void Prefix(ref float delay) { if (_swaps > 0 && delay > 0.6f) { delay = 0.6f; } } } [HarmonyPatch(typeof(CM_BoosterImplantSlotItem), "LoadData", new Type[] { typeof(BoosterImplant), typeof(bool) })] private static class Entry { private static void Postfix(CM_BoosterImplantSlotItem __instance, BoosterImplant boosterImplant) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown if ((Object)(object)__instance == (Object)null || boosterImplant == null) { return; } try { TextMeshPro nameText = ((CM_LobbyScrollItem)__instance).m_nameText; if ((Object)(object)nameText != (Object)null) { bool flag = Settings.IsFavourite(Inventory.Kind(boosterImplant)); ((TMP_Text)nameText).text = (flag ? (Star(nameText) + " ") : "") + Label(boosterImplant, rich: true); if (_measured++ == 0) { Measure(nameText); } } TextMeshPro usesText = __instance.m_usesText; if ((Object)(object)usesText != (Object)null && Unending(boosterImplant)) { ((TMP_Text)usesText).text = "[unlimited uses]"; } } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag2 = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(23, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("list: an entry's name: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } l.LogError(val); } } } } [HarmonyPatch(typeof(CM_PlayerLobbyBar), "RefreshBoosterImplantInfo")] private static class Details { private static void Prefix(CM_PlayerLobbyBar __instance) { _details = null; _dropText = null; _favouriteButton = false; CM_BoosterImplantSlotItem val = (((Object)(object)__instance != (Object)null) ? __instance.selectedBoosterImplantItem : null); if ((Object)(object)val != (Object)null && !val.IsEmpty && !val.IsPreview) { _details = val.BoosterImplant; } } private static void Postfix(CM_PlayerLobbyBar __instance) { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown BoosterImplant details = _details; try { CM_ScrollWindow popupScrollWindow = __instance.m_popupScrollWindow; CM_ScrollWindowBoosterInfoBox val = (((Object)(object)popupScrollWindow != (Object)null && (Object)(object)popupScrollWindow.InfoBox != (Object)null) ? ((Il2CppObjectBase)popupScrollWindow.InfoBox).TryCast<CM_ScrollWindowBoosterInfoBox>() : null); if (!((Object)(object)val == (Object)null)) { DropButton(__instance, (CM_ScrollWindowInfoBox)(object)val, (details != null && !Inventory.IsMine(details.InstanceId)) ? _dropText : null); TextMeshPro useCountText = val.m_useCountText; if (details != null && Unending(details) && (Object)(object)useCountText != (Object)null) { ((TMP_Text)useCountText).text = $"<color=#{ColorExt.GetBoosterUsesColorString(1f)}>{"[unlimited uses]"}</color>"; } } } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("list: a booster's details: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } l.LogError(val2); } } } private static void Finalizer() { _details = null; } } [HarmonyPatch(typeof(CM_ScrollWindowInfoBox), "SetInfoBox")] [HarmonyPriority(0)] private static class Button { private static void Prefix(ref string rejectText) { BoosterImplant details = _details; if (details == null) { return; } bool flag = Inventory.IsMine(details.InstanceId); bool flag2 = !string.IsNullOrEmpty(rejectText); if (flag || (flag2 && Favourite.On)) { if (!flag) { _dropText = rejectText; } rejectText = (Settings.IsFavourite(Inventory.Kind(details)) ? "Remove Favourite" : "Add to Favourites"); _favouriteButton = true; } } } [HarmonyPatch] private static class Favourite { private const string Lambda = "_ShowBoosterImplantSelect_b__4"; public static bool On { get; private set; } private static MethodBase TargetMethod() { Type[] nestedTypes = typeof(CM_PlayerLobbyBar).GetNestedTypes(AccessTools.all); for (int i = 0; i < nestedTypes.Length; i++) { MethodInfo methodInfo = AccessTools.DeclaredMethod(nestedTypes[i], "_ShowBoosterImplantSelect_b__4", new Type[1] { typeof(int) }, (Type[])null); if (methodInfo != null) { return methodInfo; } } return null; } private static bool Prepare() { On = TargetMethod() != null; if (On) { return true; } Plugin.L.LogWarning((object)"list: the details box's second button (_ShowBoosterImplantSelect_b__4) not found: favourites are marked through the slot's drop instead, for the mod's boosters only (the list opens again in the new order)"); return false; } private static bool Prefix(__c__DisplayClass141_0 __instance) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown CM_PlayerLobbyBar val = ((__instance != null) ? __instance.__4__this : null); CM_BoosterImplantSlotItem val2 = (((Object)(object)val != (Object)null) ? val.selectedBoosterImplantItem : null); BoosterImplant val3 = (((Object)(object)val2 != (Object)null && !val2.IsEmpty && !val2.IsPreview) ? val2.BoosterImplant : null); if (val3 == null || (!_favouriteButton && !Inventory.IsMine(val3.InstanceId))) { return true; } try { Toggle(val3); Reopen(val, val3); } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(19, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("list: a favourite: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex); } l.LogError(val4); } } return false; } } [HarmonyPatch(typeof(CM_BoosterImplantSlotItem), "DropBoosterImplant")] private static class Guard { private static bool Prefix(CM_BoosterImplantSlotItem __instance) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown BoosterImplant val = (((Object)(object)__instance != (Object)null && !__instance.IsEmpty) ? __instance.BoosterImplant : null); if (val == null || !Inventory.IsMine(val.InstanceId)) { return true; } try { if (Marked(__instance) != null) { Toggle(val); } } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(19, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("list: a favourite: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } l.LogError(val2); } } return false; } } private const float MaxIntro = 0.6f; private const string Unlimited = "[unlimited uses]"; private static int _swaps; private static int _errors; private static int _measured; private static bool _reopening; private static readonly int[] Said = new int[3]; private static string _star; private static BoosterImplant _details; private static string _dropText; private static bool _favouriteButton; private static bool _dropSaid; private static readonly Dictionary<IntPtr, CM_Item> DropOf = new Dictionary<IntPtr, CM_Item>(); public static bool Swapped => _swaps > 0; private static List<BoosterImplantInventoryItem> Ordered(List<BoosterImplantInventoryItem> real, int c, out int favourites) { List<BoosterImplantInventoryItem> list = new List<BoosterImplantInventoryItem>(); IReadOnlyList<BoosterImplantInventoryItem> readOnlyList = Inventory.Of(c); bool flag = Settings.All.On && readOnlyList.Count > 0 && real.Contains(readOnlyList[0]); if (flag) { list.AddRange(readOnlyList); } for (int i = 0; i < real.Count; i++) { BoosterImplantInventoryItem val = real[i]; if (val != null && val.Implant != null && !Inventory.IsMine(val.InstanceId) && (!flag || val.Prepared)) { list.Add(val); } } List<(BoosterImplantInventoryItem, bool, string, float)> list2 = (from it in list select (Item: it, Fav: Settings.IsFavourite(Inventory.Kind(it.Implant)), Name: Label(it.Implant, rich: false), Worth: Worth(it.Implant)) into x orderby (!x.Fav) ? 1 : 0 select x).ThenBy<(BoosterImplantInventoryItem, bool, string, float), string>(((BoosterImplantInventoryItem Item, bool Fav, string Name, float Worth) x) => x.Name, StringComparer.OrdinalIgnoreCase).ThenByDescending<(BoosterImplantInventoryItem, bool, string, float), float>(((BoosterImplantInventoryItem Item, bool Fav, string Name, float Worth) x) => x.Worth).ThenByDescending<(BoosterImplantInventoryItem, bool, string, float), int>(((BoosterImplantInventoryItem Item, bool Fav, string Name, float Worth) x) => x.Item.Implant.Uses) .ThenBy<(BoosterImplantInventoryItem, bool, string, float), uint>(((BoosterImplantInventoryItem Item, bool Fav, string Name, float Worth) x) => x.Item.InstanceId) .ToList(); favourites = list2.Count<(BoosterImplantInventoryItem, bool, string, float)>(((BoosterImplantInventoryItem Item, bool Fav, string Name, float Worth) x) => x.Fav); List<BoosterImplantInventoryItem> val2 = new List<BoosterImplantInventoryItem>(); foreach (var item in list2) { val2.Add(item.Item1); } return val2; } private static float Worth(BoosterImplant b) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) float num = 0f; Il2CppStructArray<Effect> effects = b.Effects; int num2 = 0; while (effects != null && num2 < ((Il2CppArrayBase<Effect>)(object)effects).Length) { num += ((Il2CppArrayBase<Effect>)(object)effects)[num2].Value - 1f; num2++; } return num; } public static string Label(BoosterImplant b, bool rich) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (b == null) { return ""; } List<string> list = new List<string>(); Il2CppStructArray<Effect> effects = b.Effects; int num = 0; while (effects != null && num < ((Il2CppArrayBase<Effect>)(object)effects).Length) { string effectPublicShortName = BoosterImplantTemplateDataBlock.GetEffectPublicShortName(((Il2CppArrayBase<Effect>)(object)effects)[num].Id); if (!string.IsNullOrEmpty(effectPublicShortName)) { list.Add((((Il2CppArrayBase<Effect>)(object)effects)[num].Value < 1f) ? ("-" + effectPublicShortName) : effectPublicShortName); } num++; } Il2CppStructArray<uint> conditions = b.Conditions; int num2 = 0; while (conditions != null && num2 < ((Il2CppArrayBase<uint>)(object)conditions).Length) { string conditionPublicShortName = BoosterImplantTemplateDataBlock.GetConditionPublicShortName(((Il2CppArrayBase<uint>)(object)conditions)[num2]); if (!string.IsNullOrEmpty(conditionPublicShortName)) { list.Add(conditionPublicShortName); } num2++; } string publicName = BoosterImplantTemplateDataBlock.GetPublicName(b.TemplateId); string text = string.Join(" ", list); if (!rich) { return (publicName + " - " + text).ToLowerInvariant(); } return publicName + " - <lowercase>" + text + "</lowercase>"; } public static bool Unending(BoosterImplant b) { if (b != null) { if (!Inventory.IsMine(b.InstanceId)) { return Settings.Infinite.On; } return true; } return false; } private static string Star(TextMeshPro text) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown if (_star != null) { return _star; } bool flag = false; try { flag = (Object)(object)((TMP_Text)text).font != (Object)null && ((TMP_Text)text).font.HasCharacter('★', true, false); } catch { } _star = "<color=orange>" + (flag ? "★" : "*") + "</color>"; ManualLogSource l = Plugin.L; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("list: favourites marked with "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(flag ? "a star" : "* (the font has no star)"); } l.LogInfo(val); return _star; } private static void Measure(TextMeshPro t) { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_001f: 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_0016: 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_002c: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_00a7: 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_0135: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { Rect val = (Rect)(((Object)(object)((TMP_Text)t).rectTransform != (Object)null) ? ((TMP_Text)t).rectTransform.rect : default(Rect)); Vector2 preferredValues = ((TMP_Text)t).GetPreferredValues(((TMP_Text)t).text); ManualLogSource l = Plugin.L; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(86, 9, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("list: an entry's name '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((TMP_Text)t).text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': box "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(((Rect)(ref val)).width, "0.#"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(((Rect)(ref val)).height, "0.#"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", needs "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(preferredValues.x, "0.#"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(preferredValues.y, "0.#"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("font size "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(((TMP_Text)t).fontSize, "0.#"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", auto size "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(((TMP_Text)t).enableAutoSizing); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", wrapping "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(((TMP_Text)t).enableWordWrapping); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", overflow "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<TextOverflowModes>(((TMP_Text)t).overflowMode); } l.LogInfo(val2); } catch (Exception ex) { ManualLogSource l2 = Plugin.L; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("list: an entry's name not measured: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } l2.LogInfo(val2); } } private static void DropButton(CM_PlayerLobbyBar bar, CM_ScrollWindowInfoBox box, string text) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: 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_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: 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_0241: Expected O, but got Unknown //IL_0273: 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) CM_Item infoRejectButton = box.m_infoRejectButton; if ((Object)(object)infoRejectButton == (Object)null) { return; } bool flag = !string.IsNullOrEmpty(text) && ((Component)infoRejectButton).gameObject.activeSelf; DropOf.TryGetValue(((Il2CppObjectBase)infoRejectButton).Pointer, out var value); if ((Object)(object)value == (Object)null || ((Il2CppObjectBase)value).WasCollected) { if (!flag) { return; } GameObject val = Object.Instantiate<GameObject>(((Component)infoRejectButton).gameObject, ((Component)infoRejectButton).transform.parent); ((Object)val).name = "Boosters drop button"; value = val.GetComponent<CM_Item>(); if ((Object)(object)value == (Object)null) { Object.Destroy((Object)(object)val); return; } value.m_onBtnPress = new UnityEvent(); CM_PlayerLobbyBar of = bar; value.OnBtnPressCallback += DelegateSupport.ConvertDelegate<Action<int>>((Delegate)(Action<int>)delegate { DropNow(of); }); if (DropOf.Count > 20) { DropOf.Clear(); } DropOf[((Il2CppObjectBase)infoRejectButton).Pointer] = value; } if (((Component)value).gameObject.activeSelf != flag) { ((Component)value).gameObject.SetActive(flag); } if (!flag) { return; } CM_TimedButton val2 = ((Il2CppObjectBase)value).TryCast<CM_TimedButton>(); if ((Object)(object)val2 != (Object)null) { ((CM_Item)val2).SetText(text); } else { value.SetText(text); } float num = 0f; BoxCollider2D val3 = ((Component)infoRejectButton).GetComponent<BoxCollider2D>() ?? ((Component)infoRejectButton).GetComponentInChildren<BoxCollider2D>(true); if ((Object)(object)val3 != (Object)null) { num = val3.size.y * Math.Abs(((Component)val3).transform.lossyScale.y / Math.Max(Math.Abs(((Component)infoRejectButton).transform.parent.lossyScale.y), 0.0001f)); } if (num < 5f) { RectTransform val4 = ((Il2CppObjectBase)((Component)infoRejectButton).transform).TryCast<RectTransform>(); if (val4 != null) { num = val4.sizeDelta.y * Math.Abs(((Component)infoRejectButton).transform.localScale.y); } } if (num < 5f) { num = 60f; } Vector3 localPosition = ((Component)infoRejectButton).transform.localPosition; ((Component)value).transform.localPosition = new Vector3(localPosition.x, localPosition.y + num * 1.3f, localPosition.z); if (!_dropSaid) { _dropSaid = true; ManualLogSource l = Plugin.L; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(88, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("list: Drop Booster has a button of its own, "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(num * 1.3f, "0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" above the second (now the favourite's) at "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(localPosition.x, "0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(localPosition.y, "0"); } l.LogInfo(val5); } } private static void DropNow(CM_PlayerLobbyBar bar) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { CM_BoosterImplantSlotItem val = (((Object)(object)bar != (Object)null) ? bar.selectedBoosterImplantItem : null); BoosterImplant val2 = (((Object)(object)val != (Object)null && !val.IsEmpty && !val.IsPreview) ? val.BoosterImplant : null); if (val2 != null && !Inventory.IsMine(val2.InstanceId)) { BoosterImplantCategory category = val2.Category; string text = Label(val2, rich: false); val.DropBoosterImplant(); ManualLogSource l = Plugin.L; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("list: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" dropped (Drop Booster)"); } l.LogInfo(val3); ShowAgain(bar, category, 0u); } } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l2 = Plugin.L; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(14, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("list: a drop: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex); } l2.LogError(val4); } } } private static void Reopen(CM_PlayerLobbyBar bar, BoosterImplant b) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ShowAgain(bar, b.Category, b.InstanceId); } public static void ShowAgain(CM_PlayerLobbyBar bar, BoosterImplantCategory category, uint id) { //IL_003d: 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) if ((Object)(object)bar == (Object)null) { return; } SNet_Player player = bar.m_player; bar.UnSelect(); bar.HidePopup(); _reopening = true; try { int num = ((id != 0) ? ((int)id) : (-1)); if ((Object)(object)player == (Object)null || player.IsLocal) { bar.ShowBoosterImplantSelect(category, num); } else { bar.ShowBoosterImplantTeamView(category, player); } } finally { _reopening = false; } if (id != 0) { Select(bar, id); } } private static void Select(CM_PlayerLobbyBar bar, uint id) { CM_ScrollWindow popupScrollWindow = bar.m_popupScrollWindow; List<iScrollWindowContent> val = (((Object)(object)popupScrollWindow != (Object)null) ? popupScrollWindow.m_contentItems : null); int num = 0; while (val != null && num < val.Count) { CM_BoosterImplantSlotItem val2 = ((val[num] != null) ? ((Il2CppObjectBase)val[num]).TryCast<CM_BoosterImplantSlotItem>() : null); if (!((Object)(object)val2 == (Object)null) && !val2.IsEmpty && val2.BoosterInstanceID == id) { CM_BoosterImplantSlotItem selectedBoosterImplantItem = bar.selectedBoosterImplantItem; if ((Object)(object)selectedBoosterImplantItem == (Object)null || ((Il2CppObjectBase)selectedBoosterImplantItem).Pointer != ((Il2CppObjectBase)val2).Pointer) { bar.SelectBoosterImplant(val2); bar.RefreshBoosterImplantInfo(); } break; } num++; } } private static BoosterImplant Marked(CM_BoosterImplantSlotItem sel) { BoosterImplant val = (((Object)(object)sel != (Object)null && !sel.IsEmpty && !sel.IsPreview) ? sel.BoosterImplant : null); if (val == null || !Inventory.IsMine(val.InstanceId)) { return null; } return val; } private static void Toggle(BoosterImplant b) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown bool flag = Settings.ToggleFavourite(Inventory.Kind(b)); ManualLogSource l = Plugin.L; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(7, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("list: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Label(b, rich: false)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(flag ? "is a favourite" : "is no longer a favourite"); } l.LogInfo(val); } } internal static class Organizer { private enum View { Favourites, All } private sealed class Entry { public string Kind; public string Name; public string Body; public uint Id; public bool Mine; public bool On; public bool New; public bool Unending; public int Uses; public float Worth; public BoosterImplantCategory Category; public BoosterEffectCategory Effect; } private sealed class Cell { public string Head; public int HeadCount; public bool More; public Entry E; } private sealed class Hit { public CM_Item Item; public Action<bool> Lit; public bool Was; } private sealed class RowArt { public Entry E; public SpriteRenderer Bg; public SpriteRenderer Edge; public SpriteRenderer Star; public SpriteRenderer DropBg; public TextMeshPro DropText; public bool LitBody; public bool LitStar; public bool LitDrop; public bool Lit { get { if (!LitBody && !LitStar) { return LitDrop; } return true; } } } private sealed class TabArt { public SpriteRenderer Bg; public SpriteRenderer Under; public TextMeshPro Text; public Func<string> Label; public bool On; public bool Lit; } private readonly struct Box { public readonly float X0; public readonly float Y0; public readonly float X1; public readonly float Y1; public float W => X1 - X0; public float H => Y1 - Y0; public float Cx => (X0 + X1) * 0.5f; public float Cy => (Y0 + Y1) * 0.5f; public Box(float x0, float y0, float x1, float y1) { X0 = Math.Min(x0, x1); Y0 = Math.Min(y0, y1); X1 = Math.Max(x0, x1); Y1 = Math.Max(y0, y1); } public Box With(Box o) { return new Box(Math.Min(X0, o.X0), Math.Min(Y0, o.Y0), Math.Max(X1, o.X1), Math.Max(Y1, o.Y1)); } public Box Inset(float dx, float dy) { return new Box(X0 + dx, Y0 + dy, X1 - dx, Y1 - dy); } } [HarmonyPatch(typeof(CM_PlayerLobbyBar), "ShowBoosterImplantSelect", new Type[] { typeof(BoosterImplantCategory), typeof(int) })] private static class Instead { private static bool Prefix(CM_PlayerLobbyBar __instance, BoosterImplantCategory category) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected I4, but got Unknown try { if (!Own(__instance)) { return true; } if (IsOpen) { return false; } __instance.HidePopup(); if (!Open(__instance, (int)category)) { return true; } if (!_insteadSaid) { _insteadSaid = true; Plugin.L.LogInfo((object)"organizer: the booster page opened in place of the game's booster list"); } return false; } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("organizer: the page in place of the list: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } l.LogError(val); } return !IsOpen; } } } private const int RowsPerColumn = 24; private const int Columns = 3; private const int BigRows = 9; private const float ArmedFor = 4f; private const float MaxScale = 1.5f; private static readonly Color RowBg = Art.Hex("#1C2127", 0.96f); private static readonly Color RowLit = Art.Hex("#2E3743", 0.98f); private static readonly Color FavBg = Art.Hex("#3B3116", 0.97f); private static readonly Color FavLit = Art.Hex("#54451E", 0.98f); private static readonly Color Gold = Art.Hex("#FFC83D"); private static readonly Color StarOff = Art.Hex("#7A838D", 0.9f); private static readonly Color LineColour = Art.Hex("#4E5761"); private static readonly Color TabBg = Art.Hex("#1C2127", 0.96f); private static readonly Color TabLit = Art.Hex("#2E3743", 0.98f); private static readonly Color TabOn = Art.Hex("#3D4754"); private static readonly Color OnEdge = Art.Hex("#6EC6FF"); private static readonly Color DropBg = Art.Hex("#3A1F22", 0.97f); private static readonly Color DropLit = Art.Hex("#5A2A2F", 0.98f); private static readonly Color DropArmed = Art.Hex("#B3261E"); private const string White = "#FFFFFF"; private const string Grey = "#8A9099"; private const string Soft = "#AEB5BD"; private const string InUse = "#6EC6FF"; private const string GoldText = "#FFC83D"; private const string NewText = "#FFA500"; private static CM_GlobalPopup _popup; private static CM_PlayerLobbyBar _bar; private static CM_Item _close; private static CM_BoosterIcon _iconLike; private static TextMeshPro _head; private static TextMeshPro _upper; private static TextMeshPro _lower; private static TextMeshPro _keys; private static Transform _plane; private static Camera _cam; private static Box _area; private static Box? _xBox; private static float _z; private static float _armedUntil; private static int _layer; private static int _sortLayer; private static int _order; private static int _category; private static int _page; private static int _pages; private static int _errors; private static int _changes; private static int _openedFrame; private static uint _armed; private static View _view; private static bool _pad; private static bool _hoverSaid; private static bool _treeSaid; private static bool _iconSaid; private static bool _insteadSaid; private static readonly List<GameObject> Made = new List<GameObject>(); private static readonly List<Hit> Hits = new List<Hit>(); private static readonly List<RowArt> Rows = new List<RowArt>(); private static readonly List<TabArt> TabArts = new List<TabArt>(); private static readonly HashSet<uint> Seen = new HashSet<uint>(); private static (float Ratio, float Dx, float Dy, (Material Back, Material Front) Material) _layout; private static bool _laidOut; public static bool IsOpen => _popup != null; private static bool Own(CM_PlayerLobbyBar bar) { SNet_Player val = (((Object)(object)bar != (Object)null) ? bar.m_player : null); SNet_Player localPlayer = SNet.LocalPlayer; if ((Object)(object)val != (Object)null && (Object)(object)localPlayer != (Object)null) { return ((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)localPlayer).Pointer; } return false; } private static bool Open(CM_PlayerLobbyBar bar, int category) { //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_00a5: Expected O, but got Unknown try { if (Showing(out var layer)) { return true; } if (layer != null && (Object)(object)layer.Popup != (Object)null) { Plugin.L.LogInfo((object)"organizer: another popup is showing; the game's list instead"); return false; } CM_GlobalPopup val = GlobalPopupMessageManager.ShowPopup(new PopupMessage { PopupType = (PopupType)0, BlinkInContent = false, BlinkTimeInterval = 0f, Header = "BOOSTERS", UpperText = " ", LowerText = " ", OnCloseCallback = DelegateSupport.ConvertDelegate<Action>((Delegate)(Action)delegate { }) }); if ((Object)(object)val == (Object)null && layer != null) { val = layer.Popup; } if ((Object)(object)val == (Object)null) { Plugin.L.LogWarning((object)"organizer: the game's popup didn't open"); return false; } _popup = val; _bar = bar; _category = Math.Clamp(category, 0, 2); _view = FirstView(_category); _page = 0; _armed = 0u; _head = val.m_headerText; _upper = val.m_upperText; _lower = val.m_lowerText; _close = val.m_closeButton; if ((Object)(object)_head == (Object)null || (Object)(object)_upper == (Object)null || (Object)(object)_lower == (Object)null || (Object)(object)_close == (Object)null) { Plugin.L.LogWarning((object)"organizer: the popup has no texts or no X: closed"); GlobalPopupMessageManager.HidePopup(); _popup = null; return false; } _cam = Camera(); _iconLike = IconSource(bar); _changes = 0; Seen.Clear(); _openedFrame = Time.frameCount; _pad = PadPressedNow() || (_pad && !Input.GetMouseButton(0)); Frame(); Fill(); return true; } catch (Exception ex) { if (_errors++ < 10) { ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(23, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("organizer: not opened: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } l.LogError(val2); } try { if (_popup != null) { GlobalPopupMessageManager.HidePopup(); } } catch { } _popup = null; return false; } } private static View FirstView(int c) { if (CountOf(c, favouritesOnly: true) <= 0) { return View.All; } return View.Favourites; } private static Camera Camera() { GlobalPopupMessageGuiLayer globalPopupMessageLayer = GuiManager.GlobalPopupMessageLayer; CameraController val = ((globalPopupMessageLayer != null) ? globalPopupMessageLayer.m_guiCamera : null); Camera val2 = (((Object)(object)val != (Object)null) ? val.m_camera : null); if ((Object)(object)val2 != (Object)null) { return val2; } int num = 1 << ((Component)_popup).gameObject.layer; foreach (Camera item in (Il2CppArrayBase<Camera>)(object)Camera.allCameras) { if ((Object)(object)item != (Object)null && ((Behaviour)item).enabled && (item.cullingMask & num) != 0) { return item; } } return Camera.main; } private static void Frame() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) _plane = _upper.transform.parent; _area = RectIn(((TMP_Text)_upper).rectTransform).With(RectIn(((TMP_Text)_lower).rectTransform)); _z = _upper.transform.localPosition.z; _layer = ((Component)_upper).gameObject.layer; MeshRenderer component = ((Component)_upper).GetComponent<MeshRenderer>(); _sortLayer = (((Object)(object)component != (Object)null) ? ((Renderer)component).sortingLayerID : 0); _order = (((Object)(object)component != (Object)null) ? ((Renderer)component).sortingOrder : 0); ((TMP_Text)_upper).text = ""; ((TMP_Text)_lower).text = ""; ((TMP_Text)_head).enableWordWrapping = false; ((TMP_Text)_head).overflowMode = (TextOverflowModes)0; Tree(); Box box = _area.With(RectIn(((TMP_Text)_head).rectTransform)); Vector3 val = _plane.InverseTransformPoint(((Component)_close).transform.position); box = box.With(new Box(val.x, val.y, val.x, val.y)).Inset((0f - _area.W) * 0.03f, (0f - _area.H) * 0.04f); _xBox = null; try { BoxCollider2D val2 = ((Component)_close).GetComponent<BoxCollider2D>() ?? ((Component)_close).GetComponentInChildren<BoxCollider2D>(true); if ((Object)(object)val2 != (Object)null) { Bounds bounds = ((Collider2D)val2).bounds; Vector3 val3 = _plane.InverseTransformPoint(bounds.m_Center - bounds.m_Extents); Vector3 val4 = _plane.InverseTransformPoint(bounds.m_Center + bounds.m_Extents); _xBox = new Box(val3.x, val3.y, val4.x, val4.y); } } catch { } (float W, float H) tuple = Px(box); float item = tuple.W; float item2 = tuple.H; float num = (((Object)(object)_cam != (Object)null) ? _cam.pixelWidth : Screen.width); float num2 = (((Object)(object)_cam != (Object)null) ? _cam.pixelHeight : Screen.height); float num3 = 1f; if (item > 1f && item2 > 1f && num > 1f && num2 > 1f) { num3 = Math.Clamp(Math.Min(num * 0.95f / item, num2 * 0.9f / item2), 1f, 1.5f); if (num3 > 1.02f) { ((Component)_popup).transform.localScale = ((Component)_popup).transform.localScale * num3; } else { num3 = 1f; } } (float W, float H) tuple2 = Px(_area); float item3 = tuple2.W; float item4 = tuple2.H; ManualLogSource l = Plugin.L; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(90, 13, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("organizer: the page's room "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(_area.W, "0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(_area.H, "0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" units, "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(item3, "0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(item4, "0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" px of the camera's "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(num, "0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(num2, "0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" (screen "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(Screen.width); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(Screen.height); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(")"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>((num3 > 1f) ? $" (the popup {num3:0.00} times its size)" : ""); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("; layer "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(_layer); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", sorting "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(_sortLayer); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(_order); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("; "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)(object)_iconLike != (Object)null) ? ("icons' sprites from " + ((Object)_iconLike).name) : "no icons"); } l.LogInfo(val5); } private static void Tree() { //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_024e: 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) if (_treeSaid) { return; } _treeSaid = true; try { List<string> list = new List<string>(); foreach (Renderer componentsInChild in ((Component)_popup).GetComponentsInChildren<Renderer>(true)) { if (!((Object)(object)componentsInChild == (Object)null) && list.Count < 30) { Transform transform = ((Component)componentsInChild).transform; string text = ((Object)transform).name; Transform parent = transform.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)((Component)_popup).transform && text.Length < 120) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } list.Add($"{text} [{((MemberInfo)((Object)componentsInChild).GetIl2CppType()).Name}] layer {((Component)componentsInChild).gameObject.layer} sorting {componentsInChild.sortingLayerID}/{componentsInChild.sortingOrder} z {transform.position.z:0.##}{(componentsInChild.enabled ? "" : " off")}"); } } BoxCollider2D componentInChildren = ((Component)_close).GetComponentInChildren<BoxCollider2D>(true); ManualLogSource l = Plugin.L; DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(77, 5); defaultInterpolatedStringHandler.AppendLiteral("organizer: the popup's parts (once): X "); defaultInterpolatedStringHandler.AppendFormatted(((Object)_close).name); defaultInterpolatedStringHandler.AppendLiteral(" ["); defaultInterpolatedStringHandler.AppendFormatted(((MemberInfo)((Object)_close).GetIl2CppType()).Name); defaultInterpolatedStringHandler.AppendLiteral("] under "); Transform parent2 = ((Component)_close).transform.parent; defaultInterpolatedStringHandler.AppendFormatted((parent2 != null) ? ((Object)parent2).name : null); defaultInterpolatedStringHandler.AppendLiteral(", "); defaultInterpolatedStringHandler.AppendLiteral("collider "); defaultInterpolatedStringHandler.AppendFormatted(((Object)(object)componentInChildren != (Object)null) ? $"{componentInChildren.size.x:0}x{componentInChildren.size.y:0}" : "none"); defaultInterpolatedStringHandler.AppendLiteral("; texts under "); Transform parent3 = _upper.transform.parent; defaultInterpolatedStringHandler.AppendFormatted((parent3 != null) ? ((Object)parent3).name : null); defaultInterpolatedStringHandler.AppendLiteral("\n "); l.LogInfo((object)(defaultInterpolatedStringHandler.ToStringAndClear() + string.Join("\n ", list))); } catch (Exception ex) { ManualLogSource l2 = Plugin.L; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("organizer: the popup's parts not listed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } l2.LogInfo(val); } } private static Box RectIn(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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c5: 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_00e5: 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) Rect rect = r.rect; float xMin = ((Rect)(ref rect)).xMin; float yMin = ((Rect)(ref rect)).yMin; float xMax = ((Rect)(ref rect)).xMax; float yMax = ((Rect)(ref rect)).yMax; float num = float.MaxValue; float num2 = float.MaxValue; float num3 = float.MinValue; float num4 = float.MinValue; (float, float)[] array = new(float, float)[4] { (xMin, yMin), (xMin, yMax), (xMax, yMin), (xMax, yMax) }; for (int i = 0; i < array.Length; i++) { (float, float) tuple = array[i]; float item = tuple.Item1; float item2 = tuple.Item2; Vector3 val = _plane.InverseTransformPoint(((Transform)r).TransformPoint(new Vector3(item, item2, 0f))); num = Math.Min(num, val.x); num2 = Math.Min(num2, val.y); num3 = Math.Max(num3, val.x); num4 = Math.Max(num4, val.y); } return new Box(num, num2, num3, num4); } private static (float W, float H) Px(Box b) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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) if ((Object)(object)_cam == (Object)null) { return (W: 0f, H: 0f); } Vector3 val = _cam.WorldToScreenPoint(_plane.TransformPoint(new Vector3(b.X0, b.Y0, 0f))); Vector3 val2 = _cam.WorldToScreenPoint(_plane.TransformPoint(new Vector3(b.X1, b.Y1, 0f))); return (W: Math.Abs(val2.x - val.x), H: Math.Abs(val2.y - val.y)); } private static List<Entry> Entries(int c) { //IL_00b5: 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) uint num = 0u; try { BoosterImplant activeBoosterImplant = PersistentInventoryManager.GetActiveBoosterImplant((BoosterImplantCategory)c); if (activeBoosterImplant != null) { num = activeBoosterImplant.InstanceId; } } catch { } List<Entry> list = new List<Entry>(); foreach (BoosterImplantInventoryItem item in Items(c)) { BoosterImplant implant = item.Implant; Entry entry = new Entry { Kind = Inventory.Kind(implant), Name = Words.Name(implant), Body = Words.Of(implant), Id = item.InstanceId, Mine = Inventory.IsMine(item.InstanceId), Uses = implant.Uses, Unending = Lists.Unending(implant), Worth = Words.Worth(implant), Category = (BoosterImplantCategory)c }; entry.New = !entry.Mine && !item.Touched; entry.On = num != 0 && item.InstanceId == num; try { entry.Effect = (BoosterEffectCategory)((implant.Template != null) ? ((int)implant.Template.MainEffectType) : 0); } catch { } list.Add(entry); } return list; } private static List<BoosterImplantInventoryItem> Items(int c) { List<BoosterImplantInventoryItem> list = new List<BoosterImplantInventoryItem>(); List<BoosterImplantInventoryItem> val = Account(c); if (Settings.All.On) { IReadOnlyList<BoosterImplantInventoryItem> readOnlyList = Inventory.Of(c); if (val == null || readOnlyList.Count == 0 || !val.Contains(readOnlyList[0])) { return list; } { foreach (BoosterImplantInventoryItem item in readOnlyList) { if (((item != null) ? item.Implant : null) != null) { list.Add(item); } } return list; } } int num = 0; while (val != null && num < val.Count) { BoosterImplantInventoryItem val2 = val[num]; if (((val2 != null) ? val2.Implant : null) != null && !Inventory.IsMine(val2.InstanceId)) { list.Add(val2); } num++; } return list; } private static List<BoosterImplantInventoryItem> Account(int c) { PersistentInventoryManager current = PersistentInventoryManager.Current; Il2CppReferenceArray<Category> val = (((Object)(object)current != (Object)null && current.m_boosterImplantInventory != null) ? current.m_boosterImplantInventory.Categories : null); if (val == null || c < 0 || c >= ((Il2CppArrayBase<Category>)(object)val).Length || ((Il2CppArrayBase<Category>)(object)val)[c] == null) { return null; } return ((Il2CppArrayBase<Category>)(object)val)[c].Inventory; } private static int CountOf(int c, bool favouritesOnly) { List<BoosterImplantInventoryItem> list = Items(c); if (!favouritesOnly) { return list.Count; } return list.Count((BoosterImplantInventoryItem it) => Settings.IsFavourite(Inventory.Kind(it.Implant))); } private static List<(string Name, List<Entry> Entries)> Group(List<Entry> entries) { return (from g in (from e in entries group e by e.Name).OrderBy<IGrouping<string, Entry>, string>((IGrouping<string, Entry> g) => g.Key, StringComparer.OrdinalIgnoreCase) select (Key: g.Key, g.OrderBy<Entry, string>((Entry e) => Words.Plain(e.Body), StringComparer.OrdinalIgnoreCase).ThenByDescending((Entry e) => e.Worth).ThenBy((Entry e) => e.Id) .ToList())).ToList(); } private static List<List<Cell>> Pages(List<(string Name, List<Entry> Entries)> groups, int max) { List<List<Cell>> list = new List<List<Cell>>(); List<Cell> list2 = new List<Cell>(); foreach (var group in groups) { string item = group.Name; List<Entry> item2 = group.Entries; int num = 0; bool more = false; while (num < item2.Count) { int num2 = 1 + Math.Min(item2.Count - num, 3); if (list2.Count > 0 && list2.Count + num2 > max) { list.Add(list2); list2 = new List<Cell>(); } list2.Add(new Cell { Head = item, HeadCount = item2.Count, More = more }); while (num < item2.Count && list2.Count < max) { list2.Add(new Cell { E = item2[num++] }); } if (num < item2.Count) { list.Add(list2); list2 = new List<Cell>(); more = true; } } } if (list2.Count > 0) { list.Add(list2); } return list; } private static List<List<Cell>> Even(List<(string Name, List<Entry> Entries)> groups, int max) { List<List<Cell>> list = Pages(groups, max); if (list.Count < 2) { return list; } for (int num = (list.Sum((List<Cell> p) => p.Count) + list.Count - 1) / list.Count; num < max; num++) { List<List<Cell>> list2 = Pages(groups, num); if (list2.Count <= list.Count) { return list2; } } return list; } private static List<(Cell C, int Col, int Row)> Place(List<Cell> cells, int cols, int rows) { List<(Cell, int, int)> list = new List<(Cell, int, int)>(); int num = 0; int num2 = 0; Cell cell = null; foreach (Cell cell2 in cells) { if (cell2.E == null) { i