Decompiled source of UpgradesMenu v1.0.0

UpgradesMenu.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CardDataLib;
using CardRenderer;
using CardsShared;
using HarmonyLib;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UpgradesMenu.Integrations;
using UpgradesMenu.Menu.Logic;
using UpgradesMenu.Menu.Style;
using UpgradesMenu.Menu.Style.Card;
using UpgradesMenu.Menu.Style.Panel;
using UpgradesMenu.Menu.UI.Buttons;
using UpgradesMenu.Menu.UI.CardTreeLoader;
using UpgradesMenu.Menu.UI.Components;
using UpgradesMenu.Menu.UI.PanelsLoader;
using UpgradesMenu.StateManagement;
using UpgradesMenu.StateManagement.Runtime;
using UpgradesMenu.Utility;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("UpgradesMenu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5ba33cbd70c4364e5670c6d0b39fdb00e3bded17")]
[assembly: AssemblyProduct("UpgradesMenu")]
[assembly: AssemblyTitle("UpgradesMenu")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UpgradesMenu
{
	[BepInPlugin("AgusBut.UpgradesMenu", "UpgradesMenu", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance { get; private set; }

		public static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			ConfigManager.Initialize((BaseUnityPlugin)(object)this);
			SceneHooks.Register();
			CardSyncHandler.Register();
			Harmony val = new Harmony("AgusBut.UpgradesMenu");
			val.PatchAll();
			BanishCard_Patch.ApplyIfAvailable(val);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"UpgradesMenu loaded successfully.");
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			MenuHelper.HandleMenuInput(ConfigManager.ToggleKey.Value);
		}

		private void OnDestroy()
		{
			CardSyncHandler.Unregister();
		}

		internal static bool UseRedMonsterColors()
		{
			return RedMonsterCardsInterop.IsModPresent() && !ConfigManager.OverrideRedMonsterCards.Value;
		}
	}
}
namespace UpgradesMenu.Utility
{
	internal class MonsterModeHook
	{
		internal static void HookMonsterToggle()
		{
			Toggle[] array = Object.FindObjectsOfType<Toggle>(true);
			foreach (Toggle val in array)
			{
				if (((Object)val).name == "MonsterMode")
				{
					GameModeCheck.ChallengeMode.IsMonsterModeEnabled = val.isOn;
					((UnityEvent<bool>)(object)val.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn)
					{
						GameModeCheck.ChallengeMode.IsMonsterModeEnabled = isOn;
					});
					break;
				}
			}
		}

		private static void OnPlayClicked()
		{
			GameObject val = GameObject.Find("Canvas/PlayMenu/Scaler/ChallengePanel/MonsterMode");
			if ((Object)(object)val != (Object)null)
			{
				Toggle component = val.GetComponent<Toggle>();
				if ((Object)(object)component != (Object)null)
				{
					GameModeCheck.ChallengeMode.IsMonsterModeEnabled = component.isOn;
				}
				else
				{
					Plugin.Log.LogWarning((object)"Toggle component not found on MonsterMode");
				}
			}
		}
	}
	internal class ColorsHelper
	{
		public static Color Black = new Color(0.196f, 0.196f, 0.196f, 1f);

		public static Color Grey = new Color(0.514f, 0.502f, 0.514f, 1f);

		public static Color White = new Color(1f, 1f, 1f, 1f);

		public static Color Green = new Color(0.635f, 0.741f, 0.451f, 1f);

		public static Color DeepGreen = new Color(0.259f, 0.403f, 0.155f, 1f);

		public static Color Blue = new Color(0.471f, 0.529f, 0.667f, 1f);

		public static Color DeepBlue = new Color(0f, 0f, 0.286f, 1f);

		public static Color Red = new Color(0.667f, 0.333f, 0.251f, 1f);

		public static Color DeepRed = new Color(0.323f, 0.054f, 0.05f, 1f);

		public static Color Purple = new Color(0.46f, 0.093f, 0.903f, 1f);

		public static Color DeepPurple = new Color(0.369f, 0.157f, 0.569f, 1f);

		public static Color Orange = new Color(0.544f, 0.411f, 0.265f, 1f);

		public static Color DeepOrange = new Color(0.612f, 0.478f, 0.208f, 1f);

		public static Color GetContrastByName(string colorName)
		{
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: 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_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(colorName.ToLower() switch
			{
				"blue" => DeepBlue, 
				"deepblue" => Blue, 
				"red" => DeepRed, 
				"deepred" => Red, 
				"green" => DeepGreen, 
				"deepgreen" => Green, 
				"purple" => DeepPurple, 
				"deeppurple" => Purple, 
				"orange" => DeepOrange, 
				"deeporange" => Orange, 
				"black" => Grey, 
				"grey" => Black, 
				"white" => Grey, 
				_ => Grey, 
			});
		}
	}
	internal static class ConfigManager
	{
		internal static ConfigEntry<string> ActivePanelColor;

		internal static ConfigEntry<string> ActiveCardColor;

		internal static ConfigEntry<string> PassivePanelColor;

		internal static ConfigEntry<string> PassiveCardColor;

		internal static ConfigEntry<string> MonsterPanelColor;

		internal static ConfigEntry<string> MonsterCardColor;

		internal static ConfigEntry<bool> OverrideRedMonsterCards;

		internal static ConfigEntry<string> BanishCardColor;

		internal static ConfigEntry<KeyCode> ToggleKey;

		internal static ConfigEntry<float> DefaultZoom;

		internal static ConfigEntry<float> ZoomSpeed;

		internal static ConfigEntry<float> MinZoom;

		internal static ConfigEntry<float> MaxZoom;

		internal static void Initialize(BaseUnityPlugin plugin)
		{
			string text = "Can be: White, Grey, Black, Blue, Orange, Red, Green, Purple, DeepBlue, DeepBrown, DeepRed, DeepGreen, DeepPurple";
			ActivePanelColor = plugin.Config.Bind<string>("Appearance", "ActivePanelColor", "Orange", text);
			ActiveCardColor = plugin.Config.Bind<string>("Appearance", "ActiveCardColor", "Orange", text);
			PassivePanelColor = plugin.Config.Bind<string>("Appearance", "PassivePanelColor", "Blue", text);
			PassiveCardColor = plugin.Config.Bind<string>("Appearance", "PassiveCardColor", "Blue", text);
			MonsterPanelColor = plugin.Config.Bind<string>("Appearance", "MonsterPanelColor", "Blue", text);
			MonsterCardColor = plugin.Config.Bind<string>("Appearance", "MonsterCardColor", "Blue", text);
			OverrideRedMonsterCards = plugin.Config.Bind<bool>("Compatibility", "OverrideRedMonsterCards", false, "Override monster card colors if RedMonsterCards mod is installed.");
			BanishCardColor = plugin.Config.Bind<string>("Compatibility", "BanishCardColor", "White", text);
			ToggleKey = plugin.Config.Bind<KeyCode>("Input", "ToggleKey", (KeyCode)9, "Toggles the UpgradesMenu");
			DefaultZoom = plugin.Config.Bind<float>("Zoom", "DefaultZoom", 0.5f, "Zoom on first open");
			ZoomSpeed = plugin.Config.Bind<float>("Zoom", "ZoomSpeed", 10f, "Zoom speed for the sliding screen");
			MinZoom = plugin.Config.Bind<float>("Zoom", "MinZoom", 0.25f, "Minimum zoom level");
			MaxZoom = plugin.Config.Bind<float>("Zoom", "MaxZoom", 2f, "Maximum zoom level");
		}
	}
	internal class GameModeCheck
	{
		public static class ChallengeMode
		{
			public static bool IsMonsterModeEnabled;
		}
	}
	internal class Layers
	{
		internal static void AddInvisibleBackground(GameObject slidingScreenGO)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Background", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val.transform.SetParent(slidingScreenGO.transform, false);
			val.transform.SetSiblingIndex(0);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = GetSlidingScreen10xContentSize(slidingScreenGO);
			component.anchoredPosition = new Vector2(0f, 0f);
			Image component2 = val.GetComponent<Image>();
			((Graphic)component2).color = new Color(0f, 0f, 0f, 0f);
			((Graphic)component2).raycastTarget = true;
		}

		private static Vector2 GetSlidingScreen10xContentSize(GameObject slidingScreenGO)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = slidingScreenGO.GetComponent<RectTransform>();
			if ((Object)(object)component == (Object)null || ((Transform)component).childCount == 0)
			{
				return Vector2.zero;
			}
			Bounds val = RectTransformUtility.CalculateRelativeRectTransformBounds(slidingScreenGO.transform);
			Vector3 size = ((Bounds)(ref val)).size;
			Vector2 result = default(Vector2);
			((Vector2)(ref result))..ctor(10f * size.x, 10f * size.y);
			return result;
		}
	}
	internal class SpriteHelper
	{
		private static readonly Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>();

		internal static Sprite FindSpriteByName(string spriteName)
		{
			if (_spriteCache.TryGetValue(spriteName, out var value))
			{
				return value;
			}
			Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>();
			foreach (Sprite val in array)
			{
				if (((Object)val).name == spriteName)
				{
					_spriteCache[spriteName] = val;
					return val;
				}
			}
			return null;
		}
	}
}
namespace UpgradesMenu.StateManagement
{
	internal static class CardSyncHandler
	{
		internal static void Register()
		{
			Plugin.OnCardSyncComplete += HandleCardSyncComplete;
		}

		private static void HandleCardSyncComplete()
		{
			//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)
			if (Plugin.UseRedMonsterColors())
			{
				ConfigManager.MonsterPanelColor.Value = "DeepRed";
				ConfigManager.MonsterCardColor.Value = "DeepRed";
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "GameScene")
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(LoadUpgradeMenu());
			}
		}

		private static IEnumerator LoadUpgradeMenu()
		{
			bool menuReady = false;
			yield return MenuManager.LoadMenuWhenSceneIsReady(delegate
			{
				menuReady = true;
				StatusUpdater.UpdateCardsSlicesAtStart();
			});
			yield return (object)new WaitUntil((Func<bool>)(() => menuReady));
		}

		internal static void Unregister()
		{
			Plugin.OnCardSyncComplete -= HandleCardSyncComplete;
		}
	}
	internal class StatusUpdater
	{
		internal static void UpdateCardsSlicesAtStart()
		{
			//IL_0036: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			CardDisplayData card = CardDataLibAPI.GetCard("Ballista", "Ballista");
			string text = "GameUI/UpgradesMenu/SlidingScreen/ActiveCards/TowerCards/Ballista/Ballista";
			if (card.Unlocked)
			{
				StyleManager.CardVisualStyle cardStyle = StyleManager.GetCardStyle(StyleManager.StyleType.Active);
				CardRendererAPI.SwapCardSlice(text, cardStyle.SliceUnlocked, (Color?)cardStyle.IconColor, (Color?)cardStyle.TextColor);
			}
			Subcategory[] array = new Subcategory[15];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Subcategory[] array2 = (Subcategory[])(object)array;
			Subcategory[] array3 = array2;
			for (int i = 0; i < array3.Length; i++)
			{
				Subcategory value = array3[i];
				string text2 = ((object)(Subcategory)(ref value)).ToString();
				CardDisplayData card2 = CardDataLibAPI.GetCard(text2, text2);
				if (card2 == null || !card2.Unlocked)
				{
					continue;
				}
				List<CardDisplayData> list = CardDataLibAPI.FilterCards((Category?)(Category)0, (Subcategory?)value, (AcquisitionType?)(AcquisitionType)4, (bool?)null);
				foreach (CardDisplayData item in list)
				{
					string text3 = "GameUI/UpgradesMenu/SlidingScreen/PassiveCards/TowerCards/" + text2 + "/" + item.UnlockName;
					StyleManager.CardVisualStyle cardStyle2 = StyleManager.GetCardStyle(StyleManager.StyleType.Passive);
					if (item.Unlocked)
					{
						CardRendererAPI.SwapCardSlice(text3, cardStyle2.SliceUnlocked, (Color?)cardStyle2.IconColor, (Color?)cardStyle2.TextColor);
					}
					else
					{
						CardRendererAPI.SwapCardSlice(text3, cardStyle2.SliceLocked, (Color?)cardStyle2.IconColor, (Color?)cardStyle2.TextColor);
					}
				}
			}
			Subcategory[] array4 = new Subcategory[4];
			RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Subcategory[] array5 = (Subcategory[])(object)array4;
			Subcategory[] array6 = array5;
			for (int j = 0; j < array6.Length; j++)
			{
				Subcategory value2 = array6[j];
				string text4 = ((object)(Subcategory)(ref value2)).ToString();
				List<CardDisplayData> list2 = CardDataLibAPI.FilterCards((Category?)(Category)3, (Subcategory?)value2, (AcquisitionType?)(AcquisitionType)4, (bool?)null);
				foreach (CardDisplayData item2 in list2)
				{
					string text5 = "GameUI/UpgradesMenu/SlidingScreen/PassiveCards/BuffCards/" + text4 + "/" + item2.UnlockName;
					StyleManager.CardVisualStyle cardStyle3 = StyleManager.GetCardStyle(StyleManager.StyleType.Passive);
					if (item2.Unlocked)
					{
						CardRendererAPI.SwapCardSlice(text5, cardStyle3.SliceUnlocked, (Color?)cardStyle3.IconColor, (Color?)cardStyle3.TextColor);
					}
					else
					{
						CardRendererAPI.SwapCardSlice(text5, cardStyle3.SliceLocked, (Color?)cardStyle3.IconColor, (Color?)cardStyle3.TextColor);
					}
				}
			}
		}
	}
}
namespace UpgradesMenu.StateManagement.Runtime
{
	internal static class ActiveCardsInstance
	{
		private static List<UpgradeCard> prevNormal = new List<UpgradeCard>();

		private static List<UpgradeCard> prevMonster = new List<UpgradeCard>();

		internal static readonly FieldRef<UpgradeCard, string> unlockNameRef = AccessTools.FieldRefAccess<UpgradeCard, string>("unlockName");

		internal static void SnapshotNormal(List<UpgradeCard> currentNormal)
		{
			prevNormal = new List<UpgradeCard>(currentNormal);
		}

		internal static void SnapshotMonster(List<UpgradeCard> currentMonster)
		{
			prevMonster = new List<UpgradeCard>(currentMonster);
		}

		internal static List<UpgradeCard> GetRemovedCards(List<UpgradeCard> current, bool isNormal)
		{
			List<UpgradeCard> source = (isNormal ? prevNormal : prevMonster);
			HashSet<string> currentNames = new HashSet<string>(current.Select((UpgradeCard card) => unlockNameRef.Invoke(card)));
			return source.Where(delegate(UpgradeCard card)
			{
				string item = unlockNameRef.Invoke(card);
				return !currentNames.Contains(item);
			}).ToList();
		}

		internal static bool WasCardRemoved(UpgradeCard card, List<UpgradeCard> current, bool isNormal)
		{
			return (isNormal ? prevNormal : prevMonster).Contains(card) && !current.Contains(card);
		}
	}
	internal static class SceneHooks
	{
		internal static void Register()
		{
			SceneManager.activeSceneChanged += OnActiveSceneChanged;
		}

		private static void OnActiveSceneChanged(Scene oldScene, Scene newScene)
		{
			if (((Scene)(ref newScene)).name == "MainMenu")
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(DelayButtonHook());
			}
		}

		private static IEnumerator DelayButtonHook()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)GameObject.Find("Canvas/PlayMenu/Scaler/ChallengePanel/MonsterMode") != (Object)null));
			MonsterModeHook.HookMonsterToggle();
		}
	}
}
namespace UpgradesMenu.StateManagement.Patches
{
	[HarmonyPatch(typeof(CardManager), "ActivateCard")]
	internal class ActivateCard_Patch
	{
		private static void Prefix(CardManager __instance)
		{
			ActiveCardsInstance.SnapshotNormal(GetList(__instance, "availableCards"));
		}

		private static void Postfix(CardManager __instance)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			List<UpgradeCard> list = GetList(__instance, "availableCards");
			StyleManager.CardVisualStyle cardStyle = StyleManager.GetCardStyle(StyleManager.StyleType.Active);
			foreach (UpgradeCard removedCard in ActiveCardsInstance.GetRemovedCards(list, isNormal: true))
			{
				string text = ActiveCardsInstance.unlockNameRef.Invoke(removedCard);
				CardDisplayData card = CardDataLibAPI.GetCard(text, (string)null);
				if (card != null)
				{
					string text2 = ((object)(Category)(ref card.Category)).ToString();
					string text3 = ((object)(Subcategory)(ref card.Subcategory)).ToString();
					string text4 = "GameUI/UpgradesMenu/SlidingScreen/ActiveCards/" + text2 + "Cards/" + text3 + "/" + text;
					CardRendererAPI.SwapCardSlice(text4, cardStyle.SliceUnlocked, (Color?)cardStyle.IconColor, (Color?)cardStyle.TextColor);
				}
			}
			ActiveCardsInstance.SnapshotNormal(list);
		}

		private static List<UpgradeCard> GetList(CardManager cm, string fieldName)
		{
			return AccessTools.Field(typeof(CardManager), fieldName).GetValue(cm) as List<UpgradeCard>;
		}
	}
	[HarmonyPatch(typeof(CardManager), "ActivateMonsterCard")]
	internal class ActivateMonsterCard_Patch
	{
		private static void Prefix(CardManager __instance)
		{
			ActiveCardsInstance.SnapshotMonster(GetList(__instance, "availableMonsterCards"));
		}

		private static void Postfix(CardManager __instance)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			List<UpgradeCard> list = GetList(__instance, "availableMonsterCards");
			StyleManager.CardVisualStyle cardStyle = StyleManager.GetCardStyle(StyleManager.StyleType.Monster);
			foreach (UpgradeCard removedCard in ActiveCardsInstance.GetRemovedCards(list, isNormal: false))
			{
				string text = ActiveCardsInstance.unlockNameRef.Invoke(removedCard);
				CardDisplayData card = CardDataLibAPI.GetCard(text, (string)null);
				if (card != null)
				{
					string text2 = ((object)(Category)(ref card.Category)).ToString();
					string text3 = ((object)(Subcategory)(ref card.Subcategory)).ToString();
					string text4 = "GameUI/UpgradesMenu/SlidingScreen/MonsterCards/" + text2 + "Cards/" + text3 + "/" + text;
					CardRendererAPI.SwapCardSlice(text4, cardStyle.SliceUnlocked, (Color?)cardStyle.IconColor, (Color?)cardStyle.TextColor);
				}
			}
			ActiveCardsInstance.SnapshotMonster(list);
		}

		private static List<UpgradeCard> GetList(CardManager cm, string fieldName)
		{
			return AccessTools.Field(typeof(CardManager), fieldName).GetValue(cm) as List<UpgradeCard>;
		}
	}
}
namespace UpgradesMenu.Menu.UI.PanelsLoader
{
	internal class ActiveCards
	{
		internal static IEnumerator SetupActiveCards(GameObject slidingScreenGO, string menuPath)
		{
			string prefAspectName = "DefaultHorizontalCard";
			StyleManager.CardVisualStyle cardStyle = StyleManager.GetCardStyle(StyleManager.StyleType.Active);
			StyleManager.PanelVisualStyle panelStyle = StyleManager.GetPanelStyle(StyleManager.StyleType.Active);
			GameObject activeCardsGO = Panels.CreatePanel("ActiveCards", slidingScreenGO.transform);
			Panels.CreatePanel("TowerCards", activeCardsGO.transform);
			yield return Towers.LoadTowerActiveUnlockedCards(menuPath + "/TowerCards", cardStyle.SliceLocked, panelStyle.Slice, prefAspectName, cardStyle.IconColor, cardStyle.TextColor);
			Panels.CreatePanel("DOTCards", activeCardsGO.transform, (Vector2?)new Vector2(-140f, 0f));
			yield return DOT.LoadDOTUnlockedCards(menuPath + "/DOTCards", cardStyle.SliceLocked, panelStyle.Slice, prefAspectName, cardStyle.IconColor, cardStyle.TextColor);
			Vector2 DOTSize = Vector2.zero;
			yield return Panels.GetPanelDimensions(menuPath, "DOTCards", delegate(Vector2 s)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				DOTSize = s;
			});
			Panels.CreatePanel(anchoredPos: (Vector2?)new Vector2(-140f, 0f - ((DOTSize.y > 0f) ? (DOTSize.y + 10f) : 0f)), name: "BuildingCards", parent: activeCardsGO.transform);
			yield return Buildings.LoadBuildingUnlockedCards(menuPath + "/BuildingCards", cardStyle.SliceLocked, panelStyle.Slice, prefAspectName, cardStyle.IconColor, cardStyle.TextColor);
			GameObject buffGO = Panels.CreatePanel("BuffCards", activeCardsGO.transform);
			yield return Buffs.LoadBuffActiveUnlockedCards(menuPath + "/BuffCards", cardStyle.SliceLocked, panelStyle.Slice, prefAspectName, cardStyle.IconColor, cardStyle.TextColor);
			Vector2 buffActiveSize = Vector2.zero;
			yield return Panels.GetPanelDimensions(menuPath, "BuffCards", delegate(Vector2 s)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				buffActiveSize = s;
			});
			buffGO.GetComponent<RectTransform>().anchoredPosition = new Vector2(-140f, buffActiveSize.y + 40f);
		}
	}
	internal class MonsterCards
	{
		internal static IEnumerator SetupMonsterCards(GameObject slidingScreenGO, string slidingScreenPath)
		{
			string prefAspectName = "DefaultHorizontalCard";
			StyleManager.CardVisualStyle cardStyle = StyleManager.GetCardStyle(StyleManager.StyleType.Monster);
			StyleManager.PanelVisualStyle panelStyle = StyleManager.GetPanelStyle(StyleManager.StyleType.Monster);
			string monsterMenuPath = slidingScreenPath + "/MonsterCards";
			Panels.CreatePanel("MonsterCards", slidingScreenGO.transform);
			Vector2 towerActiveSize = Vector2.zero;
			yield return Panels.GetPanelDimensions(slidingScreenPath + "/ActiveCards", "TowerCards", delegate(Vector2 s)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				towerActiveSize = s;
			});
			float monsterYShift = ((towerActiveSize.y > 0f) ? (towerActiveSize.y + 50f) : 0f);
			GameObject monsterGO = CardRendererAPI.NewPanel(monsterMenuPath, "MonsterCards", (Vector2?)new Vector2(0f, 0f - monsterYShift), false, panelStyle.Slice);
			yield return Monsters.LoadMonsterActiveUnlockedCards(monsterMenuPath + "/MonsterCards", monsterGO, cardStyle.SliceLocked, prefAspectName, cardStyle.IconColor, cardStyle.TextColor);
			CardRendererAPI.ResizeToFitChildren(monsterGO, false);
			RectTransform monsterRect = monsterGO.GetComponent<RectTransform>();
			Vector2 monsterSize = monsterRect.sizeDelta;
			monsterSize.x -= 40f;
			monsterSize.y -= 40f;
			monsterRect.sizeDelta = monsterSize;
		}
	}
	internal class PassiveCards
	{
		internal static IEnumerator SetupPassiveCards(GameObject slidingScreenGO, string menuPath)
		{
			string prefAspectName = "DefaultHorizontalCard";
			StyleManager.CardVisualStyle cardStyle = StyleManager.GetCardStyle(StyleManager.StyleType.Passive);
			StyleManager.PanelVisualStyle panelStyle = StyleManager.GetPanelStyle(StyleManager.StyleType.Passive);
			GameObject passiveCardsGO = Panels.CreatePanel("PassiveCards", slidingScreenGO.transform);
			GameObject buffGO = Panels.CreatePanel("BuffCards", passiveCardsGO.transform);
			yield return Buffs.LoadBuffPassiveCards(menuPath + "/BuffCards", cardStyle.SliceLocked, panelStyle.Slice, prefAspectName, cardStyle.IconColor, cardStyle.TextColor);
			Vector2 buffSize = Vector2.zero;
			yield return Panels.GetPanelDimensions(menuPath, "BuffCards", delegate(Vector2 s)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				buffSize = s;
			});
			GameObject towerGO = Panels.CreatePanel("TowerCards", passiveCardsGO.transform);
			yield return Towers.LoadTowerPassiveCards(menuPath + "/TowerCards", cardStyle.SliceLocked, panelStyle.Slice, prefAspectName, cardStyle.IconColor, cardStyle.TextColor);
			Vector2 towerSize = Vector2.zero;
			yield return Panels.GetPanelDimensions(menuPath, "TowerCards", delegate(Vector2 s)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				towerSize = s;
			});
			float buffYShift = ((towerSize.y > 0f) ? (buffSize.y + towerSize.y + 50f) : (buffSize.y + 40f));
			float towerYShift = ((towerSize.y > 0f) ? (towerSize.y + 40f) : 0f);
			buffGO.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, buffYShift);
			towerGO.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, towerYShift);
		}
	}
}
namespace UpgradesMenu.Menu.UI.Components
{
	public class SlidingScreenZoomHandler : MonoBehaviour, IScrollHandler, IEventSystemHandler
	{
		public RectTransform targetToZoom;

		private float scale = 1f;

		private float targetScale = 1f;

		public void OnScroll(PointerEventData eventData)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			float y = eventData.scrollDelta.y;
			if (Mathf.Abs(y) > 0.01f)
			{
				float num = ConfigManager.ZoomSpeed.Value / 50f * scale;
				targetScale = Mathf.Clamp(scale + y * num, ConfigManager.MinZoom.Value, ConfigManager.MaxZoom.Value);
			}
		}

		private void Update()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			scale = Mathf.Lerp(scale, targetScale, Time.deltaTime * 10f);
			((Transform)targetToZoom).localScale = Vector3.one * scale;
		}

		public void SetZoom(float value)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			scale = value;
			targetScale = value;
			if ((Object)(object)targetToZoom != (Object)null)
			{
				((Transform)targetToZoom).localScale = Vector3.one * value;
			}
		}
	}
}
namespace UpgradesMenu.Menu.UI.CardTreeLoader
{
	internal class Buffs
	{
		internal static IEnumerator LoadBuffActiveUnlockedCards(string menuPath, string sliceVariant, string panelSliceVariant = null, string prefabAspectName = null, Color? colorVariant = null, Color? textColorVariant = null)
		{
			Subcategory[] array = new Subcategory[5];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Subcategory[] allBuff = (Subcategory[])(object)array;
			float currentY = 0f;
			float panelSpacing = 10f;
			Subcategory[] array2 = allBuff;
			for (int i = 0; i < array2.Length; i++)
			{
				Subcategory subcategory = array2[i];
				string buffName = ((object)(Subcategory)(ref subcategory)).ToString();
				List<CardDisplayData> cardsInPanel = CardDataLibAPI.FilterCards((Category?)(Category)3, (Subcategory?)subcategory, (AcquisitionType?)(AcquisitionType)3, (bool?)true);
				if (cardsInPanel.Count != 0)
				{
					string parentPath = menuPath + "/" + buffName;
					Vector2 panelPosition = new Vector2(0f, 0f - currentY);
					GameObject panelGO = CardRendererAPI.NewPanel(menuPath, buffName, (Vector2?)panelPosition, true, panelSliceVariant);
					if (!((Object)(object)panelGO == (Object)null))
					{
						List<CardTree> treeRoots = CardTreeBuilder.BuildCardTrees(cardsInPanel.ToList());
						float? num = 0f;
						CardRendererAPI.DisplayCardTree(treeRoots, parentPath, sliceVariant, prefabAspectName, colorVariant, textColorVariant, true, (float?)null, (float?)null, num, (float?)null);
						CardRendererAPI.ResizeToFitChildren(panelGO, true);
						yield return null;
						RectTransform rect = panelGO.GetComponent<RectTransform>();
						float panelHeight = rect.sizeDelta.y;
						currentY += panelHeight + panelSpacing;
					}
				}
			}
		}

		internal static IEnumerator LoadBuffPassiveCards(string menuPath, string sliceVariant, string panelSliceVariant = null, string prefabAspectName = null, Color? colorVariant = null, Color? textColorVariant = null)
		{
			Subcategory[][] buffColumns = new Subcategory[2][]
			{
				(Subcategory[])(object)new Subcategory[2]
				{
					(Subcategory)24,
					(Subcategory)27
				},
				(Subcategory[])(object)new Subcategory[2]
				{
					(Subcategory)23,
					(Subcategory)25
				}
			};
			float currentX = 0f;
			float columnSpacing = 10f;
			Subcategory[][] array = buffColumns;
			foreach (Subcategory[] column in array)
			{
				float currentY = 0f;
				float rowSpacing = 10f;
				float maxWidthInColumn = 0f;
				bool columnHasVisiblePanels = false;
				Subcategory[] array2 = column;
				for (int j = 0; j < array2.Length; j++)
				{
					Subcategory subcategory = array2[j];
					string buffName = ((object)(Subcategory)(ref subcategory)).ToString();
					List<CardDisplayData> cardsInPanel = CardDataLibAPI.FilterCards((Category?)(Category)3, (Subcategory?)subcategory, (AcquisitionType?)(AcquisitionType)4, (bool?)null);
					if (cardsInPanel.Count == 0)
					{
						continue;
					}
					columnHasVisiblePanels = true;
					string parentPath = menuPath + "/" + buffName;
					Vector2 panelPosition = new Vector2(currentX, 0f - currentY);
					GameObject panelGO = CardRendererAPI.NewPanel(menuPath, buffName, (Vector2?)panelPosition, false, panelSliceVariant);
					if (!((Object)(object)panelGO == (Object)null))
					{
						List<CardTree> treeRoots = CardTreeBuilder.BuildCardTrees(cardsInPanel.ToList());
						float? num = 0f;
						CardRendererAPI.DisplayCardTree(treeRoots, parentPath, sliceVariant, prefabAspectName, colorVariant, textColorVariant, false, (float?)null, (float?)null, num, (float?)null);
						CardRendererAPI.ResizeToFitChildren(panelGO, false);
						yield return null;
						RectTransform rect = panelGO.GetComponent<RectTransform>();
						float panelHeight = rect.sizeDelta.y;
						float panelWidth = rect.sizeDelta.x;
						currentY += panelHeight + rowSpacing;
						if (panelWidth > maxWidthInColumn)
						{
							maxWidthInColumn = panelWidth;
						}
					}
				}
				if (columnHasVisiblePanels)
				{
					currentX += maxWidthInColumn + columnSpacing;
				}
			}
		}
	}
	internal class Buildings
	{
		internal static IEnumerator LoadBuildingUnlockedCards(string menuPath, string sliceVariant, string panelSliceVariant = null, string prefabAspectName = null, Color? colorVariant = null, Color? textColorVariant = null)
		{
			Subcategory[] array = new Subcategory[5];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Subcategory[] allBuildings = (Subcategory[])(object)array;
			float currentY = 0f;
			float panelSpacing = 10f;
			Subcategory[] array2 = allBuildings;
			for (int i = 0; i < array2.Length; i++)
			{
				Subcategory subcategory = array2[i];
				string buildingName = ((object)(Subcategory)(ref subcategory)).ToString();
				CardDisplayData card = CardDataLibAPI.GetCard(buildingName, (string)null);
				if (card == null || !card.Unlocked)
				{
					continue;
				}
				List<CardDisplayData> cardsInPanel = CardDataLibAPI.FilterCards((Category?)(Category)2, (Subcategory?)subcategory, (AcquisitionType?)(AcquisitionType)3, (bool?)true);
				if (cardsInPanel.Count != 0)
				{
					string parentPath = menuPath + "/" + buildingName;
					Vector2 panelPosition = new Vector2(0f, 0f - currentY);
					GameObject panelGO = CardRendererAPI.NewPanel(menuPath, buildingName, (Vector2?)panelPosition, true, panelSliceVariant);
					if (!((Object)(object)panelGO == (Object)null))
					{
						List<CardTree> treeRoots = CardTreeBuilder.BuildCardTrees(cardsInPanel.ToList());
						CardRendererAPI.DisplayCardTree(treeRoots, parentPath, sliceVariant, prefabAspectName, colorVariant, textColorVariant, true, (float?)null, (float?)null, (float?)null, (float?)null);
						CardRendererAPI.ResizeToFitChildren(panelGO, true);
						yield return null;
						RectTransform rect = panelGO.GetComponent<RectTransform>();
						float panelHeight = rect.sizeDelta.y;
						currentY += panelHeight + panelSpacing;
					}
				}
			}
		}
	}
	internal class DOT
	{
		internal static IEnumerator LoadDOTUnlockedCards(string menuPath, string sliceVariant, string panelSliceVariant = null, string prefabAspectName = null, Color? colorVariant = null, Color? textColorVariant = null)
		{
			Subcategory[] array = new Subcategory[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Subcategory[] allDOT = (Subcategory[])(object)array;
			float currentY = 0f;
			float panelSpacing = 10f;
			Subcategory[] array2 = allDOT;
			for (int i = 0; i < array2.Length; i++)
			{
				Subcategory subcategory = array2[i];
				string DOTName = ((object)(Subcategory)(ref subcategory)).ToString();
				CardDisplayData card = CardDataLibAPI.GetCard(DOTName + "1", (string)null);
				if (card == null || !card.Unlocked)
				{
					continue;
				}
				List<CardDisplayData> cardsInPanel = CardDataLibAPI.FilterCards((Category?)(Category)1, (Subcategory?)subcategory, (AcquisitionType?)(AcquisitionType)3, (bool?)true);
				if (cardsInPanel.Count != 0)
				{
					string parentPath = menuPath + "/" + DOTName;
					Vector2 panelPosition = new Vector2(0f, 0f - currentY);
					GameObject panelGO = CardRendererAPI.NewPanel(menuPath, DOTName, (Vector2?)panelPosition, true, panelSliceVariant);
					if (!((Object)(object)panelGO == (Object)null))
					{
						List<CardTree> treeRoots = CardTreeBuilder.BuildCardTrees(cardsInPanel.ToList());
						float? num = 0f;
						CardRendererAPI.DisplayCardTree(treeRoots, parentPath, sliceVariant, prefabAspectName, colorVariant, textColorVariant, true, (float?)null, (float?)null, num, (float?)null);
						CardRendererAPI.ResizeToFitChildren(panelGO, true);
						yield return null;
						RectTransform rect = panelGO.GetComponent<RectTransform>();
						float panelHeight = rect.sizeDelta.y;
						currentY += panelHeight + panelSpacing;
					}
				}
			}
		}
	}
	internal class Monsters
	{
		internal static IEnumerator LoadMonsterActiveUnlockedCards(string menuPath, GameObject menuGO, string sliceVariant, string prefabAspectName = null, Color? colorVariant = null, Color? textColorVariant = null)
		{
			Subcategory[] array = new Subcategory[9];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Subcategory[] allMonster = (Subcategory[])(object)array;
			float currentY = 0f;
			Subcategory[] array2 = allMonster;
			for (int i = 0; i < array2.Length; i++)
			{
				Subcategory subcategory = array2[i];
				string monsterName = ((object)(Subcategory)(ref subcategory)).ToString();
				List<CardDisplayData> cardsInPanel = CardDataLibAPI.FilterCards((Category?)(Category)4, (Subcategory?)subcategory, (AcquisitionType?)(AcquisitionType)1, (bool?)true);
				if (cardsInPanel.Count != 0)
				{
					string parentPath = menuPath + "/" + monsterName;
					GameObject panelGO = Panels.CreatePanel(anchoredPos: (Vector2?)new Vector2(0f, 0f - currentY), name: monsterName, parent: menuGO.transform);
					if (!((Object)(object)panelGO == (Object)null))
					{
						List<CardTree> treeRoots = CardTreeBuilder.BuildCardTrees(cardsInPanel.ToList());
						CardRendererAPI.DisplayCardTree(treeRoots, parentPath, sliceVariant, prefabAspectName, colorVariant, textColorVariant, false, (float?)null, (float?)null, (float?)null, (float?)null);
						CardRendererAPI.ResizeToFitChildren(panelGO, false);
						yield return null;
						RectTransform rect = panelGO.GetComponent<RectTransform>();
						float panelHeight = rect.sizeDelta.y;
						currentY += panelHeight;
					}
				}
			}
		}
	}
	internal class Towers
	{
		internal static IEnumerator LoadTowerActiveUnlockedCards(string menuPath, string sliceVariant, string panelSliceVariant = null, string prefabAspectName = null, Color? colorVariant = null, Color? textColorVariant = null)
		{
			Subcategory[][] obj = new Subcategory[5][]
			{
				(Subcategory[])(object)new Subcategory[3]
				{
					default(Subcategory),
					(Subcategory)1,
					(Subcategory)2
				},
				null,
				null,
				null,
				null
			};
			Subcategory[] array = new Subcategory[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj[1] = (Subcategory[])(object)array;
			Subcategory[] array2 = new Subcategory[3];
			RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj[2] = (Subcategory[])(object)array2;
			Subcategory[] array3 = new Subcategory[3];
			RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj[3] = (Subcategory[])(object)array3;
			Subcategory[] array4 = new Subcategory[3];
			RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj[4] = (Subcategory[])(object)array4;
			Subcategory[][] towerColumns = obj;
			float currentX = 0f;
			float columnSpacing = 10f;
			Subcategory[][] array5 = towerColumns;
			foreach (Subcategory[] column in array5)
			{
				float currentY = 0f;
				float rowSpacing = 10f;
				float maxWidthInColumn = 0f;
				bool columnHasVisiblePanels = false;
				Subcategory[] array6 = column;
				for (int j = 0; j < array6.Length; j++)
				{
					Subcategory subcategory = array6[j];
					string towerName = ((object)(Subcategory)(ref subcategory)).ToString();
					CardDisplayData card = CardDataLibAPI.GetCard(towerName, towerName);
					if (card == null || !card.Unlocked)
					{
						continue;
					}
					columnHasVisiblePanels = true;
					List<CardDisplayData> cardsInPanel = CardDataLibAPI.FilterCards((Category?)(Category)0, (Subcategory?)subcategory, (AcquisitionType?)(AcquisitionType)3, (bool?)true);
					string parentPath = menuPath + "/" + towerName;
					Vector2 panelPosition = new Vector2(currentX, 0f - currentY);
					GameObject panelGO = CardRendererAPI.NewPanel(menuPath, towerName, (Vector2?)panelPosition, false, panelSliceVariant);
					if (!((Object)(object)panelGO == (Object)null))
					{
						List<CardTree> treeRoots = CardTreeBuilder.BuildCardTrees(cardsInPanel.ToList());
						CardRendererAPI.DisplayCardTree(treeRoots, parentPath, sliceVariant, prefabAspectName, colorVariant, textColorVariant, false, (float?)null, (float?)null, (float?)null, (float?)null);
						CardRendererAPI.ResizeToFitChildren(panelGO, false);
						yield return null;
						RectTransform rect = panelGO.GetComponent<RectTransform>();
						float panelWidth = rect.sizeDelta.x;
						float panelHeight = rect.sizeDelta.y;
						currentY += panelHeight + rowSpacing;
						if (panelWidth > maxWidthInColumn)
						{
							maxWidthInColumn = panelWidth;
						}
					}
				}
				if (columnHasVisiblePanels)
				{
					currentX += maxWidthInColumn + columnSpacing;
				}
			}
		}

		internal static IEnumerator LoadTowerPassiveCards(string menuPath, string sliceVariant, string panelSliceVariant = null, string prefabAspectName = null, Color? colorVariant = null, Color? textColorVariant = null)
		{
			Subcategory[][] obj = new Subcategory[5][]
			{
				(Subcategory[])(object)new Subcategory[3]
				{
					default(Subcategory),
					(Subcategory)1,
					(Subcategory)2
				},
				null,
				null,
				null,
				null
			};
			Subcategory[] array = new Subcategory[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj[1] = (Subcategory[])(object)array;
			Subcategory[] array2 = new Subcategory[3];
			RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj[2] = (Subcategory[])(object)array2;
			Subcategory[] array3 = new Subcategory[3];
			RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj[3] = (Subcategory[])(object)array3;
			Subcategory[] array4 = new Subcategory[3];
			RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj[4] = (Subcategory[])(object)array4;
			Subcategory[][] towerColumns = obj;
			float currentX = 0f;
			float columnSpacing = 10f;
			Subcategory[][] array5 = towerColumns;
			foreach (Subcategory[] column in array5)
			{
				float currentY = 0f;
				float rowSpacing = 10f;
				float maxWidthInColumn = 0f;
				bool columnHasVisiblePanels = false;
				Subcategory[] array6 = column;
				for (int j = 0; j < array6.Length; j++)
				{
					Subcategory subcategory = array6[j];
					string towerName = ((object)(Subcategory)(ref subcategory)).ToString();
					CardDisplayData card = CardDataLibAPI.GetCard(towerName, towerName);
					if (card == null || !card.Unlocked)
					{
						continue;
					}
					List<CardDisplayData> cardsInPanel = CardDataLibAPI.FilterCards((Category?)(Category)0, (Subcategory?)subcategory, (AcquisitionType?)(AcquisitionType)4, (bool?)null);
					if (cardsInPanel.Count == 0)
					{
						continue;
					}
					columnHasVisiblePanels = true;
					string parentPath = menuPath + "/" + towerName;
					Vector2 panelPosition = new Vector2(currentX, 0f - currentY);
					GameObject panelGO = CardRendererAPI.NewPanel(menuPath, towerName, (Vector2?)panelPosition, false, panelSliceVariant);
					if (!((Object)(object)panelGO == (Object)null))
					{
						List<CardTree> treeRoots = CardTreeBuilder.BuildCardTrees(cardsInPanel.ToList());
						CardRendererAPI.DisplayCardTreeVertical(treeRoots, parentPath, sliceVariant, prefabAspectName, colorVariant, textColorVariant, false, (float?)null, (float?)null, (float?)null, (float?)null);
						CardRendererAPI.ResizeToFitChildrenVertical(panelGO, false);
						yield return null;
						RectTransform rect = panelGO.GetComponent<RectTransform>();
						float panelHeight = rect.sizeDelta.y;
						float panelWidth = rect.sizeDelta.x;
						currentY += panelHeight + rowSpacing;
						if (panelWidth > maxWidthInColumn)
						{
							maxWidthInColumn = panelWidth;
						}
					}
				}
				if (columnHasVisiblePanels)
				{
					currentX += maxWidthInColumn + columnSpacing;
				}
			}
		}
	}
}
namespace UpgradesMenu.Menu.UI.Buttons
{
	internal class MenuToggle
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__0_0;

			internal void <CreateUpgradesMenuToggleButton>b__0_0()
			{
				MenuHelper.ToggleMenu();
			}
		}

		internal static void CreateUpgradesMenuToggleButton(GameObject upgradesMenuGO)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Expected O, but got Unknown
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Expected O, but got Unknown
			RectTransform component = upgradesMenuGO.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(1f, 1f);
				component.anchorMax = new Vector2(1f, 1f);
				component.pivot = new Vector2(1f, 1f);
				component.anchoredPosition = Vector2.zero;
			}
			string text = "GameUI/UpgradesMenu/SlidingScreen";
			GameObject val = GameObject.Find(text);
			RectTransform val2 = default(RectTransform);
			if ((Object)(object)val != (Object)null && val.TryGetComponent<RectTransform>(ref val2))
			{
				val2.anchorMin = new Vector2(1f, 1f);
				val2.anchorMax = new Vector2(1f, 1f);
				val2.pivot = new Vector2(1f, 1f);
				val2.anchoredPosition = new Vector2(-1500f, -400f);
			}
			GameObject val3 = GameObject.Find("GameUI/UpgradesMenu/Panel");
			RectTransform val4 = default(RectTransform);
			if ((Object)(object)val3 != (Object)null && val3.TryGetComponent<RectTransform>(ref val4))
			{
				val4.anchorMin = new Vector2(1f, 1f);
				val4.anchorMax = new Vector2(1f, 1f);
				val4.pivot = new Vector2(1f, 1f);
				val4.anchoredPosition = new Vector2(0f, 0f);
			}
			GameObject val5 = new GameObject("ToggleButton", new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			});
			val5.transform.SetParent(upgradesMenuGO.transform, false);
			Sprite val6 = SpriteHelper.FindSpriteByName("UI9SliceOrangeFilled");
			Sprite val7 = SpriteHelper.FindSpriteByName("UI9SliceOrange");
			Image component2 = val5.GetComponent<Image>();
			if ((Object)(object)val6 != (Object)null)
			{
				component2.sprite = val6;
				component2.type = (Type)1;
			}
			else
			{
				((Graphic)component2).color = ColorsHelper.DeepOrange;
			}
			RectTransform component3 = val5.GetComponent<RectTransform>();
			component3.sizeDelta = new Vector2(55f, 55f);
			component3.anchorMin = new Vector2(1f, 1f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.pivot = new Vector2(1f, 1f);
			component3.anchoredPosition = new Vector2(-30f, -30f);
			Button component4 = val5.GetComponent<Button>();
			((Selectable)component4).transition = (Transition)2;
			SpriteState spriteState = default(SpriteState);
			if ((Object)(object)val7 != (Object)null)
			{
				((SpriteState)(ref spriteState)).highlightedSprite = val7;
			}
			((Selectable)component4).spriteState = spriteState;
			GameObject val8 = new GameObject("Icon", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val8.transform.SetParent(val5.transform, false);
			Image component5 = val8.GetComponent<Image>();
			Sprite val9 = SpriteHelper.FindSpriteByName("Book");
			if ((Object)(object)val9 != (Object)null)
			{
				component5.sprite = val9;
				component5.preserveAspect = true;
				((Graphic)component5).color = ColorsHelper.DeepOrange;
			}
			RectTransform component6 = val8.GetComponent<RectTransform>();
			component6.anchorMin = new Vector2(0.5f, 0.5f);
			component6.anchorMax = new Vector2(0.5f, 0.5f);
			component6.pivot = new Vector2(0.5f, 0.5f);
			component6.anchoredPosition = Vector2.zero;
			component6.sizeDelta = new Vector2(50f, 50f);
			ButtonClickedEvent onClick = val5.GetComponent<Button>().onClick;
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				UnityAction val10 = delegate
				{
					MenuHelper.ToggleMenu();
				};
				<>c.<>9__0_0 = val10;
				obj = (object)val10;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
		}
	}
}
namespace UpgradesMenu.Menu.Style
{
	internal class StyleManager
	{
		public enum StyleType
		{
			Active,
			Passive,
			Monster,
			Banish
		}

		internal struct CardVisualStyle
		{
			public string SliceLocked;

			public string SliceUnlocked;

			public Color IconColor;

			public Color TextColor;
		}

		internal struct PanelVisualStyle
		{
			public string Slice;
		}

		internal static CardVisualStyle GetCardStyle(StyleType type)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			CardVisualStyle result = default(CardVisualStyle);
			result.SliceLocked = UpgradesMenu.Menu.Style.Card.SliceColor.GetCardLockedSlice(type);
			result.SliceUnlocked = UpgradesMenu.Menu.Style.Card.SliceColor.GetCardUnlockedSlice(type);
			result.IconColor = IconColor.GetCardIconColor(type);
			result.TextColor = TextColor.GetCardTextColor(type);
			return result;
		}

		internal static PanelVisualStyle GetPanelStyle(StyleType type)
		{
			PanelVisualStyle result = default(PanelVisualStyle);
			result.Slice = UpgradesMenu.Menu.Style.Panel.SliceColor.GetPanelSlice(type);
			return result;
		}
	}
}
namespace UpgradesMenu.Menu.Style.Panel
{
	internal class SliceColor
	{
		internal static string GetPanelSlice(StyleManager.StyleType type)
		{
			return type switch
			{
				StyleManager.StyleType.Active => "LargeUI9Slice" + ConfigManager.ActivePanelColor.Value, 
				StyleManager.StyleType.Passive => "LargeUI9Slice" + ConfigManager.PassivePanelColor.Value, 
				StyleManager.StyleType.Monster => "LargeUI9Slice" + ConfigManager.MonsterPanelColor.Value, 
				_ => "LargeUI9SliceOrange", 
			};
		}
	}
}
namespace UpgradesMenu.Menu.Style.Card
{
	internal class IconColor
	{
		internal static Color GetCardIconColor(StyleManager.StyleType type)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			return ColorsHelper.GetContrastByName(type switch
			{
				StyleManager.StyleType.Active => ConfigManager.ActiveCardColor.Value, 
				StyleManager.StyleType.Passive => ConfigManager.PassiveCardColor.Value, 
				StyleManager.StyleType.Monster => ConfigManager.MonsterCardColor.Value, 
				StyleManager.StyleType.Banish => ConfigManager.BanishCardColor.Value, 
				_ => "orange", 
			});
		}
	}
	public static class SliceColor
	{
		internal static string GetCardLockedSlice(StyleManager.StyleType type)
		{
			return type switch
			{
				StyleManager.StyleType.Active => "UI9Slice" + ConfigManager.ActiveCardColor.Value + "Filled", 
				StyleManager.StyleType.Passive => "UI9Slice" + ConfigManager.PassiveCardColor.Value + "Filled", 
				StyleManager.StyleType.Monster => "UI9Slice" + ConfigManager.MonsterCardColor.Value + "Filled", 
				StyleManager.StyleType.Banish => "UI9Slice" + ConfigManager.BanishCardColor.Value + "Filled", 
				_ => "UI9SliceOrangeFilled", 
			};
		}

		internal static string GetCardUnlockedSlice(StyleManager.StyleType type)
		{
			return type switch
			{
				StyleManager.StyleType.Active => "UI9Slice" + ConfigManager.ActiveCardColor.Value, 
				StyleManager.StyleType.Passive => "UI9Slice" + ConfigManager.PassiveCardColor.Value, 
				StyleManager.StyleType.Monster => "UI9Slice" + ConfigManager.MonsterCardColor.Value, 
				StyleManager.StyleType.Banish => "UI9Slice" + ConfigManager.BanishCardColor.Value, 
				_ => "UI9SliceOrange", 
			};
		}
	}
	internal class TextColor
	{
		internal static Color GetCardTextColor(StyleManager.StyleType type)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			return ColorsHelper.GetContrastByName(type switch
			{
				StyleManager.StyleType.Active => ConfigManager.ActiveCardColor.Value, 
				StyleManager.StyleType.Passive => ConfigManager.PassiveCardColor.Value, 
				StyleManager.StyleType.Monster => ConfigManager.MonsterCardColor.Value, 
				StyleManager.StyleType.Banish => ConfigManager.BanishCardColor.Value, 
				_ => "orange", 
			});
		}
	}
}
namespace UpgradesMenu.Menu.Logic
{
	internal static class MenuHelper
	{
		private static bool firstOpenDone;

		internal static void HandleMenuInput(KeyCode toggleKey)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(toggleKey))
			{
				ToggleMenu();
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				CloseMenu();
			}
		}

		internal static void CloseMenu()
		{
			GameObject val = GameObject.Find("GameUI/UpgradesMenu/SlidingScreen");
			GameObject val2 = GameObject.Find("GameUI/UpgradesMenu/Panel");
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && (val.activeSelf || val2.activeSelf))
			{
				val.SetActive(false);
				val2.SetActive(false);
			}
		}

		internal static void ResetFirstOpen()
		{
			firstOpenDone = false;
		}

		internal static void ToggleMenu()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("GameUI/UpgradesMenu/SlidingScreen");
			GameObject val2 = GameObject.Find("GameUI/UpgradesMenu/Panel");
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
			{
				bool flag = val.activeSelf || val2.activeSelf;
				if (!flag && !firstOpenDone)
				{
					val.GetComponent<SlidingScreenZoomHandler>()?.SetZoom(ConfigManager.DefaultZoom.Value);
					RectTransform component = val.GetComponent<RectTransform>();
					component.anchoredPosition = new Vector2(-1335f, -830f);
					firstOpenDone = true;
				}
				val.SetActive(!flag);
				val2.SetActive(!flag);
			}
		}
	}
	internal class MenuManager
	{
		internal static IEnumerator LoadMenuWhenSceneIsReady(Action onComplete = null)
		{
			yield return CardRendererAPI.WaitForCardAspect("DefaultHorizontalCard");
			yield return CardRendererAPI.WaitForMenuAspect("DefaultMenu");
			GameObject parentPanel = GameObject.Find("GameUI");
			if ((Object)(object)parentPanel == (Object)null)
			{
				Plugin.Log.LogError((object)"GameUI 'GameUI' not found. Cannot proceed.");
				yield break;
			}
			GameObject upgradesMenuGO = GameObject.Find("GameUI/UpgradesMenu");
			if ((Object)(object)upgradesMenuGO != (Object)null)
			{
				Object.Destroy((Object)(object)upgradesMenuGO);
				yield return null;
			}
			CardRendererAPI.NewMenu("GameUI", "UpgradesMenu", (string)null);
			GameObject upgradesMenuWithContentGO = GameObject.Find("GameUI/UpgradesMenu");
			MenuToggle.CreateUpgradesMenuToggleButton(upgradesMenuWithContentGO);
			string slidingScreenPath = "GameUI/UpgradesMenu/SlidingScreen";
			GameObject slidingScreenGO = GameObject.Find(slidingScreenPath);
			if ((Object)(object)slidingScreenGO == (Object)null)
			{
				Plugin.Log.LogError((object)("SlidingScreen not found at path '" + slidingScreenPath + "'"));
				yield break;
			}
			Time.timeScale = 0f;
			if ((Object)(object)Object.FindObjectOfType<EventSystem>() == (Object)null)
			{
				new GameObject("EventSystem", new Type[2]
				{
					typeof(EventSystem),
					typeof(StandaloneInputModule)
				});
			}
			yield return ActiveCards.SetupActiveCards(slidingScreenGO, slidingScreenPath + "/ActiveCards");
			yield return PassiveCards.SetupPassiveCards(slidingScreenGO, slidingScreenPath + "/PassiveCards");
			if (GameModeCheck.ChallengeMode.IsMonsterModeEnabled)
			{
				yield return MonsterCards.SetupMonsterCards(slidingScreenGO, slidingScreenPath);
			}
			SlidingScreenZoomHandler zoomHandler = slidingScreenGO.AddComponent<SlidingScreenZoomHandler>();
			zoomHandler.targetToZoom = slidingScreenGO.GetComponent<RectTransform>();
			CenterPanelsInSlidingScreen(slidingScreenGO.GetComponent<RectTransform>());
			Layers.AddInvisibleBackground(slidingScreenGO);
			MenuHelper.CloseMenu();
			MenuHelper.ResetFirstOpen();
			Time.timeScale = 1f;
			onComplete?.Invoke();
		}

		internal static void CenterPanelsInSlidingScreen(RectTransform slidingScreen)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			string text = "GameUI/UpgradesMenu/SlidingScreen/ActiveCards/TowerCards/Ballista";
			GameObject val = GameObject.Find(text);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Ballista not found, using default centering.");
				return;
			}
			RectTransform component = val.GetComponent<RectTransform>();
			if ((Object)(object)component == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Ballista RectTransform missing.");
				return;
			}
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			component.GetWorldCorners(array);
			Vector3 val2 = array[3];
			Vector3 val3 = ((Transform)slidingScreen).InverseTransformPoint(val2);
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(val3.x + 35f, val3.y - 60f);
			foreach (Transform item in (Transform)slidingScreen)
			{
				Transform val5 = item;
				if (!(((Object)val5).name == "Background"))
				{
					RectTransform val6 = (RectTransform)(object)((val5 is RectTransform) ? val5 : null);
					if (val6 != null)
					{
						val6.anchoredPosition -= val4;
					}
				}
			}
		}
	}
	internal class Panels
	{
		internal static GameObject CreatePanel(string name, Transform parent, Vector2? anchoredPos = null)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform val2 = default(RectTransform);
			if (anchoredPos.HasValue && val.TryGetComponent<RectTransform>(ref val2))
			{
				val2.anchoredPosition = anchoredPos.Value;
			}
			return val;
		}

		internal static IEnumerator GetPanelDimensions(string menuPath, string panelName, Action<Vector2> onComplete)
		{
			yield return null;
			GameObject panelGO = GameObject.Find(menuPath + "/" + panelName);
			if ((Object)(object)panelGO == (Object)null)
			{
				Plugin.Log.LogError((object)(panelName + " panel not found at path " + menuPath + "/" + panelName));
				onComplete?.Invoke(Vector2.zero);
				yield break;
			}
			RectTransform panelRect = panelGO.GetComponent<RectTransform>();
			if ((Object)(object)panelRect == (Object)null)
			{
				Plugin.Log.LogError((object)("RectTransform not found on " + panelName));
				onComplete?.Invoke(Vector2.zero);
				yield break;
			}
			if (((Transform)panelRect).childCount == 0)
			{
				onComplete?.Invoke(Vector2.zero);
				yield break;
			}
			float minX = float.MaxValue;
			float maxX = float.MinValue;
			float minY = float.MaxValue;
			float maxY = float.MinValue;
			foreach (RectTransform item in (Transform)panelRect)
			{
				RectTransform child = item;
				Vector2 anchoredPos = child.anchoredPosition;
				Vector2 size = child.sizeDelta;
				float left = anchoredPos.x;
				float right = anchoredPos.x + size.x;
				float top = anchoredPos.y;
				float bottom = anchoredPos.y - size.y;
				if (left < minX)
				{
					minX = left;
				}
				if (right > maxX)
				{
					maxX = right;
				}
				if (top > maxY)
				{
					maxY = top;
				}
				if (bottom < minY)
				{
					minY = bottom;
				}
			}
			float width = maxX - minX;
			float height = maxY - minY;
			onComplete?.Invoke(new Vector2(width, height));
		}
	}
}
namespace UpgradesMenu.Integrations
{
	public static class BanishCardsInterop
	{
		public static List<string> GetBanishedUnlockNames()
		{
			Type type = Type.GetType("BanishCards.Runtime.BanishedCards, BanishCards");
			if (type == null)
			{
				return null;
			}
			FieldInfo field = type.GetField("BanishedUnlockNames", BindingFlags.Static | BindingFlags.Public);
			if (field == null)
			{
				Debug.LogWarning((object)"BanishedUnlockNames field not found in BanishCards.");
				return null;
			}
			object value = field.GetValue(null);
			if (value is List<string> result)
			{
				return result;
			}
			Debug.LogWarning((object)"BanishedUnlockNames field is not a List<string>.");
			return null;
		}
	}
	internal class BanishCard_Patch
	{
		public static void ApplyIfAvailable(Harmony harmony)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			Type type = AccessTools.TypeByName("BanishCards.Runtime.CardBanishManager");
			if (!(type == null))
			{
				MethodInfo methodInfo = AccessTools.Method(type, "BanishCard", (Type[])null, (Type[])null);
				if (!(methodInfo == null))
				{
					MethodInfo method = typeof(BanishCard_Patch).GetMethod("Postfix");
					harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		public static void Postfix()
		{
			//IL_0057: 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_01d5: 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)
			List<string> banishedUnlockNames = BanishCardsInterop.GetBanishedUnlockNames();
			if (banishedUnlockNames == null)
			{
				return;
			}
			HashSet<string> hashSet = new HashSet<string>();
			foreach (string item in banishedUnlockNames)
			{
				CardDisplayData card = CardDataLibAPI.GetCard(item, (string)null);
				if (card == null)
				{
					continue;
				}
				hashSet.Add(item);
				List<CardDisplayData> list = CardDataLibAPI.FilterCards((Category?)card.Category, (Subcategory?)card.Subcategory, (AcquisitionType?)(AcquisitionType)3, (bool?)true);
				List<CardTree> list2 = CardTreeBuilder.BuildCardTrees(list);
				foreach (CardTree item2 in list2)
				{
					CardTree val = FindNode(item2, item);
					if (val == null)
					{
						continue;
					}
					List<CardDisplayData> allDescendants = CardTreeUtils.GetAllDescendants(val);
					foreach (CardDisplayData item3 in allDescendants)
					{
						hashSet.Add(item3.UnlockName);
					}
					break;
				}
			}
			StyleManager.CardVisualStyle cardStyle = StyleManager.GetCardStyle(StyleManager.StyleType.Banish);
			foreach (string item4 in hashSet)
			{
				CardDisplayData card2 = CardDataLibAPI.GetCard(item4, (string)null);
				if (card2 != null)
				{
					string text = ((object)(Category)(ref card2.Category)).ToString();
					string text2 = ((object)(Subcategory)(ref card2.Subcategory)).ToString();
					string text3 = "GameUI/UpgradesMenu/SlidingScreen/ActiveCards/" + text + "Cards/" + text2 + "/" + item4;
					CardRendererAPI.SwapCardSlice(text3, cardStyle.SliceUnlocked, (Color?)cardStyle.IconColor, (Color?)cardStyle.TextColor);
				}
			}
		}

		private static CardTree FindNode(CardTree node, string unlockName)
		{
			if (node.Card.UnlockName == unlockName)
			{
				return node;
			}
			foreach (CardTree child in node.Children)
			{
				CardTree val = FindNode(child, unlockName);
				if (val != null)
				{
					return val;
				}
			}
			return null;
		}
	}
	public static class RedMonsterCardsInterop
	{
		public static bool IsModPresent()
		{
			return AppDomain.CurrentDomain.GetAssemblies().Any((Assembly a) => a.GetName().Name == "RustyDios.RedMonsterCards");
		}
	}
}