using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; using TMPro; using ToggleCardsCategories.Extensions; using ToggleCardsCategories.Patches; using ToggleCardsCategories.ScriptableObjects; using ToggleCardsCategories.UI; using UnboundLib; using UnboundLib.Utils; using UnboundLib.Utils.UI; using UnityEngine; using UnityEngine.Events; using UnityEngine.Serialization; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ToggleCardsCategories { public struct ToggleCardCategoryInfo { public string Name; public int? Priority; public ToggleCardCategoryInfo(string name, int? priority = null) { Name = name; Priority = priority; } } public interface IToggleCardCategory { ToggleCardCategoryInfo GetCardCategoryInfo(); } public class ToggleCardsCategoriesManager : MonoBehaviour { public readonly Dictionary Menus = new Dictionary(); internal readonly Dictionary> CardsNameToMenuMapping = new Dictionary>(); private List registeredCategories = new List(); public static ToggleCardsCategoriesManager instance { get; internal set; } public IReadOnlyList RegisteredCategories => registeredCategories.AsReadOnly(); public void RegisterCategories(string category) { if (!registeredCategories.Contains(category)) { registeredCategories.Add(category); } } public ToggleCardsCategoryMenu[] GetCategoriesByMod(string ModPrefix) { string modPrefix = ModPrefix.Split(new char[1] { '/' }).First(); return (from menu in Menus where menu.Key.StartsWith(modPrefix) select menu into m select m.Value).ToArray(); } public ToggleCardsCategoryMenu AddToggleCardToCategory(GameObject parent, GameObject toggleCard, string categoryPath, string modPrefix) { if (!Menus.ContainsKey(modPrefix + "/" + categoryPath)) { CreateToggleCardsCategoryMenu(parent, categoryPath, modPrefix); } ToggleCardsCategoryMenu toggleCardsCategoryMenu = Menus[modPrefix + "/" + categoryPath]; toggleCardsCategoryMenu.AddToggleCardToCategory(toggleCard); if (!CardsNameToMenuMapping.ContainsKey(modPrefix)) { CardsNameToMenuMapping.Add(modPrefix, new Dictionary()); } CardsNameToMenuMapping[modPrefix].Add(((Object)toggleCard).name, toggleCardsCategoryMenu); return toggleCardsCategoryMenu; } private void CreateToggleCardsCategoryMenu(GameObject parent, string categoryPath, string modPrefix) { string[] array = categoryPath.Split(new char[1] { '/' }); string text = array[0]; GameObject val = parent; ToggleCardsCategoryMenu toggleCardsCategoryMenu = null; for (int i = 0; i < array.Length; i++) { string text2 = array[i]; if (i > 0) { text = text + "/" + text2; } if (Menus.ContainsKey(modPrefix + "/" + text)) { ToggleCardsCategoryMenu toggleCardsCategoryMenu2 = Menus[modPrefix + "/" + text]; val = toggleCardsCategoryMenu2.categoriesContent; toggleCardsCategoryMenu = toggleCardsCategoryMenu2; } else if (!Menus.ContainsKey(modPrefix + "/" + text)) { GameObject obj = Object.Instantiate(ToggleCardsCategoryMenu.Prefab); obj.transform.SetParent(val.transform, false); ToggleCardsCategoryMenu component = obj.GetComponent(); ((TMP_Text)component.categoryText).text = text2; component.categoryDepth = i; Menus.Add(modPrefix + "/" + text, component); if (Object.op_Implicit((Object)(object)toggleCardsCategoryMenu)) { toggleCardsCategoryMenu.categories.Add(component); toggleCardsCategoryMenu.categoriesContent.SetActive(true); component.parentCategory = toggleCardsCategoryMenu; } component.viewport.SetActive(false); ((Selectable)component.dropdownButton).image.sprite = component.dropdownCloseImage; val = component.categoriesContent; toggleCardsCategoryMenu = component; } } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.aalund13.rounds.toggle_cards_categories", "ToggleCardsCategories", "1.5.1")] [BepInProcess("Rounds.exe")] public class ToggleCardsCategories : BaseUnityPlugin { private const string modId = "com.aalund13.rounds.toggle_cards_categories"; private const string modName = "ToggleCardsCategories"; internal static ToggleCardsCategories Instance; internal static AssetBundle Assets; private void Awake() { //IL_000b: 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_001b: Expected O, but got Unknown Instance = this; Harmony val = new Harmony("com.aalund13.rounds.toggle_cards_categories"); val.PatchAll(); ToggleCardsMenuHandlerPatch.PatchUpdateCategoryVisuals(val); Assets = AssetUtils.LoadAssetBundleFromResources("togglecardscategories_assets", typeof(ToggleCardsCategories).Assembly); ToggleCardsCategoriesManager.instance = ((Component)this).gameObject.AddComponent(); ToggleCardsCategoryMenu.Prefab = Assets.LoadAsset("CardsCatagory"); Unbound.RegisterClientSideMod("com.aalund13.rounds.toggle_cards_categories"); Debug.Log("ToggleCardsCategories loaded!"); } private void Start() { Debug.Log("ToggleCardsCategories started!"); } } } namespace ToggleCardsCategories.Utils { public enum CategorySourceType { FromPath, FromScriptableObject } public class AddToToggleCardCategory : MonoBehaviour, IToggleCardCategory { [Tooltip("Determines how the category is defined — via a path string or a ScriptableObject reference.")] [SerializeField] private CategorySourceType sourceType; [Tooltip("The path for the category. Example: \"Classes/MyClassHere\" creates 'MyClassHere' under 'Classes'.")] [FormerlySerializedAs("CategoryPath")] [SerializeField] private string categoryPath; [HideInInspector] [SerializeField] private string CategoryPath; [Tooltip("If SourceType is 'FromScriptableObject', assign a ScriptableObject that defines the category.")] [SerializeField] private ToggleCardCategory categoryAsset; [Tooltip("Sets the position (priority) of the category in the toggle mod category list.")] public int Priority; public ToggleCardCategoryInfo GetCardCategoryInfo() { OnValidate(); if (sourceType != CategorySourceType.FromScriptableObject) { return new ToggleCardCategoryInfo(categoryPath, Priority); } return new ToggleCardCategoryInfo(categoryAsset.CategoryPath, categoryAsset.Priority); } public void SetCategoryFromPath(string path) { sourceType = CategorySourceType.FromPath; categoryPath = path.Trim(); } public void SetCategoryFromScriptableObject(ToggleCardCategory category) { sourceType = CategorySourceType.FromScriptableObject; categoryAsset = category; } private void OnValidate() { if (!string.IsNullOrEmpty(CategoryPath) && string.IsNullOrEmpty(categoryPath)) { categoryPath = CategoryPath.Trim(); CategoryPath = string.Empty; Debug.LogWarning((object)("[AddToToggleCardCategory] '" + ((Object)((Component)this).gameObject).name + "' was using legacy field 'CategoryPath'. It has been migrated to 'categoryPath'. Please re-save the prefab or scene."), (Object)(object)this); } } } } namespace ToggleCardsCategories.UI { public class ToggleCardsCategoryMenu : MonoBehaviour { public static GameObject Prefab; [SerializeField] private Sprite dropdownOpenImage; [SerializeField] internal Sprite dropdownCloseImage; [SerializeField] private Toggle toggleCardsButton; [SerializeField] internal Button dropdownButton; [SerializeField] internal GameObject viewport; [SerializeField] internal GameObject cardsContent; [SerializeField] internal GameObject categoriesContent; [SerializeField] private GameObject darkenEffect; [SerializeField] private GridLayoutGroup gridLayoutGroup; [SerializeField] internal TextMeshProUGUI categoryText; internal List cardsInfo = new List(); internal List categories = new List(); internal ToggleCardsCategoryMenu parentCategory; internal List categoryContent = new List(); internal List categoryCardsContent = new List(); internal int categoryDepth; private bool LockIsDropdown; private bool updateVisualRequest; public int Priority { get { return ExtensionMethods.GetOrAddComponent(((Component)this).gameObject, false).layoutPriority; } set { ExtensionMethods.GetOrAddComponent(((Component)this).gameObject, false).layoutPriority = value; } } private bool isDisable { get { bool num = categories.Count == 0 || categories.All((ToggleCardsCategoryMenu c) => c.isDisable); bool flag = true; if (cardsInfo.Count > 0) { List cardNames = cardsInfo.Select((CardInfo ci) => ((Object)ci).name).ToList(); flag = CardManager.cards.Values.Where((Card c) => ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(c.category) && cardNames.Contains(((Object)c.cardInfo).name)).All((Card c) => !c.enabled); } return num && flag; } } private bool isPreviousCategoryDisable { get { ToggleCardsCategoryMenu toggleCardsCategoryMenu = parentCategory; while ((Object)(object)toggleCardsCategoryMenu != (Object)null) { if (toggleCardsCategoryMenu.isDisable) { return true; } toggleCardsCategoryMenu = toggleCardsCategoryMenu.parentCategory; } return false; } } public void DisableCategory() { CardManager.DisableCards(cardsInfo.ToArray(), true); foreach (GameObject item in categoryCardsContent) { ToggleCardsMenuHandler.UpdateVisualsCardObj(item, (bool?)null); } ToggleDarken(); } public void EnableCategory() { CardManager.EnableCards(cardsInfo.ToArray(), true); foreach (GameObject item in categoryCardsContent) { ToggleCardsMenuHandler.UpdateVisualsCardObj(item, (bool?)null); } ToggleDarken(); } public void CollapseCategory() { if (viewport.activeSelf) { viewport.SetActive(false); ((Selectable)dropdownButton).image.sprite = dropdownCloseImage; Debug.Log((object)(((TMP_Text)categoryText).text + " have been collapse")); } } public void ExpandCategory() { if (viewport.activeSelf) { return; } viewport.SetActive(true); ((Selectable)dropdownButton).image.sprite = dropdownOpenImage; foreach (GameObject item in categoryCardsContent) { ToggleCardsMenuHandler.UpdateVisualsCardObj(item, (bool?)null); } Debug.Log((object)(((TMP_Text)categoryText).text + " have been expanded")); } public void ToggleCategory(bool toggle) { if (toggle) { CardManager.EnableCards(cardsInfo.ToArray(), true); } else { CardManager.DisableCards(cardsInfo.ToArray(), true); } foreach (GameObject item in categoryCardsContent) { ToggleCardsMenuHandler.UpdateVisualsCardObj(item, (bool?)null); } foreach (ToggleCardsCategoryMenu category in categories) { category.ToggleCategory(toggle); } ToggleDarken(); } public void ToggleDropdown() { if (viewport.activeSelf) { CollapseCategory(); } else { ExpandCategory(); } } public void RequestUpdateVisual() { if (!updateVisualRequest) { updateVisualRequest = true; ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)ToggleCardsCategories.Instance, 1, (Action)delegate { updateVisualRequest = false; UpdateVisual(); }); } } public void UpdateVisual() { bool flag = isDisable; ((UnityEventBase)toggleCardsButton.onValueChanged).RemoveAllListeners(); toggleCardsButton.isOn = !flag; ((UnityEvent)(object)toggleCardsButton.onValueChanged).AddListener((UnityAction)ToggleCategory); ToggleDarken(); Queue queue = new Queue(); foreach (ToggleCardsCategoryMenu category in categories) { queue.Enqueue(category); } while (queue.Count > 0) { ToggleCardsCategoryMenu toggleCardsCategoryMenu = queue.Dequeue(); foreach (ToggleCardsCategoryMenu category2 in toggleCardsCategoryMenu.categories) { queue.Enqueue(category2); } toggleCardsCategoryMenu.ToggleDarken(); } if ((Object)(object)parentCategory != (Object)null) { parentCategory.UpdateVisual(); } } public void LockDropdown() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!LockIsDropdown) { Image image = ((Selectable)dropdownButton).image; ((Graphic)image).color = ((Graphic)image).color / 2f; } } public void UnLockDropdown() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (LockIsDropdown) { Image image = ((Selectable)dropdownButton).image; ((Graphic)image).color = ((Graphic)image).color * 2f; } } private void ToggleDarken() { if (isDisable && !isPreviousCategoryDisable) { darkenEffect.SetActive(true); } else { darkenEffect.SetActive(false); } } internal void AddToggleCardToCategory(GameObject toggleCard) { toggleCard.transform.SetParent(cardsContent.transform, false); categoryContent.Add(toggleCard); categoryCardsContent.Add(toggleCard); cardsInfo.Add(CardManager.GetCardInfoWithName(((Object)toggleCard).name)); } internal void SetGridSize(int amount) { //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gridLayoutGroup == (Object)null) { return; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(220f, 300f); float num = 1.5f; if (amount > 3) { switch (amount) { case 4: ((Vector2)(ref val))..ctor(170f, 240f); num = 1.2f; break; default: ((Vector2)(ref val))..ctor(136f, 192f); num = 0.9f; break; case 6: ((Vector2)(ref val))..ctor(112f, 158f); num = 0.75f; break; case 7: ((Vector2)(ref val))..ctor(97f, 137f); num = 0.65f; break; case 8: ((Vector2)(ref val))..ctor(85f, 120f); num = 0.55f; break; case 9: ((Vector2)(ref val))..ctor(75f, 106f); num = 0.45f; break; case 10: ((Vector2)(ref val))..ctor(68f, 96f); num = 0.4f; break; } } float num2 = Mathf.Clamp01(1f - 0.015f * (float)(categoryDepth + 1)); gridLayoutGroup.cellSize = val * num2; gridLayoutGroup.constraintCount = amount; foreach (GameObject item in categoryCardsContent) { item.transform.GetChild(2).localScale = num * Vector3.one * 10f * num2; } } } } namespace ToggleCardsCategories.ScriptableObjects { [CreateAssetMenu(fileName = "ToggleCardCategory", menuName = "ToggleCardsCategories/ToggleCardCategory", order = 1)] public class ToggleCardCategory : ScriptableObject { public string CategoryPath = "None"; public int Priority; } } namespace ToggleCardsCategories.Patches { [HarmonyPatch(typeof(ToggleCardsMenuHandler))] internal class ToggleCardsMenuHandlerPatch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func <>9__6_0; public static Func, GameObject> <>9__11_0; public static Func, string> <>9__13_0; public static Action <>9__14_3; public static UnityAction <>9__14_0; public static UnityAction <>9__14_1; public static Func <>9__14_4; public static Action <>9__14_2; public static Func <>9__15_0; internal bool b__6_0(MethodInfo m) { return m.Name.Contains("UpdateCategoryVisuals"); } internal GameObject b__11_0(KeyValuePair c) { return ((Component)c.Value.dropdownButton).gameObject; } internal string b__13_0(KeyValuePair c) { return ((Object)c.Value.dropdownButton).name; } internal void b__14_0(string value) { Debug.Log((object)"Value Chnage"); DelayActionQueue.Clear(); ((MonoBehaviour)ToggleCardsCategoriesManager.instance).StopAllCoroutines(); ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)ToggleCardsCategoriesManager.instance, 1, (Action)delegate { Debug.Log((object)"Delay trigger"); while (DelayActionQueue.Count > 0) { Debug.Log((object)"Invoke Delay Action"); DelayActionQueue.Dequeue()(); } foreach (ToggleCardsCategoryMenu item in MenuToCollapses.ToList()) { if (!ActiveMenus.Contains(item)) { item.CollapseCategory(); MenuToCollapses.Remove(item); } ActiveMenus.Remove(item); } }); } internal void b__14_3() { Debug.Log((object)"Delay trigger"); while (DelayActionQueue.Count > 0) { Debug.Log((object)"Invoke Delay Action"); DelayActionQueue.Dequeue()(); } foreach (ToggleCardsCategoryMenu item in MenuToCollapses.ToList()) { if (!ActiveMenus.Contains(item)) { item.CollapseCategory(); MenuToCollapses.Remove(item); } ActiveMenus.Remove(item); } } internal void b__14_1() { string text = (string)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "currentCategory"); if (ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(text)) { ToggleCardsCategoryMenu[] categoriesByMod = ToggleCardsCategoriesManager.instance.GetCategoriesByMod(text); for (int i = 0; i < categoriesByMod.Length; i++) { categoriesByMod[i].ExpandCategory(); } } } internal void b__14_2() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) Dictionary> dictionary = (Dictionary>)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "cardObjectsInCategory"); foreach (string registeredCategory in ToggleCardsCategoriesManager.instance.RegisteredCategories) { GameObject gameObject = ((Component)dictionary[registeredCategory][0].transform.parent).gameObject; List list = (from Transform t in (IEnumerable)gameObject.transform select ((Component)t).gameObject).ToList(); Object.DestroyImmediate((Object)(object)gameObject.GetComponent()); gameObject.AddComponent(); GameObject val = new GameObject("Categories Content", new Type[1] { typeof(VerticalLayoutGroup) }); VerticalLayoutGroup component = val.GetComponent(); val.transform.SetParent(gameObject.transform, false); ((HorizontalOrVerticalLayoutGroup)component).spacing = 5f; ((LayoutGroup)component).padding = new RectOffset(5, 5, 5, 5); GameObject val2 = new GameObject("Cards Content", new Type[1] { typeof(GridLayoutGroup) }); GridLayoutGroup component2 = val2.GetComponent(); val2.transform.SetParent(gameObject.transform, false); Groups.Add(component2); gameObject.GetComponent().horizontalFit = (FitMode)0; gameObject.GetComponent().sizeDelta = new Vector2(0f, 0f); foreach (GameObject item in list) { IToggleCardCategory component3 = ((Component)item.transform.GetChild(2)).GetComponent(); if (component3 == null || Utility.IsNullOrWhiteSpace(component3.GetCardCategoryInfo().Name)) { item.transform.SetParent(val2.transform); continue; } string name = component3.GetCardCategoryInfo().Name; ToggleCardsCategoryMenu toggleCardsCategoryMenu = ToggleCardsCategoriesManager.instance.AddToggleCardToCategory(val, item, name, registeredCategory); if (component3 != null && component3.GetCardCategoryInfo().Priority.HasValue) { toggleCardsCategoryMenu.Priority = component3.GetCardCategoryInfo().Priority.Value; } } } } internal GameObject b__14_4(Transform t) { return ((Component)t).gameObject; } internal RectTransform b__15_0(Transform cardTransform) { return ExtensionMethods.GetOrAddComponent(((Component)cardTransform.GetChild(2)).gameObject, false); } } public static List Groups = new List(); public static List MenuToCollapses = new List(); public static List ActiveMenus = new List(); public static Queue DelayActionQueue = new Queue(); public static bool AlreadyTrigger = false; public static GameObject expandAllButton; public static void PatchUpdateCategoryVisuals(Harmony harmony) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown Type[] nestedTypes = typeof(ToggleCardsMenuHandler).GetNestedTypes(BindingFlags.NonPublic); foreach (Type type in nestedTypes) { if (type.Name.Contains("DisplayClass23_4")) { MethodInfo methodInfo = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).First((MethodInfo m) => m.Name.Contains("UpdateCategoryVisuals")); MethodInfo methodInfo2 = AccessTools.Method(typeof(ToggleCardsMenuHandlerPatch), "UpdateCategoryVisualsTranspiler", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null); } } } public static IEnumerable UpdateCategoryVisualsTranspiler(IEnumerable instructions, ILGenerator il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0115: 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_011b: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, il); MethodInfo methodInfo = AccessTools.Method(typeof(ToggleCardsMenuHandlerPatch), "ToggleCategorySubmenu", (Type[])null, (Type[])null); FieldInfo fieldInfo = AccessTools.Field(typeof(ToggleCardsMenuHandler).GetNestedType("<>c__DisplayClass23_4", BindingFlags.Instance | BindingFlags.NonPublic), "CS$<>8__locals3"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(ToggleCardsMenuHandler).GetNestedType("<>c__DisplayClass23_3", BindingFlags.Instance | BindingFlags.NonPublic), "category"); bool flag = false; while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"Viewport/Content", (string)null) }).IsValid) { int pos = val.Pos; while (val.IsValid && val.Instruction.opcode != OpCodes.Leave) { val.Advance(1); } if (!val.IsValid) { Debug.LogError((object)"[ToggleCardsCategories] Failed to find the instruction to leave the loop in UpdateCategoryVisualsTranspiler"); break; } CodeInstruction instruction = val.Instruction; ExtensionMethods.SetPropertyValue((object)val, "Pos", (object)pos); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[6] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo), new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo2), flag ? new CodeInstruction(OpCodes.Ldc_I4_0, (object)null) : new CodeInstruction(OpCodes.Ldc_I4_1, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo), new CodeInstruction(OpCodes.Brtrue_S, instruction.operand) }); val.Advance(6); flag = true; } return val.InstructionEnumeration(); } public static bool ToggleCategorySubmenu(string category, bool toggle) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown if (!ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(category)) { return false; } Dictionary dictionary = AccessTools.Field(typeof(ToggleCardsMenuHandler), "scrollViews").GetValue(null) as Dictionary; if ((Object)(object)dictionary[category].Find("Viewport/Content/Cards Content") == (Object)null) { return false; } if (ToggleCardsCategoriesManager.instance.CardsNameToMenuMapping.TryGetValue(category, out var value)) { foreach (ToggleCardsCategoryMenu value2 in value.Values) { value2.ToggleCategory(toggle); } } foreach (Transform item in dictionary[category].Find("Viewport/Content/Cards Content")) { Transform val = item; if (toggle) { CardManager.EnableCard(CardManager.GetCardInfoWithName(((Object)val).name), true); } else { CardManager.DisableCard(CardManager.GetCardInfoWithName(((Object)val).name), true); } } return true; } [HarmonyPatch("ChangeCardColumnAmountMenus")] [HarmonyPrefix] public static void ChangeCardColumnAmountMenusPrefex(int amount) { foreach (string registeredCategory in ToggleCardsCategoriesManager.instance.RegisteredCategories) { CardManager.categories.Remove(registeredCategory); } } [HarmonyPatch("ChangeCardColumnAmountMenus")] [HarmonyPostfix] public static void ChangeCardColumnAmountMenusPostfix(int amount) { foreach (string registeredCategory in ToggleCardsCategoriesManager.instance.RegisteredCategories) { CardManager.categories.Add(registeredCategory); } foreach (ToggleCardsCategoryMenu value in ToggleCardsCategoriesManager.instance.Menus.Values) { value.SetGridSize(amount); } SetGridsSize(amount); } [HarmonyPatch("UpdateVisualsCardObj")] [HarmonyPrefix] public static bool UpdateVisualsCardObjPrefix(GameObject cardObject) { if (ToggleCardsCategoriesManager.instance.Menus.Select((KeyValuePair c) => ((Component)c.Value.dropdownButton).gameObject).Contains(cardObject)) { return false; } if (ToggleCardsCategoriesManager.instance.CardsNameToMenuMapping.TryGetValue((string)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "currentCategory"), out var value) && value.TryGetValue(((Object)cardObject).name, out var value2)) { value2.RequestUpdateVisual(); } return true; } [HarmonyPatch("EnableCardsInCategory")] [HarmonyPrefix] public static void EnableCardsInCategoryPrefex(string category) { if (ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(category)) { expandAllButton.SetActive(true); } else { expandAllButton.SetActive(false); } } [HarmonyPatch("ActiveOnSearch")] [HarmonyPostfix] public static void ActiveOnSearchPostfix(string cardName, ref bool __result) { string text = (string)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "currentCategory"); string text2 = (string)ExtensionMethods.GetFieldValue((object)ToggleCardsMenuHandler.instance, "currentSearch"); ToggleCardsCategoryMenu menu = default(ToggleCardsCategoryMenu); if ((ToggleCardsCategoriesManager.instance.RegisteredCategories.Contains(text) && ToggleCardsCategoriesManager.instance.CardsNameToMenuMapping[text].TryGetValue(cardName, out menu)) & __result) { if (text2 != "") { DelayActionQueue.Enqueue(delegate { if (!menu.viewport.activeSelf) { menu.ExpandCategory(); if (!MenuToCollapses.Contains(menu)) { MenuToCollapses.Add(menu); } } ToggleCardsCategoryMenu parentCategory2 = menu.parentCategory; while ((Object)(object)parentCategory2 != (Object)null) { if (!parentCategory2.viewport.activeSelf) { parentCategory2.ExpandCategory(); if (!MenuToCollapses.Contains(parentCategory2)) { MenuToCollapses.Add(parentCategory2); } } parentCategory2 = parentCategory2.parentCategory; } }); if (!ActiveMenus.Contains(menu)) { ActiveMenus.Add(menu); } ToggleCardsCategoryMenu parentCategory = menu.parentCategory; while ((Object)(object)parentCategory != (Object)null) { if (!ActiveMenus.Contains(parentCategory)) { ActiveMenus.Add(parentCategory); } parentCategory = parentCategory.parentCategory; } } else { foreach (ToggleCardsCategoryMenu menuToCollapse in MenuToCollapses) { if (ActiveMenus.Contains(menuToCollapse)) { ActiveMenus.Remove(menuToCollapse); } } } } if (ToggleCardsCategoriesManager.instance.Menus.Select((KeyValuePair c) => ((Object)c.Value.dropdownButton).name).Contains(cardName)) { __result = true; } } [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPostfix() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown GameObject gameObject = ((Component)ToggleCardsMenuHandler.cardMenuCanvas.transform.Find("CardMenu/Top/InputField")).gameObject; GameObject gameObject2 = ((Component)ToggleCardsMenuHandler.cardMenuCanvas.transform.Find("CardMenu/Top/ToggleAll")).gameObject; ((UnityEvent)(object)gameObject.GetComponent().onValueChanged).AddListenerLast(delegate { Debug.Log((object)"Value Chnage"); DelayActionQueue.Clear(); ((MonoBehaviour)ToggleCardsCategoriesManager.instance).StopAllCoroutines(); ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)ToggleCardsCategoriesManager.instance, 1, (Action)delegate { Debug.Log((object)"Delay trigger"); while (DelayActionQueue.Count > 0) { Debug.Log((object)"Invoke Delay Action"); DelayActionQueue.Dequeue()(); } foreach (ToggleCardsCategoryMenu item in MenuToCollapses.ToList()) { if (!ActiveMenus.Contains(item)) { item.CollapseCategory(); MenuToCollapses.Remove(item); } ActiveMenus.Remove(item); } }); }); expandAllButton = Object.Instantiate(gameObject2, gameObject2.transform.parent); ((TMP_Text)expandAllButton.GetComponentInChildren()).text = "Expand All"; ((UnityEventBase)expandAllButton.GetComponent