Decompiled source of BetterCards v1.3.1

plugins/BetterCards.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Nosebleed.Pancake.GameConfig;
using Nosebleed.Pancake.GameLogic;
using Nosebleed.Pancake.Modal;
using Nosebleed.Pancake.Models;
using Nosebleed.Pancake.View;
using Nosebleed.SaveLoadSystem;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BetterCards")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a35e5ad62e5867e77089ab77bd86330416f476c1")]
[assembly: AssemblyProduct("BetterCards")]
[assembly: AssemblyTitle("BetterCards")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BetterCards;

[BepInPlugin("com.tovak.vc.bettercards", "BetterCards", "1.3.1")]
public class Plugin : BasePlugin
{
	internal static ManualLogSource Log;

	internal static string CurrentLangCode = "";

	internal static bool LocaleRebuildPending = false;

	internal static ConfigEntry<bool> CardLockEnabled;

	public override void Load()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Expected O, but got Unknown
		Log = ((BasePlugin)this).Log;
		CardLockEnabled = ((BasePlugin)this).Config.Bind<bool>("CardLock", "Enabled", true, "Right-click any card to lock it (golden padlock). Locked cards can't be played accidentally — useful for keeping Destruction cards alive until fusion.");
		ClassInjector.RegisterTypeInIl2Cpp<ComboObserver>();
		GameObject val = new GameObject("BetterCards");
		Object.DontDestroyOnLoad((Object)val);
		val.AddComponent<ComboObserver>();
		try
		{
			Locale selectedLocale = LocalizationSettings.SelectedLocale;
			if ((Object)(object)selectedLocale != (Object)null)
			{
				CurrentLangCode = (selectedLocale.Identifier.Code ?? "").ToLowerInvariant();
			}
		}
		catch
		{
		}
		bool flag = default(bool);
		try
		{
			Harmony val2 = new Harmony("com.tovak.vc.bettercards");
			val2.PatchAll(typeof(LocalePatch));
			val2.PatchAll(typeof(PlayerModel_CanAffordCard_Patch));
			val2.PatchAll(typeof(PlayerModel_AreAnyCardsInHandPlayable_Patch));
			val2.PatchAll(typeof(PlayerModel_TryPlayCard_Patch));
			val2.PatchAll(typeof(PlayerModel_SimplePlayCard_Patch));
			val2.PatchAll(typeof(PlayableCard_TryPlayCard_Patch));
			val2.PatchAll(typeof(PlayableCard_OnCardPlayRequested_Patch));
			int num = val2.GetPatchedMethods().Count();
			ManualLogSource log = Log;
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CardLock] Harmony patches actifs : ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
			}
			log.LogInfo(val3);
		}
		catch (Exception ex)
		{
			ManualLogSource log2 = Log;
			BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[BetterCards] harmony error: ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
			}
			log2.LogWarning(val4);
		}
		Log.LogInfo((object)"BetterCards chargé !");
	}
}
[HarmonyPatch(typeof(LocalizationSettings), "SetSelectedLocale")]
public static class LocalePatch
{
	public static void Postfix(Locale locale)
	{
		try
		{
			string text = "";
			if ((Object)(object)locale != (Object)null)
			{
				text = (locale.Identifier.Code ?? "").ToLowerInvariant();
			}
			if (text != Plugin.CurrentLangCode)
			{
				Plugin.CurrentLangCode = text;
				Plugin.LocaleRebuildPending = true;
			}
		}
		catch
		{
		}
	}
}
[HarmonyPatch(typeof(PlayerModel), "CanAffordCard")]
public static class PlayerModel_CanAffordCard_Patch
{
	public static void Postfix(CardModel cardModel, ref bool __result)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		try
		{
			if (__result && Plugin.CardLockEnabled != null && Plugin.CardLockEnabled.Value && (Object)(object)cardModel != (Object)null && ComboObserver.IsLocked(cardModel))
			{
				__result = false;
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[CardLock] CanAffordCard patch err: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val);
		}
	}
}
[HarmonyPatch(typeof(PlayerModel), "AreAnyCardsInHandPlayable")]
public static class PlayerModel_AreAnyCardsInHandPlayable_Patch
{
	public static void Postfix(PlayerModel __instance, ref bool __result)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		try
		{
			if (!__result || Plugin.CardLockEnabled == null || !Plugin.CardLockEnabled.Value || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			HandPileModel handPile = __instance.HandPile;
			object obj;
			if (handPile == null)
			{
				obj = null;
			}
			else
			{
				CardPileModel cardPile = handPile.CardPile;
				obj = ((cardPile != null) ? cardPile._cards : null);
			}
			List<CardModel> val = (List<CardModel>)obj;
			if (val == null)
			{
				return;
			}
			int count = val.Count;
			for (int i = 0; i < count; i++)
			{
				CardModel val2 = val[i];
				if (!((Object)(object)val2 == (Object)null) && !ComboObserver.IsLocked(val2) && __instance.CanAffordCard(val2))
				{
					return;
				}
			}
			__result = false;
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(48, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CardLock] AreAnyCardsInHandPlayable patch err: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val3);
		}
	}
}
[HarmonyPatch(typeof(PlayerModel), "TryPlayCard", new Type[]
{
	typeof(CardModel),
	typeof(bool)
})]
public static class PlayerModel_TryPlayCard_Patch
{
	private static bool _firstHitLogged;

	public static bool Prefix(CardModel cardModel, bool isAutoPlay, ref bool __result)
	{
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		try
		{
			if (!_firstHitLogged)
			{
				_firstHitLogged = true;
				string lockKey = ComboObserver.GetLockKey(cardModel);
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(75, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[CardLock] PlayerModel.TryPlayCard prefix actif (guid=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(lockKey ?? "null");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", autoPlay=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(isAutoPlay);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", locked=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(ComboObserver.IsLocked(cardModel));
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				log.LogInfo(val);
			}
			if (Plugin.CardLockEnabled == null || !Plugin.CardLockEnabled.Value)
			{
				return true;
			}
			if ((Object)(object)cardModel == (Object)null)
			{
				return true;
			}
			if (!ComboObserver.IsLocked(cardModel))
			{
				return true;
			}
			ComboObserver.PlayBlockedFeedback(null);
			__result = false;
			return false;
		}
		catch (Exception ex)
		{
			ManualLogSource log2 = Plugin.Log;
			bool flag2 = default(bool);
			BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[CardLock] PlayerModel.TryPlayCard patch err: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
			}
			log2.LogWarning(val2);
			return true;
		}
	}
}
[HarmonyPatch(typeof(PlayableCard), "TryPlayCard")]
public static class PlayableCard_TryPlayCard_Patch
{
	private static bool _firstFireLogged;

	public static void Postfix(PlayableCard __instance)
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		bool flag2 = default(bool);
		try
		{
			CardModel val = ((__instance != null) ? __instance._cardModel : null);
			bool flag = ComboObserver.IsLocked(val);
			if (!_firstFireLogged)
			{
				_firstFireLogged = true;
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[CardLock] TryPlayCard 1st fire (locked=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(flag);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
				}
				log.LogInfo(val2);
			}
			if (Plugin.CardLockEnabled != null && Plugin.CardLockEnabled.Value && !((Object)(object)val == (Object)null) && flag)
			{
				ComboObserver.PlayBlockedFeedback(__instance);
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log2 = Plugin.Log;
			BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CardLock] TryPlayCard err: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
			}
			log2.LogWarning(val3);
		}
	}
}
[HarmonyPatch(typeof(PlayableCard), "OnCardPlayRequested")]
public static class PlayableCard_OnCardPlayRequested_Patch
{
	private static bool _firstFireLogged;

	public static void Postfix(PlayableCard __instance)
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		bool flag2 = default(bool);
		try
		{
			CardModel val = ((__instance != null) ? __instance._cardModel : null);
			bool flag = ComboObserver.IsLocked(val);
			if (!_firstFireLogged)
			{
				_firstFireLogged = true;
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(49, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[CardLock] OnCardPlayRequested 1st fire (locked=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(flag);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
				}
				log.LogInfo(val2);
			}
			if (Plugin.CardLockEnabled != null && Plugin.CardLockEnabled.Value && !((Object)(object)val == (Object)null) && flag)
			{
				ComboObserver.PlayBlockedFeedback(__instance);
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log2 = Plugin.Log;
			BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CardLock] OnCardPlayRequested err: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
			}
			log2.LogWarning(val3);
		}
	}
}
[HarmonyPatch(typeof(PlayerModel), "SimplePlayCard")]
public static class PlayerModel_SimplePlayCard_Patch
{
	private static bool _firstHitLogged;

	public static bool Prefix(CardModel cardModel)
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		try
		{
			if (!_firstHitLogged)
			{
				_firstHitLogged = true;
				Plugin.Log.LogInfo((object)"[CardLock] PlayerModel.SimplePlayCard prefix actif");
			}
			if (Plugin.CardLockEnabled == null || !Plugin.CardLockEnabled.Value)
			{
				return true;
			}
			if ((Object)(object)cardModel == (Object)null)
			{
				return true;
			}
			if (!ComboObserver.IsLocked(cardModel))
			{
				return true;
			}
			ComboObserver.PlayBlockedFeedback(null);
			return false;
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[CardLock] SimplePlayCard err: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val);
			return true;
		}
	}
}
public class ComboObserver : MonoBehaviour
{
	internal class LockPopAnim
	{
		public Transform badge;

		public CanvasGroup cg;

		public float startTime;
	}

	internal class AnimBadge
	{
		public Transform ring;

		public Transform shine;
	}

	private bool _wasOpen;

	private string _lastCardSignature = "";

	private ChooseCardModal _cachedModal;

	private int _searchCooldown;

	private DeckBoxModal _cachedDeckModal;

	private int _deckSearchCooldown;

	private int _deckAliveCheck;

	private bool _wasDeckOpen;

	private PlayerModel _cachedPlayerModel;

	private GameObject _deckOverlay;

	private GameObject _chooseCardOverlay;

	private bool _deckOverlayPending;

	private Dictionary<int, int> _pendingCostGroups;

	private Transform _cachedScrollView;

	private RectTransform _cachedScrollRT;

	private RectTransform _cachedDeckViewRT;

	private Il2CppStructArray<Vector3> _cornersBuf;

	private int _overlayStabilizeFrames;

	private bool _deckOverlayFixed;

	private int _levelupReopenDelay;

	private int _lastOverlayTotal;

	private bool _pendingLevelupClose;

	private int _overlayCardCount;

	private int _cardCountCheckTimer;

	private static readonly Dictionary<int, Sprite> _manaOrbSprites = new Dictionary<int, Sprite>();

	private static readonly Dictionary<int, Color> _manaOrbColors = new Dictionary<int, Color>();

	private static Sprite _arcSprite = null;

	private static Sprite _modalFrameSprite = null;

	private const int WILD_KEY = -99;

	private const int XMANA_KEY = -98;

	private static HashSet<string> _allKnownNorms;

	private static HashSet<string> _allCompRefs;

	private const string BadgeName = "VCComboBadge";

	private static Sprite _ringSpriteRainbow;

	private static Sprite _ringSpriteSilver;

	private static Sprite _evoTextSprite;

	private static Sprite _shineSprite;

	private static Sprite _checkmarkSprite;

	private const string CountBadgeName = "VCCountBadge";

	private static Sprite _newBadgeSprite;

	private static readonly Sprite[] _countBadgeCache = (Sprite[])(object)new Sprite[10];

	private static readonly byte[][][] GlyphsNEW = new byte[3][][]
	{
		new byte[7][]
		{
			new byte[5] { 1, 0, 0, 0, 1 },
			new byte[5] { 1, 1, 0, 0, 1 },
			new byte[5] { 1, 1, 0, 0, 1 },
			new byte[5] { 1, 0, 1, 0, 1 },
			new byte[5] { 1, 0, 0, 1, 1 },
			new byte[5] { 1, 0, 0, 1, 1 },
			new byte[5] { 1, 0, 0, 0, 1 }
		},
		new byte[7][]
		{
			new byte[5] { 1, 1, 1, 1, 1 },
			new byte[5] { 1, 0, 0, 0, 0 },
			new byte[5] { 1, 0, 0, 0, 0 },
			new byte[5] { 1, 1, 1, 1, 0 },
			new byte[5] { 1, 0, 0, 0, 0 },
			new byte[5] { 1, 0, 0, 0, 0 },
			new byte[5] { 1, 1, 1, 1, 1 }
		},
		new byte[7][]
		{
			new byte[5] { 1, 0, 0, 0, 1 },
			new byte[5] { 1, 0, 0, 0, 1 },
			new byte[5] { 1, 0, 0, 0, 1 },
			new byte[5] { 1, 0, 1, 0, 1 },
			new byte[5] { 1, 0, 1, 0, 1 },
			new byte[5] { 0, 1, 0, 1, 0 },
			new byte[5] { 0, 1, 0, 1, 0 }
		}
	};

	private static readonly byte[][] GlyphTimes = new byte[3][]
	{
		new byte[3] { 1, 0, 1 },
		new byte[3] { 0, 1, 0 },
		new byte[3] { 1, 0, 1 }
	};

	private static readonly byte[][][] GlyphsDigits = new byte[10][][]
	{
		new byte[5][]
		{
			new byte[3] { 0, 1, 0 },
			new byte[3] { 1, 0, 1 },
			new byte[3] { 1, 0, 1 },
			new byte[3] { 1, 0, 1 },
			new byte[3] { 0, 1, 0 }
		},
		new byte[5][]
		{
			new byte[3] { 0, 1, 0 },
			new byte[3] { 1, 1, 0 },
			new byte[3] { 0, 1, 0 },
			new byte[3] { 0, 1, 0 },
			new byte[3] { 1, 1, 1 }
		},
		new byte[5][]
		{
			new byte[3] { 1, 1, 0 },
			new byte[3] { 0, 0, 1 },
			new byte[3] { 0, 1, 0 },
			new byte[3] { 1, 0, 0 },
			new byte[3] { 1, 1, 1 }
		},
		new byte[5][]
		{
			new byte[3] { 1, 1, 0 },
			new byte[3] { 0, 0, 1 },
			new byte[3] { 0, 1, 0 },
			new byte[3] { 0, 0, 1 },
			new byte[3] { 1, 1, 0 }
		},
		new byte[5][]
		{
			new byte[3] { 1, 0, 1 },
			new byte[3] { 1, 0, 1 },
			new byte[3] { 1, 1, 1 },
			new byte[3] { 0, 0, 1 },
			new byte[3] { 0, 0, 1 }
		},
		new byte[5][]
		{
			new byte[3] { 1, 1, 1 },
			new byte[3] { 1, 0, 0 },
			new byte[3] { 1, 1, 0 },
			new byte[3] { 0, 0, 1 },
			new byte[3] { 1, 1, 0 }
		},
		new byte[5][]
		{
			new byte[3] { 0, 1, 1 },
			new byte[3] { 1, 0, 0 },
			new byte[3] { 1, 1, 0 },
			new byte[3] { 1, 0, 1 },
			new byte[3] { 0, 1, 0 }
		},
		new byte[5][]
		{
			new byte[3] { 1, 1, 1 },
			new byte[3] { 0, 0, 1 },
			new byte[3] { 0, 1, 0 },
			new byte[3] { 0, 1, 0 },
			new byte[3] { 0, 1, 0 }
		},
		new byte[5][]
		{
			new byte[3] { 0, 1, 0 },
			new byte[3] { 1, 0, 1 },
			new byte[3] { 0, 1, 0 },
			new byte[3] { 1, 0, 1 },
			new byte[3] { 0, 1, 0 }
		},
		new byte[5][]
		{
			new byte[3] { 0, 1, 0 },
			new byte[3] { 1, 0, 1 },
			new byte[3] { 0, 1, 1 },
			new byte[3] { 0, 0, 1 },
			new byte[3] { 0, 1, 0 }
		}
	};

	internal static readonly HashSet<string> _lockedCardKeys = new HashSet<string>();

	private const string LockBadgeName = "BC_LockBadge";

	private int _lockBadgeScanCooldown;

	private static Sprite _lockBadgeSprite;

	private static AudioSource _audioSource;

	private static AudioClip _clipLock;

	private static AudioClip _clipUnlock;

	private static AudioClip _clipBlocked;

	private static bool _assetsLoaded = false;

	private static Sprite _goldenDiscSprite;

	internal static readonly HashSet<string> _lockedConfigsCache = new HashSet<string>();

	internal static bool _lockedConfigsCacheDirty = true;

	private static readonly List<string> _matchingGuidsBuf = new List<string>();

	private int _autoEndPollCooldown;

	private bool _autoEndDone;

	private static float _lastBlockedFeedbackTime = -10f;

	private static bool _prevSpaceP;

	private static bool _prevEnterP;

	private static bool _prevNumEnterP;

	private static bool _firstBadgeLogged = false;

	internal static readonly List<LockPopAnim> _lockPopAnims = new List<LockPopAnim>();

	private const float LOCK_POP_DURATION = 0.25f;

	private const float LOCK_POP_START_SCALE = 1.6f;

	private static bool _firstScanLogged = false;

	private static bool _firstRightClickLogged = false;

	internal static readonly List<AnimBadge> _animBadges = new List<AnimBadge>();

	public ComboObserver(IntPtr ptr)
		: base(ptr)
	{
	}

	public void Awake()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		try
		{
			EnsureAssetsLoaded();
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(24, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[CardLock] Awake error: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val);
		}
	}

	private static string GetCardSignature(ChooseCardModal modal)
	{
		List<CardChoiceView> cardChoiceViews = modal._cardChoiceViews;
		if (cardChoiceViews == null)
		{
			return "";
		}
		StringBuilder stringBuilder = new StringBuilder();
		Enumerator<CardChoiceView> enumerator = cardChoiceViews.GetEnumerator();
		while (enumerator.MoveNext())
		{
			CardChoiceView current = enumerator.Current;
			object obj;
			if (current == null)
			{
				obj = null;
			}
			else
			{
				CardConfig cardConfig = current.CardConfig;
				obj = ((cardConfig != null) ? ((Object)cardConfig).name : null);
			}
			if (obj == null)
			{
				obj = "null";
			}
			stringBuilder.Append((string?)obj).Append("|");
		}
		return stringBuilder.ToString();
	}

	public void Update()
	{
		//IL_08c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_08cb: Expected O, but got Unknown
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0708: Unknown result type (might be due to invalid IL or missing references)
		//IL_070d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0714: Unknown result type (might be due to invalid IL or missing references)
		//IL_0721: Unknown result type (might be due to invalid IL or missing references)
		//IL_072b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0739: Unknown result type (might be due to invalid IL or missing references)
		//IL_0456: Unknown result type (might be due to invalid IL or missing references)
		//IL_045b: Unknown result type (might be due to invalid IL or missing references)
		//IL_046a: Unknown result type (might be due to invalid IL or missing references)
		//IL_047b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0485: Unknown result type (might be due to invalid IL or missing references)
		//IL_078f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0494: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0828: Unknown result type (might be due to invalid IL or missing references)
		//IL_0837: Unknown result type (might be due to invalid IL or missing references)
		//IL_0844: Unknown result type (might be due to invalid IL or missing references)
		//IL_0857: Unknown result type (might be due to invalid IL or missing references)
		//IL_085c: Unknown result type (might be due to invalid IL or missing references)
		//IL_085e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0863: Unknown result type (might be due to invalid IL or missing references)
		//IL_086b: Unknown result type (might be due to invalid IL or missing references)
		//IL_087e: Unknown result type (might be due to invalid IL or missing references)
		//IL_088a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0898: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		HandleRightClickToggle();
		HandleKeyboardLockedFeedback();
		ScanAndUpdateLockBadges();
		TickLockPopAnims();
		CheckAutoEndTurn();
		if (_animBadges.Count > 0)
		{
			float unscaledTime = Time.unscaledTime;
			float num = unscaledTime * 35f % 360f;
			float num2 = unscaledTime * -120f % 360f;
			for (int num3 = _animBadges.Count - 1; num3 >= 0; num3--)
			{
				AnimBadge animBadge = _animBadges[num3];
				if (animBadge == null || (Object)(object)animBadge.ring == (Object)null)
				{
					_animBadges.RemoveAt(num3);
				}
				else
				{
					try
					{
						animBadge.ring.localEulerAngles = new Vector3(0f, 0f, num);
						if ((Object)(object)animBadge.shine != (Object)null)
						{
							animBadge.shine.localEulerAngles = new Vector3(0f, 0f, num2);
						}
					}
					catch
					{
						_animBadges.RemoveAt(num3);
					}
				}
			}
		}
		if ((Object)(object)_cachedModal == (Object)null)
		{
			if (--_searchCooldown > 0)
			{
				return;
			}
			_searchCooldown = 20;
			_cachedModal = Object.FindObjectOfType<ChooseCardModal>();
		}
		ChooseCardModal cachedModal = _cachedModal;
		bool flag = (Object)(object)cachedModal != (Object)null && ((Modal)cachedModal).IsOpen;
		if (flag)
		{
			string cardSignature = GetCardSignature(cachedModal);
			if (!_wasOpen || cardSignature != _lastCardSignature)
			{
				_lastCardSignature = cardSignature;
				OnModalOpened(cachedModal);
			}
		}
		else
		{
			_lastCardSignature = "";
			if (_wasOpen)
			{
				if ((Object)(object)_chooseCardOverlay != (Object)null)
				{
					Object.Destroy((Object)(object)_chooseCardOverlay);
					_chooseCardOverlay = null;
				}
				_cachedModal = null;
				_pendingLevelupClose = true;
				if ((Object)(object)_cachedDeckModal != (Object)null)
				{
					_levelupReopenDelay = 60;
				}
			}
		}
		_wasOpen = flag;
		if ((Object)(object)_cachedDeckModal == (Object)null && --_deckSearchCooldown <= 0)
		{
			_deckSearchCooldown = 20;
			_cachedDeckModal = Object.FindObjectOfType<DeckBoxModal>();
			if ((Object)(object)_cachedDeckModal != (Object)null)
			{
				_cachedScrollView = null;
				_cachedScrollRT = null;
				_cachedDeckViewRT = null;
				_deckAliveCheck = 0;
				_wasDeckOpen = false;
				if (_pendingLevelupClose && _levelupReopenDelay == 0)
				{
					_levelupReopenDelay = 60;
					_pendingLevelupClose = false;
				}
			}
		}
		if ((Object)(object)_cachedDeckModal != (Object)null)
		{
			if (_overlayStabilizeFrames > 0)
			{
				_overlayStabilizeFrames--;
			}
			if (Plugin.LocaleRebuildPending)
			{
				Plugin.LocaleRebuildPending = false;
				if ((Object)(object)_deckOverlay != (Object)null)
				{
					Object.Destroy((Object)(object)_deckOverlay);
					_deckOverlay = null;
				}
				_deckOverlayFixed = false;
				_deckOverlayPending = false;
				_pendingCostGroups = null;
				_overlayStabilizeFrames = 0;
				if (((Modal)_cachedDeckModal).IsOpen && !flag)
				{
					OnDeckBoxOpened(_cachedDeckModal, "locale-change");
				}
			}
			if (_levelupReopenDelay > 0 && !flag && --_levelupReopenDelay == 0)
			{
				OnDeckBoxOpened(_cachedDeckModal, "levelup-close");
			}
			bool isOpen = ((Modal)_cachedDeckModal).IsOpen;
			if (isOpen && !_wasDeckOpen && !_deckOverlayPending && !flag)
			{
				OnDeckBoxOpened(_cachedDeckModal, "open-transition");
			}
			_wasDeckOpen = isOpen;
			if ((Object)(object)_cachedScrollView == (Object)null)
			{
				Transform val = FindNamedChild(((Component)_cachedDeckModal).gameObject.transform, "AdjustableScrollView", 10);
				if ((Object)(object)val != (Object)null)
				{
					_cachedScrollView = val;
					_cachedScrollRT = ((Component)val).GetComponent<RectTransform>();
				}
			}
			if ((Object)(object)_cachedDeckViewRT == (Object)null)
			{
				Transform val2 = FindNamedChild(((Component)_cachedDeckModal).gameObject.transform, "DeckView");
				if ((Object)(object)val2 != (Object)null)
				{
					_cachedDeckViewRT = ((Component)val2).GetComponent<RectTransform>();
				}
			}
			if ((Object)(object)_deckOverlay != (Object)null && (Object)(object)_cachedScrollRT != (Object)null && (Object)(object)_cachedDeckViewRT != (Object)null && !_deckOverlayFixed)
			{
				if (_cornersBuf == null)
				{
					_cornersBuf = new Il2CppStructArray<Vector3>(4L);
				}
				_cachedScrollRT.GetWorldCorners(_cornersBuf);
				Vector2 zero = Vector2.zero;
				if (RectTransformUtility.ScreenPointToLocalPointInRectangle(_cachedDeckViewRT, new Vector2(((Il2CppArrayBase<Vector3>)(object)_cornersBuf)[0].x, ((Il2CppArrayBase<Vector3>)(object)_cornersBuf)[0].y), (Camera)null, ref zero))
				{
					float num4 = zero.y - 5f - 75f;
					RectTransform component = _deckOverlay.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null && Mathf.Abs(component.anchoredPosition.y - num4) > 0.5f)
					{
						component.anchoredPosition = new Vector2(0f, num4);
					}
				}
			}
			if (flag && (Object)(object)_deckOverlay != (Object)null)
			{
				Object.Destroy((Object)(object)_deckOverlay);
				_deckOverlay = null;
			}
			if ((Object)(object)_deckOverlay != (Object)null && isOpen && _levelupReopenDelay == 0 && ++_cardCountCheckTimer >= 30)
			{
				_cardCountCheckTimer = 0;
				Transform val3 = FindNamedChild(((Component)_cachedDeckModal).gameObject.transform, "CardContainer", 10);
				if ((Object)(object)val3 != (Object)null && val3.childCount != _overlayCardCount)
				{
					_levelupReopenDelay = 90;
				}
			}
			if (++_deckAliveCheck >= 30)
			{
				_deckAliveCheck = 0;
				if ((Object)(object)Object.FindObjectOfType<DeckBoxModal>() == (Object)null)
				{
					if ((Object)(object)_deckOverlay != (Object)null)
					{
						Object.Destroy((Object)(object)_deckOverlay);
						_deckOverlay = null;
					}
					_cachedDeckModal = null;
					_cachedScrollView = null;
					_cachedScrollRT = null;
					_cachedDeckViewRT = null;
					_deckOverlayFixed = false;
					_deckOverlayPending = false;
					_pendingCostGroups = null;
					_wasDeckOpen = false;
					_levelupReopenDelay = 0;
					_lastOverlayTotal = 0;
					_overlayCardCount = 0;
					_cardCountCheckTimer = 0;
				}
			}
		}
		if (!_deckOverlayPending || !((Object)(object)_cachedDeckModal != (Object)null) || _pendingCostGroups == null)
		{
			return;
		}
		_deckOverlayPending = false;
		if (!flag)
		{
			float yOffset = -340f;
			float xOffset = 0f;
			bool flag2 = false;
			try
			{
				Transform val4 = FindNamedChild(((Component)_cachedDeckModal).gameObject.transform, "DeckView");
				Transform val5 = FindNamedChild(((Component)_cachedDeckModal).gameObject.transform, "AdjustableScrollView", 10);
				if ((Object)(object)val5 != (Object)null && (Object)(object)val4 != (Object)null)
				{
					Canvas.ForceUpdateCanvases();
					RectTransform component2 = ((Component)val5).GetComponent<RectTransform>();
					RectTransform component3 = ((Component)val4).GetComponent<RectTransform>();
					if ((Object)(object)component2 != (Object)null && (Object)(object)component3 != (Object)null)
					{
						Il2CppStructArray<Vector3> val6 = new Il2CppStructArray<Vector3>(4L);
						component2.GetWorldCorners(val6);
						Vector2 zero2 = Vector2.zero;
						RectTransformUtility.ScreenPointToLocalPointInRectangle(component3, new Vector2(((Il2CppArrayBase<Vector3>)(object)val6)[0].x, ((Il2CppArrayBase<Vector3>)(object)val6)[0].y), (Camera)null, ref zero2);
						float num5 = zero2.y - 5f - 75f;
						float num6 = num5 - 75f;
						float num7 = 540f;
						Transform obj2 = FindCanvasTransform(((Component)_cachedDeckModal).gameObject.transform);
						RectTransform val7 = ((obj2 != null) ? ((Component)obj2).GetComponent<RectTransform>() : null);
						if ((Object)(object)val7 != (Object)null && val7.sizeDelta.y > 0f)
						{
							num7 = val7.sizeDelta.y / 2f;
						}
						int num8 = 0;
						Transform val8 = FindNamedChild(((Component)_cachedDeckModal).gameObject.transform, "CardContainer", 10);
						if ((Object)(object)val8 != (Object)null)
						{
							num8 = val8.childCount;
						}
						flag2 = num8 > 10 || num6 < 0f - (num7 + 10f);
						if (!flag2)
						{
							float num9 = 0f - (num7 - 75f - 4f);
							yOffset = Mathf.Max(num5, num9);
						}
						else
						{
							float x = ((Il2CppArrayBase<Vector3>)(object)val6)[2].x;
							float num10 = (((Il2CppArrayBase<Vector3>)(object)val6)[0].y + ((Il2CppArrayBase<Vector3>)(object)val6)[1].y) / 2f;
							Vector2 zero3 = Vector2.zero;
							Vector2 zero4 = Vector2.zero;
							RectTransformUtility.ScreenPointToLocalPointInRectangle(component3, new Vector2(x, num10), (Camera)null, ref zero3);
							RectTransformUtility.ScreenPointToLocalPointInRectangle(component3, new Vector2(((Il2CppArrayBase<Vector3>)(object)val6)[0].x, num10), (Camera)null, ref zero4);
							xOffset = zero3.x + 20f + 120f;
							yOffset = zero4.y;
						}
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag3 = default(bool);
				BepInExWarningLogInterpolatedStringHandler val9 = new BepInExWarningLogInterpolatedStringHandler(21, 1, ref flag3);
				if (flag3)
				{
					((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[DeckBox] pos error: ");
					((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val9);
			}
			if ((Object)(object)_deckOverlay != (Object)null)
			{
				Object.Destroy((Object)(object)_deckOverlay);
				_deckOverlay = null;
			}
			_deckOverlay = CreateManaPanel(((Component)_cachedDeckModal).gameObject, _pendingCostGroups, yOffset, xOffset, flag2);
			_deckOverlayFixed = flag2;
			_overlayStabilizeFrames = 30;
			Transform val10 = FindNamedChild(((Component)_cachedDeckModal).gameObject.transform, "CardContainer", 10);
			_overlayCardCount = (((Object)(object)val10 != (Object)null) ? val10.childCount : 0);
			_cardCountCheckTimer = 0;
		}
		_pendingCostGroups = null;
	}

	private static void TryCacheManaIcons(List<CardChoiceView> views)
	{
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Invalid comparison between Unknown and I4
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		Enumerator<CardChoiceView> enumerator = views.GetEnumerator();
		while (enumerator.MoveNext())
		{
			CardChoiceView current = enumerator.Current;
			CardConfig val = ((current != null) ? current.CardConfig : null);
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			int manaCost = val.manaCost;
			if (!_manaOrbSprites.ContainsKey(manaCost))
			{
				Transform obj = FindNamedChild(((Component)current).gameObject.transform, "_manaComboElementOrb", 15);
				Image val2 = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
				if ((Object)(object)((val2 != null) ? val2.sprite : null) != (Object)null)
				{
					_manaOrbSprites[manaCost] = val2.sprite;
					_manaOrbColors[manaCost] = ((Graphic)val2).color;
				}
			}
			if ((Object)(object)_arcSprite == (Object)null)
			{
				Transform obj2 = FindNamedChild(((Component)current).gameObject.transform, "_manaComboElement", 15);
				Image val3 = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null);
				if ((Object)(object)((val3 != null) ? val3.sprite : null) != (Object)null)
				{
					_arcSprite = val3.sprite;
				}
			}
			if ((Object)(object)_modalFrameSprite == (Object)null && ((Component)current).gameObject.transform.childCount > 0)
			{
				Image component = ((Component)((Component)current).gameObject.transform.GetChild(0)).GetComponent<Image>();
				if ((Object)(object)component != (Object)null && (int)component.type == 1 && (Object)(object)component.sprite != (Object)null)
				{
					_modalFrameSprite = component.sprite;
				}
			}
		}
	}

	private void OnDeckBoxOpened(DeckBoxModal modal, string reason = "")
	{
		//IL_0631: Unknown result type (might be due to invalid IL or missing references)
		//IL_0638: Expected O, but got Unknown
		//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Invalid comparison between Unknown and I4
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (_overlayStabilizeFrames > 0 && reason == "open-transition")
			{
				return;
			}
			if ((Object)(object)_deckOverlay != (Object)null)
			{
				Object.Destroy((Object)(object)_deckOverlay);
				_deckOverlay = null;
			}
			if ((Object)(object)_cachedModal != (Object)null && ((Modal)_cachedModal).IsOpen)
			{
				return;
			}
			Transform val = FindNamedChild(((Component)modal).gameObject.transform, "CardContainer", 10);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"[DeckBox] CardContainer null");
				return;
			}
			if ((Object)(object)_modalFrameSprite != (Object)null)
			{
				string name = ((Object)_modalFrameSprite).name;
				if (name != null && name.StartsWith("frame", StringComparison.OrdinalIgnoreCase))
				{
					goto IL_00e3;
				}
			}
			Sprite val2 = FindFrameSpriteRecursive(((Component)modal).gameObject.transform, 15);
			if ((Object)(object)val2 != (Object)null)
			{
				_modalFrameSprite = val2;
			}
			goto IL_00e3;
			IL_00e3:
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			for (int i = 0; i < val.childCount; i++)
			{
				Transform child = val.GetChild(i);
				CardSelectionCardView component = ((Component)child).GetComponent<CardSelectionCardView>();
				CardConfig val3 = null;
				CardModel val4 = null;
				CardView val5 = null;
				if ((Object)(object)component != (Object)null)
				{
					try
					{
						MethodInfo method = ((Object)component).GetIl2CppType().GetMethod("get_CardModel");
						Object val6 = ((method != null) ? ((MethodBase)method).Invoke((Object)(object)component, (Il2CppReferenceArray<Object>)null) : null);
						if (val6 != null)
						{
							val4 = ((Il2CppObjectBase)val6).TryCast<CardModel>();
							if ((Object)(object)val4 != (Object)null)
							{
								val3 = val4.CardConfig;
								try
								{
									val5 = val4.CardView;
								}
								catch
								{
								}
							}
						}
					}
					catch
					{
					}
				}
				if ((Object)(object)val5 != (Object)null)
				{
					try
					{
						CardConfig appliedCardConfig = val5._appliedCardConfig;
						if ((Object)(object)appliedCardConfig != (Object)null)
						{
							val3 = appliedCardConfig;
						}
					}
					catch
					{
					}
				}
				string text = ((val3 != null) ? ((Object)val3).name : null) ?? FindCardConfigName(child);
				if (text == null)
				{
					continue;
				}
				int num = text.IndexOf("(Clone)", StringComparison.Ordinal);
				if (num > 0)
				{
					text = text.Substring(0, num).TrimEnd();
				}
				string[] array = text.Split('_');
				if (array.Length >= 2 && array[1].ToUpperInvariant() == "C")
				{
					continue;
				}
				bool num2 = array.Length == 3 || (array.Length >= 2 && array[1].ToUpperInvariant() == "E");
				int cost = -999;
				if (num2)
				{
					cost = -99;
				}
				else
				{
					if ((Object)(object)val5 != (Object)null)
					{
						try
						{
							TMP_Text costText = val5._costText;
							if ((Object)(object)costText != (Object)null)
							{
								TryParseCostText(costText.text, out cost);
							}
						}
						catch
						{
						}
					}
					if (cost == -999 && (Object)(object)val4 != (Object)null)
					{
						try
						{
							cost = val4.GetCardCostTypeManaCost(false);
						}
						catch
						{
							cost = -999;
						}
					}
					if (cost == -999 && (Object)(object)val3 != (Object)null)
					{
						cost = val3.manaCost;
					}
					if (cost == -999)
					{
						continue;
					}
					if (cost == -99 && (Object)(object)val4 != (Object)null)
					{
						TryCacheWildSpriteFromModel(val4);
					}
				}
				if (!_manaOrbSprites.ContainsKey(cost))
				{
					Transform val7 = ((cost != -99) ? FindNamedChild(child, "_manaComboElementOrb", 15) : (FindNamedChild(child, "_W_cardCostBackgroundElement", 15) ?? FindNamedChild(child, "_manaComboElementOrb", 15)));
					Image val8 = ((val7 != null) ? ((Component)val7).GetComponent<Image>() : null);
					if ((Object)(object)((val8 != null) ? val8.sprite : null) != (Object)null)
					{
						_manaOrbSprites[cost] = val8.sprite;
						_manaOrbColors[cost] = ((Graphic)val8).color;
					}
				}
				if ((Object)(object)_modalFrameSprite == (Object)null && child.childCount > 0)
				{
					Image component2 = ((Component)child.GetChild(0)).GetComponent<Image>();
					if ((Object)(object)component2 != (Object)null && (int)component2.type == 1 && (Object)(object)component2.sprite != (Object)null)
					{
						_modalFrameSprite = component2.sprite;
					}
				}
				dictionary[cost] = ((!dictionary.TryGetValue(cost, out var value)) ? 1 : (value + 1));
			}
			if ((Object)(object)_cachedPlayerModel == (Object)null)
			{
				_cachedPlayerModel = Object.FindObjectOfType<PlayerModel>();
			}
			Dictionary<int, int> dictionary2 = new Dictionary<int, int>();
			PlayerModel cachedPlayerModel = _cachedPlayerModel;
			List<CardModel> val9 = ((cachedPlayerModel != null) ? cachedPlayerModel._allCards : null);
			if (val9 != null)
			{
				Enumerator<CardModel> enumerator = val9.GetEnumerator();
				while (enumerator.MoveNext())
				{
					CardModel current = enumerator.Current;
					CardConfig val10 = ((current != null) ? current.CardConfig : null);
					if ((Object)(object)val10 == (Object)null || ((Object)val10).name == null || !((Object)val10).name.StartsWith("Card_"))
					{
						continue;
					}
					try
					{
						CardView cardView = current.CardView;
						CardConfig val11 = ((cardView != null) ? cardView._appliedCardConfig : null);
						if ((Object)(object)val11 != (Object)null)
						{
							val10 = val11;
						}
					}
					catch
					{
					}
					string[] array2 = ((Object)val10).name.Split('_');
					if (array2.Length >= 2 && array2[1].ToUpperInvariant() == "C")
					{
						continue;
					}
					bool num3 = array2.Length == 3 || (array2.Length >= 2 && array2[1].ToUpperInvariant() == "E");
					int cost2 = -999;
					if (num3)
					{
						cost2 = -99;
						TryCacheWildSpriteFromModel(current);
					}
					else
					{
						try
						{
							CardView cardView2 = current.CardView;
							TMP_Text val12 = ((cardView2 != null) ? cardView2._costText : null);
							if ((Object)(object)val12 != (Object)null)
							{
								TryParseCostText(val12.text, out cost2);
							}
						}
						catch
						{
						}
						if (cost2 == -999)
						{
							try
							{
								cost2 = current.GetCardCostTypeManaCost(false);
							}
							catch
							{
								cost2 = -999;
							}
						}
						if (cost2 == -999)
						{
							cost2 = val10.manaCost;
						}
						switch (cost2)
						{
						case -99:
							TryCacheWildSpriteFromModel(current);
							break;
						default:
							TryCacheOrbSpriteFromModel(current, cost2);
							break;
						case -98:
							break;
						}
					}
					dictionary2[cost2] = ((!dictionary2.TryGetValue(cost2, out var value2)) ? 1 : (value2 + 1));
				}
			}
			if (dictionary2.Count == 0)
			{
				dictionary2 = dictionary;
			}
			if (dictionary2.Count == 0)
			{
				Plugin.Log.LogWarning((object)"[DeckBox] costGroups vide");
				return;
			}
			int num4 = dictionary2.Values.Sum();
			if (!(reason == "levelup-close") || num4 >= _lastOverlayTotal)
			{
				_lastOverlayTotal = num4;
				_pendingCostGroups = dictionary2;
				_deckOverlayPending = true;
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val13 = new BepInExErrorLogInterpolatedStringHandler(10, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val13).AppendLiteral("[DeckBox] ");
				((BepInExLogInterpolatedStringHandler)val13).AppendFormatted<Exception>(ex);
			}
			log.LogError(val13);
		}
	}

	private static void TryCacheWildSpriteFromModel(CardModel cm)
	{
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)cm == (Object)null || _manaOrbSprites.ContainsKey(-99))
		{
			return;
		}
		try
		{
			CardView cardView = cm.CardView;
			if ((Object)(object)cardView == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)cardView).gameObject;
			Transform val = ((gameObject != null) ? gameObject.transform : null);
			if (!((Object)(object)val == (Object)null))
			{
				Transform obj = FindNamedChild(val, "_W_cardCostBackgroundElement", 15) ?? FindNamedChild(val, "_manaComboElementOrb", 15);
				Image val2 = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
				if ((Object)(object)((val2 != null) ? val2.sprite : null) != (Object)null)
				{
					_manaOrbSprites[-99] = val2.sprite;
					_manaOrbColors[-99] = ((Graphic)val2).color;
				}
			}
		}
		catch
		{
		}
	}

	private static void TryCacheOrbSpriteFromModel(CardModel cm, int cost)
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)cm == (Object)null || _manaOrbSprites.ContainsKey(cost))
		{
			return;
		}
		try
		{
			CardView cardView = cm.CardView;
			if ((Object)(object)cardView == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)cardView).gameObject;
			Transform val = ((gameObject != null) ? gameObject.transform : null);
			if (!((Object)(object)val == (Object)null))
			{
				Transform obj = FindNamedChild(val, "_manaComboElementOrb", 15);
				Image val2 = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
				if ((Object)(object)((val2 != null) ? val2.sprite : null) != (Object)null)
				{
					_manaOrbSprites[cost] = val2.sprite;
					_manaOrbColors[cost] = ((Graphic)val2).color;
				}
			}
		}
		catch
		{
		}
	}

	private static bool TryParseCostText(string txt, out int cost)
	{
		cost = -999;
		if (string.IsNullOrEmpty(txt))
		{
			return false;
		}
		txt = txt.Trim();
		if (int.TryParse(txt, out var result))
		{
			cost = result;
			return true;
		}
		if (txt.Equals("W", StringComparison.OrdinalIgnoreCase) || txt.Equals("U", StringComparison.OrdinalIgnoreCase))
		{
			cost = -99;
			return true;
		}
		if (txt.Equals("X", StringComparison.OrdinalIgnoreCase))
		{
			cost = -98;
			return true;
		}
		return false;
	}

	private static Sprite FindFrameSpriteRecursive(Transform t, int maxDepth)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Invalid comparison between Unknown and I4
		if (maxDepth <= 0)
		{
			return null;
		}
		Image component = ((Component)t).GetComponent<Image>();
		if ((Object)(object)component != (Object)null && (int)component.type == 1 && (Object)(object)component.sprite != (Object)null && (((Object)component.sprite).name ?? "").StartsWith("frame", StringComparison.OrdinalIgnoreCase))
		{
			return component.sprite;
		}
		for (int i = 0; i < t.childCount; i++)
		{
			Sprite val = FindFrameSpriteRecursive(t.GetChild(i), maxDepth - 1);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return null;
	}

	private static Transform FindNamedChild(Transform t, string name, int maxDepth = 5)
	{
		if (maxDepth <= 0)
		{
			return null;
		}
		for (int i = 0; i < t.childCount; i++)
		{
			Transform child = t.GetChild(i);
			if (((Object)child).name == name)
			{
				return child;
			}
			Transform val = FindNamedChild(child, name, maxDepth - 1);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return null;
	}

	private static string FindCardConfigName(Transform root, int maxDepth = 4)
	{
		if (maxDepth <= 0)
		{
			return null;
		}
		if (((Object)root).name.StartsWith("Card_"))
		{
			return ((Object)root).name;
		}
		for (int i = 0; i < root.childCount; i++)
		{
			string text = FindCardConfigName(root.GetChild(i), maxDepth - 1);
			if (text != null)
			{
				return text;
			}
		}
		return null;
	}

	private static (string main, string sub) GetCompositionLabel()
	{
		string text = Plugin.CurrentLangCode ?? "";
		if (text.StartsWith("zh"))
		{
			if (!text.Contains("hant"))
			{
				return ("牌组构成", "(不含同伴卡)");
			}
			return ("牌組構成", "(不含同伴卡)");
		}
		return ((text.Length > 0) ? text.Split('-')[0] : "") switch
		{
			"fr" => ("COMPOSITION", "(hors cartes compagnons)"), 
			"de" => ("ZUSAMMENSETZUNG", "(ohne Begleiterkarten)"), 
			"it" => ("COMPOSIZIONE", "(escl. carte compagno)"), 
			"es" => ("COMPOSICIÓN", "(excl. cartas de compañero)"), 
			"ru" => ("СОСТАВ", "(без карт спутника)"), 
			"pl" => ("SKŁAD TALII", "(bez kart towarzyszy)"), 
			"pt" => ("COMPOSIÇÃO", "(excl. cartas de companheiro)"), 
			"ja" => ("デッキ構成", "(仲間カードを除く)"), 
			"ko" => ("덱 구성", "(동료 카드 제외)"), 
			_ => ("COMPOSITION", "(excl. companion cards)"), 
		};
	}

	private static Transform FindCanvasTransform(Transform t, int maxDepth = 5)
	{
		if (maxDepth <= 0)
		{
			return null;
		}
		if ((Object)(object)((Component)t).GetComponent<Canvas>() != (Object)null && (Object)(object)((Component)t).GetComponent<RectTransform>() != (Object)null)
		{
			return t;
		}
		for (int i = 0; i < t.childCount; i++)
		{
			Transform val = FindCanvasTransform(t.GetChild(i), maxDepth - 1);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return null;
	}

	private static GameObject CreateManaPanel(GameObject modalGo, Dictionary<int, int> costGroups, float yOffset, float xOffset = 0f, bool vertical = false)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_125b: Unknown result type (might be due to invalid IL or missing references)
		//IL_126a: Unknown result type (might be due to invalid IL or missing references)
		//IL_126f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1281: Unknown result type (might be due to invalid IL or missing references)
		//IL_1288: Unknown result type (might be due to invalid IL or missing references)
		//IL_1293: Unknown result type (might be due to invalid IL or missing references)
		//IL_129e: Unknown result type (might be due to invalid IL or missing references)
		//IL_12a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_12a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_12ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_12cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_12da: Unknown result type (might be due to invalid IL or missing references)
		//IL_12df: Unknown result type (might be due to invalid IL or missing references)
		//IL_12f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_12f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_1303: Unknown result type (might be due to invalid IL or missing references)
		//IL_1318: Unknown result type (might be due to invalid IL or missing references)
		//IL_132c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0990: Unknown result type (might be due to invalid IL or missing references)
		//IL_099f: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_09bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a00: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: 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_036f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: 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_0409: Unknown result type (might be due to invalid IL or missing references)
		//IL_041e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_0448: Unknown result type (might be due to invalid IL or missing references)
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_139b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a93: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a98: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aaa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0abb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0afa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b0e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b57: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b73: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b78: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b8a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b9b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bb0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bc5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bda: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c30: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c4c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c51: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c63: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c74: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c89: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c9e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cb3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cc7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a1c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a21: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a33: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a3a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a45: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a55: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a56: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a5d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fc: Expected O, but got Unknown
		//IL_0522: Unknown result type (might be due to invalid IL or missing references)
		//IL_0527: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Unknown result type (might be due to invalid IL or missing references)
		//IL_052f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0541: Unknown result type (might be due to invalid IL or missing references)
		//IL_0550: Unknown result type (might be due to invalid IL or missing references)
		//IL_0564: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d28: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d2f: Expected O, but got Unknown
		//IL_0d55: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d5a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d5b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d62: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d74: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d83: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d97: Unknown result type (might be due to invalid IL or missing references)
		//IL_0597: Unknown result type (might be due to invalid IL or missing references)
		//IL_059c: Unknown result type (might be due to invalid IL or missing references)
		//IL_05af: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0609: Unknown result type (might be due to invalid IL or missing references)
		//IL_0633: Unknown result type (might be due to invalid IL or missing references)
		//IL_0638: Unknown result type (might be due to invalid IL or missing references)
		//IL_064b: Unknown result type (might be due to invalid IL or missing references)
		//IL_065d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0662: Unknown result type (might be due to invalid IL or missing references)
		//IL_0663: Unknown result type (might be due to invalid IL or missing references)
		//IL_066a: Unknown result type (might be due to invalid IL or missing references)
		//IL_067c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0687: Unknown result type (might be due to invalid IL or missing references)
		//IL_069b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dc5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ddd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0def: Unknown result type (might be due to invalid IL or missing references)
		//IL_0df4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0df5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dfc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e0e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e19: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e2d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e67: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e76: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e7b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e8e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ea0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ea5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ea6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ead: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ebf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ed4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ee8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f12: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f17: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f2a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f3c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f41: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f42: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f49: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f5b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f66: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f7a: Unknown result type (might be due to invalid IL or missing references)
		//IL_079e: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_073b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_107d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1082: Unknown result type (might be due to invalid IL or missing references)
		//IL_1095: Unknown result type (might be due to invalid IL or missing references)
		//IL_109c: Unknown result type (might be due to invalid IL or missing references)
		//IL_10a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_10b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_10b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_10b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_10bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_101a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fd0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fc9: Unknown result type (might be due to invalid IL or missing references)
		//IL_078f: Unknown result type (might be due to invalid IL or missing references)
		//IL_077a: Unknown result type (might be due to invalid IL or missing references)
		//IL_106e: Unknown result type (might be due to invalid IL or missing references)
		//IL_1059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0844: Unknown result type (might be due to invalid IL or missing references)
		//IL_085c: Unknown result type (might be due to invalid IL or missing references)
		//IL_086b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0870: Unknown result type (might be due to invalid IL or missing references)
		//IL_0882: Unknown result type (might be due to invalid IL or missing references)
		//IL_0894: Unknown result type (might be due to invalid IL or missing references)
		//IL_0899: Unknown result type (might be due to invalid IL or missing references)
		//IL_089a: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0932: Unknown result type (might be due to invalid IL or missing references)
		//IL_1123: Unknown result type (might be due to invalid IL or missing references)
		//IL_113b: Unknown result type (might be due to invalid IL or missing references)
		//IL_114a: Unknown result type (might be due to invalid IL or missing references)
		//IL_114f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1161: Unknown result type (might be due to invalid IL or missing references)
		//IL_1173: Unknown result type (might be due to invalid IL or missing references)
		//IL_1178: Unknown result type (might be due to invalid IL or missing references)
		//IL_1179: Unknown result type (might be due to invalid IL or missing references)
		//IL_1180: Unknown result type (might be due to invalid IL or missing references)
		//IL_1192: Unknown result type (might be due to invalid IL or missing references)
		//IL_11ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_11c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_121d: Unknown result type (might be due to invalid IL or missing references)
		object obj = FindNamedChild(modalGo.transform, "ChooseACard");
		Transform val = FindCanvasTransform(modalGo.transform);
		if (obj == null)
		{
			obj = val ?? modalGo.transform;
		}
		Transform val2 = (Transform)obj;
		GameObject val3 = new GameObject("VCManaOverlay");
		val3.layer = ((Component)val2).gameObject.layer;
		val3.transform.SetParent(val2, false);
		val3.transform.SetAsLastSibling();
		RectTransform val4 = val3.AddComponent<RectTransform>();
		val4.anchorMin = new Vector2(0.5f, 0.5f);
		val4.anchorMax = new Vector2(0.5f, 0.5f);
		val4.pivot = new Vector2(0.5f, 0.5f);
		val4.anchoredPosition = new Vector2(xOffset, yOffset);
		List<KeyValuePair<int, int>> list = costGroups.OrderBy((KeyValuePair<int, int> kv) => (kv.Key != -99) ? ((kv.Key != -98) ? kv.Key : (-2147483647)) : int.MinValue).ToList();
		bool flag = list.Count > 0;
		if (flag && vertical)
		{
			float num = 242f;
			float num2 = 70f + (float)list.Count * 96f - 8f + 14f;
			val4.sizeDelta = new Vector2(num, num2);
			GameObject val5 = new GameObject("BgFill");
			val5.transform.SetParent(val3.transform, false);
			RectTransform obj2 = val5.AddComponent<RectTransform>();
			obj2.anchorMin = Vector2.zero;
			obj2.anchorMax = Vector2.one;
			Vector2 offsetMin = (obj2.offsetMax = Vector2.zero);
			obj2.offsetMin = offsetMin;
			((Graphic)val5.AddComponent<Image>()).color = new Color(0.294f, 0.31f, 0.455f, 0.97f);
			if ((Object)(object)_modalFrameSprite != (Object)null)
			{
				GameObject val6 = new GameObject("BgFrame");
				val6.transform.SetParent(val3.transform, false);
				RectTransform obj3 = val6.AddComponent<RectTransform>();
				obj3.anchorMin = Vector2.zero;
				obj3.anchorMax = Vector2.one;
				offsetMin = (obj3.offsetMax = Vector2.zero);
				obj3.offsetMin = offsetMin;
				Image obj4 = val6.AddComponent<Image>();
				obj4.sprite = _modalFrameSprite;
				obj4.type = (Type)1;
			}
			(string main, string sub) compositionLabel = GetCompositionLabel();
			string item = compositionLabel.main;
			string item2 = compositionLabel.sub;
			GameObject val7 = new GameObject("Title");
			val7.transform.SetParent(val3.transform, false);
			RectTransform obj5 = val7.AddComponent<RectTransform>();
			obj5.anchorMin = new Vector2(0f, 1f);
			obj5.anchorMax = new Vector2(1f, 1f);
			obj5.pivot = new Vector2(0.5f, 1f);
			obj5.anchoredPosition = new Vector2(0f, -6f);
			obj5.sizeDelta = new Vector2(-8f, 26f);
			TextMeshProUGUI obj6 = val7.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj6).text = item;
			((TMP_Text)obj6).fontSize = 22f;
			((TMP_Text)obj6).fontStyle = (FontStyles)1;
			((TMP_Text)obj6).alignment = (TextAlignmentOptions)514;
			((Graphic)obj6).color = new Color(1f, 0.92f, 0.55f, 1f);
			((TMP_Text)obj6).enableWordWrapping = false;
			((TMP_Text)obj6).overflowMode = (TextOverflowModes)0;
			GameObject val8 = new GameObject("Sub");
			val8.transform.SetParent(val3.transform, false);
			RectTransform obj7 = val8.AddComponent<RectTransform>();
			obj7.anchorMin = new Vector2(0f, 1f);
			obj7.anchorMax = new Vector2(1f, 1f);
			obj7.pivot = new Vector2(0.5f, 1f);
			obj7.anchoredPosition = new Vector2(0f, -32f);
			obj7.sizeDelta = new Vector2(-8f, 18f);
			TextMeshProUGUI obj8 = val8.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj8).text = item2;
			((TMP_Text)obj8).fontSize = 14f;
			((TMP_Text)obj8).alignment = (TextAlignmentOptions)514;
			((Graphic)obj8).color = new Color(0.78f, 0.78f, 0.85f, 0.9f);
			((TMP_Text)obj8).enableWordWrapping = false;
			((TMP_Text)obj8).overflowMode = (TextOverflowModes)0;
			GameObject val9 = new GameObject("Sep");
			val9.transform.SetParent(val3.transform, false);
			RectTransform obj9 = val9.AddComponent<RectTransform>();
			obj9.anchorMin = new Vector2(0.03f, 1f);
			obj9.anchorMax = new Vector2(0.97f, 1f);
			obj9.pivot = new Vector2(0.5f, 1f);
			obj9.anchoredPosition = new Vector2(0f, -60f);
			obj9.sizeDelta = new Vector2(0f, 1f);
			((Graphic)val9.AddComponent<Image>()).color = new Color(1f, 0.92f, 0.55f, 0.35f);
			float num3 = (0f - num) / 2f + 18f + 42f;
			float num4 = (0f - num) / 2f + 18f + 84f + 12f;
			float num5 = num2 / 2f - 60f - 10f - 44f;
			foreach (KeyValuePair<int, int> item5 in list)
			{
				GameObject val10 = new GameObject("Badge");
				val10.transform.SetParent(val3.transform, false);
				RectTransform obj10 = val10.AddComponent<RectTransform>();
				offsetMin = (obj10.anchorMax = new Vector2(0.5f, 0.5f));
				obj10.anchorMin = offsetMin;
				obj10.pivot = new Vector2(0.5f, 0.5f);
				obj10.anchoredPosition = new Vector2(num3, num5);
				obj10.sizeDelta = new Vector2(84f, 84f);
				if (item5.Key == -99 && _manaOrbSprites.ContainsKey(item5.Key))
				{
					GameObject val12 = new GameObject("WBg");
					val12.transform.SetParent(val10.transform, false);
					RectTransform obj11 = val12.AddComponent<RectTransform>();
					offsetMin = (obj11.anchorMax = new Vector2(0.5f, 0.5f));
					obj11.anchorMin = offsetMin;
					obj11.pivot = new Vector2(0.5f, 0.5f);
					obj11.anchoredPosition = new Vector2(-1f, 1f);
					obj11.sizeDelta = new Vector2(84f, 84f);
					val12.AddComponent<Image>().sprite = _manaOrbSprites[item5.Key];
					GameObject val14 = new GameObject("WFg");
					val14.transform.SetParent(val10.transform, false);
					RectTransform obj12 = val14.AddComponent<RectTransform>();
					offsetMin = (obj12.anchorMax = new Vector2(0.5f, 0.5f));
					obj12.anchorMin = offsetMin;
					obj12.pivot = new Vector2(0.5f, 0.5f);
					obj12.anchoredPosition = Vector2.zero;
					obj12.sizeDelta = new Vector2(84f, 84f);
					Image obj13 = val14.AddComponent<Image>();
					obj13.sprite = _manaOrbSprites[item5.Key];
					((Graphic)obj13).color = (Color)(_manaOrbColors.TryGetValue(item5.Key, out var value) ? value : new Color(0f, 0.23f, 0.58f, 1f));
				}
				else
				{
					Image val16 = val10.AddComponent<Image>();
					if (_manaOrbSprites.TryGetValue(item5.Key, out var value2))
					{
						val16.sprite = value2;
						if (_manaOrbColors.TryGetValue(item5.Key, out var value3))
						{
							((Graphic)val16).color = value3;
						}
					}
					else if (_manaOrbSprites.Count > 0)
					{
						val16.sprite = _manaOrbSprites.First().Value;
						((Graphic)val16).color = ((_manaOrbColors.Count > 0) ? _manaOrbColors.First().Value : Color.white);
					}
					GameObject val17 = new GameObject("Num");
					val17.transform.SetParent(val10.transform, false);
					RectTransform obj14 = val17.AddComponent<RectTransform>();
					obj14.anchorMin = Vector2.zero;
					obj14.anchorMax = Vector2.one;
					offsetMin = (obj14.offsetMax = Vector2.zero);
					obj14.offsetMin = offsetMin;
					TextMeshProUGUI obj15 = val17.AddComponent<TextMeshProUGUI>();
					((TMP_Text)obj15).text = ((item5.Key == -99) ? "W" : ((item5.Key == -98) ? "X" : item5.Key.ToString()));
					((TMP_Text)obj15).fontSize = 60f;
					((TMP_Text)obj15).fontStyle = (FontStyles)1;
					((TMP_Text)obj15).alignment = (TextAlignmentOptions)514;
					((Graphic)obj15).color = Color.white;
					((TMP_Text)obj15).enableWordWrapping = false;
					((TMP_Text)obj15).overflowMode = (TextOverflowModes)0;
					((TMP_Text)obj15).margin = Vector4.zero;
				}
				GameObject val18 = new GameObject("Cnt");
				val18.transform.SetParent(val3.transform, false);
				RectTransform obj16 = val18.AddComponent<RectTransform>();
				offsetMin = (obj16.anchorMax = new Vector2(0.5f, 0.5f));
				obj16.anchorMin = offsetMin;
				obj16.pivot = new Vector2(0f, 0.5f);
				obj16.anchoredPosition = new Vector2(num4, num5);
				obj16.sizeDelta = new Vector2(110f, 88f);
				TextMeshProUGUI obj17 = val18.AddComponent<TextMeshProUGUI>();
				((TMP_Text)obj17).text = $"x{item5.Value}";
				((TMP_Text)obj17).fontSize = 36f;
				((TMP_Text)obj17).fontStyle = (FontStyles)1;
				((TMP_Text)obj17).alignment = (TextAlignmentOptions)4097;
				((Graphic)obj17).color = Color.white;
				num5 -= 96f;
			}
		}
		else if (flag)
		{
			float num6 = (float)list.Count * 164f - 20f + 44f;
			val4.sizeDelta = new Vector2(num6, 150f);
			GameObject val20 = new GameObject("BgFill");
			val20.transform.SetParent(val3.transform, false);
			RectTransform obj18 = val20.AddComponent<RectTransform>();
			obj18.anchorMin = Vector2.zero;
			obj18.anchorMax = Vector2.one;
			Vector2 offsetMin = (obj18.offsetMax = Vector2.zero);
			obj18.offsetMin = offsetMin;
			((Graphic)val20.AddComponent<Image>()).color = new Color(0.294f, 0.31f, 0.455f, 0.97f);
			if ((Object)(object)_modalFrameSprite != (Object)null)
			{
				GameObject val21 = new GameObject("BgFrame");
				val21.transform.SetParent(val3.transform, false);
				RectTransform obj19 = val21.AddComponent<RectTransform>();
				obj19.anchorMin = Vector2.zero;
				obj19.anchorMax = Vector2.one;
				offsetMin = (obj19.offsetMax = Vector2.zero);
				obj19.offsetMin = offsetMin;
				Image obj20 = val21.AddComponent<Image>();
				obj20.sprite = _modalFrameSprite;
				obj20.type = (Type)1;
			}
			(string main, string sub) compositionLabel2 = GetCompositionLabel();
			string item3 = compositionLabel2.main;
			string item4 = compositionLabel2.sub;
			GameObject val22 = new GameObject("Title");
			val22.transform.SetParent(val3.transform, false);
			RectTransform obj21 = val22.AddComponent<RectTransform>();
			obj21.anchorMin = new Vector2(0f, 1f);
			obj21.anchorMax = new Vector2(1f, 1f);
			obj21.pivot = new Vector2(0.5f, 1f);
			obj21.anchoredPosition = new Vector2(0f, -4f);
			obj21.sizeDelta = new Vector2(-8f, 24f);
			TextMeshProUGUI obj22 = val22.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj22).text = item3;
			((TMP_Text)obj22).fontSize = 22f;
			((TMP_Text)obj22).fontStyle = (FontStyles)1;
			((TMP_Text)obj22).alignment = (TextAlignmentOptions)514;
			((Graphic)obj22).color = new Color(1f, 0.92f, 0.55f, 1f);
			((TMP_Text)obj22).enableWordWrapping = false;
			((TMP_Text)obj22).overflowMode = (TextOverflowModes)0;
			GameObject val23 = new GameObject("Subtitle");
			val23.transform.SetParent(val3.transform, false);
			RectTransform obj23 = val23.AddComponent<RectTransform>();
			obj23.anchorMin = new Vector2(0f, 1f);
			obj23.anchorMax = new Vector2(1f, 1f);
			obj23.pivot = new Vector2(0.5f, 1f);
			obj23.anchoredPosition = new Vector2(0f, -27f);
			obj23.sizeDelta = new Vector2(-8f, 18f);
			TextMeshProUGUI obj24 = val23.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj24).text = item4;
			((TMP_Text)obj24).fontSize = 14f;
			((TMP_Text)obj24).alignment = (TextAlignmentOptions)514;
			((Graphic)obj24).color = new Color(0.78f, 0.78f, 0.85f, 0.9f);
			((TMP_Text)obj24).enableWordWrapping = false;
			((TMP_Text)obj24).overflowMode = (TextOverflowModes)0;
			GameObject val24 = new GameObject("Sep");
			val24.transform.SetParent(val3.transform, false);
			RectTransform obj25 = val24.AddComponent<RectTransform>();
			obj25.anchorMin = new Vector2(0.03f, 1f);
			obj25.anchorMax = new Vector2(0.97f, 1f);
			obj25.pivot = new Vector2(0.5f, 1f);
			obj25.anchoredPosition = new Vector2(0f, -46f);
			obj25.sizeDelta = new Vector2(0f, 1f);
			((Graphic)val24.AddComponent<Image>()).color = new Color(1f, 0.92f, 0.55f, 0.35f);
			float num7 = -23f;
			float num8 = (0f - num6) / 2f + 22f;
			foreach (KeyValuePair<int, int> item6 in list)
			{
				GameObject val25 = new GameObject("Badge");
				val25.transform.SetParent(val3.transform, false);
				RectTransform obj26 = val25.AddComponent<RectTransform>();
				offsetMin = (obj26.anchorMax = new Vector2(0.5f, 0.5f));
				obj26.anchorMin = offsetMin;
				obj26.pivot = new Vector2(0f, 0.5f);
				obj26.anchoredPosition = new Vector2(num8, num7);
				obj26.sizeDelta = new Vector2(80f, 80f);
				if (item6.Key == -99 && _manaOrbSprites.ContainsKey(-99))
				{
					GameObject val27 = new GameObject("WildShadow");
					val27.transform.SetParent(val25.transform, false);
					RectTransform obj27 = val27.AddComponent<RectTransform>();
					offsetMin = (obj27.anchorMax = new Vector2(0.5f, 0.5f));
					obj27.anchorMin = offsetMin;
					obj27.pivot = new Vector2(0.5f, 0.5f);
					obj27.anchoredPosition = Vector2.zero;
					obj27.sizeDelta = new Vector2(92f, 92f);
					Image obj28 = val27.AddComponent<Image>();
					obj28.sprite = _manaOrbSprites[item6.Key];
					((Graphic)obj28).color = new Color(0.1f, 0.1f, 0.15f, 0.95f);
					GameObject val29 = new GameObject("WildBg");
					val29.transform.SetParent(val25.transform, false);
					RectTransform obj29 = val29.AddComponent<RectTransform>();
					offsetMin = (obj29.anchorMax = new Vector2(0.5f, 0.5f));
					obj29.anchorMin = offsetMin;
					obj29.pivot = new Vector2(0.5f, 0.5f);
					obj29.anchoredPosition = new Vector2(-2f, 2f);
					obj29.sizeDelta = new Vector2(80f, 80f);
					val29.AddComponent<Image>().sprite = _manaOrbSprites[item6.Key];
					GameObject val31 = new GameObject("WildFg");
					val31.transform.SetParent(val25.transform, false);
					RectTransform obj30 = val31.AddComponent<RectTransform>();
					offsetMin = (obj30.anchorMax = new Vector2(0.5f, 0.5f));
					obj30.anchorMin = offsetMin;
					obj30.pivot = new Vector2(0.5f, 0.5f);
					obj30.anchoredPosition = Vector2.zero;
					obj30.sizeDelta = new Vector2(80f, 80f);
					Image obj31 = val31.AddComponent<Image>();
					obj31.sprite = _manaOrbSprites[item6.Key];
					((Graphic)obj31).color = (Color)(_manaOrbColors.TryGetValue(item6.Key, out var value4) ? value4 : new Color(0f, 0.23f, 0.58f, 1f));
				}
				else
				{
					Image val33 = val25.AddComponent<Image>();
					if (_manaOrbSprites.TryGetValue(item6.Key, out var value5))
					{
						val33.sprite = value5;
						if (_manaOrbColors.TryGetValue(item6.Key, out var value6))
						{
							((Graphic)val33).color = value6;
						}
					}
					else
					{
						if (_manaOrbSprites.Count > 0)
						{
							val33.sprite = _manaOrbSprites.First().Value;
						}
						((Graphic)val33).color = ((_manaOrbColors.Count > 0) ? _manaOrbColors.First().Value : Color.white);
					}
					GameObject val34 = new GameObject("Num");
					val34.transform.SetParent(val25.transform, false);
					RectTransform obj32 = val34.AddComponent<RectTransform>();
					obj32.anchorMin = Vector2.zero;
					obj32.anchorMax = Vector2.one;
					offsetMin = (obj32.offsetMax = Vector2.zero);
					obj32.offsetMin = offsetMin;
					TextMeshProUGUI obj33 = val34.AddComponent<TextMeshProUGUI>();
					((TMP_Text)obj33).text = ((item6.Key == -99) ? "W" : ((item6.Key == -98) ? "X" : item6.Key.ToString()));
					((TMP_Text)obj33).fontSize = 56f;
					((TMP_Text)obj33).fontStyle = (FontStyles)1;
					((TMP_Text)obj33).alignment = (TextAlignmentOptions)514;
					((Graphic)obj33).color = Color.white;
					((TMP_Text)obj33).enableWordWrapping = false;
					((TMP_Text)obj33).overflowMode = (TextOverflowModes)0;
					((TMP_Text)obj33).margin = Vector4.zero;
				}
				GameObject val35 = new GameObject("Cnt");
				val35.transform.SetParent(val3.transform, false);
				RectTransform obj34 = val35.AddComponent<RectTransform>();
				offsetMin = (obj34.anchorMax = new Vector2(0.5f, 0.5f));
				obj34.anchorMin = offsetMin;
				obj34.pivot = new Vector2(0f, 0.5f);
				obj34.anchoredPosition = new Vector2(num8 + 80f + 4f, num7);
				obj34.sizeDelta = new Vector2(64f, 56f);
				TextMeshProUGUI obj35 = val35.AddComponent<TextMeshProUGUI>();
				((TMP_Text)obj35).text = $"x{item6.Value}";
				((TMP_Text)obj35).fontSize = 30f;
				((TMP_Text)obj35).fontStyle = (FontStyles)1;
				((TMP_Text)obj35).alignment = (TextAlignmentOptions)4097;
				((Graphic)obj35).color = Color.white;
				num8 += 164f;
			}
		}
		else
		{
			val4.sizeDelta = new Vector2(300f, 40f);
			GameObject val37 = new GameObject("BgFill");
			val37.transform.SetParent(val3.transform, false);
			RectTransform obj36 = val37.AddComponent<RectTransform>();
			obj36.anchorMin = Vector2.zero;
			obj36.anchorMax = Vector2.one;
			Vector2 offsetMin = (obj36.offsetMax = Vector2.zero);
			obj36.offsetMin = offsetMin;
			((Graphic)val37.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.72f);
			GameObject val38 = new GameObject("Label");
			val38.transform.SetParent(val3.transform, false);
			RectTransform obj37 = val38.AddComponent<RectTransform>();
			obj37.anchorMin = Vector2.zero;
			obj37.anchorMax = Vector2.one;
			obj37.offsetMin = new Vector2(6f, 0f);
			obj37.offsetMax = new Vector2(-6f, 0f);
			TextMeshProUGUI obj38 = val38.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj38).text = string.Join("   ", list.Select((KeyValuePair<int, int> kv) => $"{kv.Key}: {kv.Value}"));
			((TMP_Text)obj38).fontSize = 14f;
			((TMP_Text)obj38).alignment = (TextAlignmentOptions)514;
			((Graphic)obj38).color = new Color(1f, 0.92f, 0.55f, 1f);
		}
		return val3;
	}

	private void OnModalOpened(ChooseCardModal modal)
	{
		//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: Expected O, but got Unknown
		//IL_0336: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			PlayerModel playerModel = modal._playerModel;
			if ((Object)(object)playerModel == (Object)null)
			{
				return;
			}
			_cachedPlayerModel = playerModel;
			List<CardChoiceView> cardChoiceViews = modal._cardChoiceViews;
			if (cardChoiceViews == null)
			{
				return;
			}
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			List<CardConfig> list = new List<CardConfig>();
			List<CardModel> allCards = playerModel._allCards;
			Enumerator<CardModel> enumerator;
			if (allCards != null)
			{
				enumerator = allCards.GetEnumerator();
				while (enumerator.MoveNext())
				{
					CardModel current = enumerator.Current;
					CardConfig val = ((current != null) ? current.CardConfig : null);
					if (!((Object)(object)val == (Object)null))
					{
						if (((Object)val).name != null)
						{
							string baseKey = GetBaseKey(((Object)val).name);
							dictionary[baseKey] = ((!dictionary.TryGetValue(baseKey, out var value)) ? 1 : (value + 1));
						}
						list.Add(val);
					}
				}
			}
			TryCacheManaIcons(cardChoiceViews);
			Enumerator<CardChoiceView> enumerator2 = cardChoiceViews.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				CardChoiceView current2 = enumerator2.Current;
				if (!((Object)(object)current2 == (Object)null))
				{
					Transform tweenContainer = GetTweenContainer(((Component)current2).gameObject);
					Transform val2 = tweenContainer.Find("VCComboBadge");
					if ((Object)(object)val2 != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)((Component)val2).gameObject);
					}
					Transform val3 = tweenContainer.Find("VCCountBadge");
					if ((Object)(object)val3 != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)((Component)val3).gameObject);
					}
				}
			}
			enumerator2 = cardChoiceViews.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				CardChoiceView current3 = enumerator2.Current;
				if ((Object)(object)current3 == (Object)null)
				{
					continue;
				}
				CardConfig cardConfig = current3.CardConfig;
				if ((Object)(object)cardConfig == (Object)null)
				{
					continue;
				}
				string text = ((((Object)cardConfig).name != null) ? GetBaseKey(((Object)cardConfig).name) : "");
				int value2;
				int count = ((text.Length > 0 && dictionary.TryGetValue(text, out value2)) ? value2 : 0);
				AddCountBadge(((Component)current3).gameObject, count);
				if (((Object)cardConfig).name != null)
				{
					var (flag, evoName, isRedundant) = CheckCombo(cardConfig, list);
					if (flag)
					{
						AddBadge(((Component)current3).gameObject, evoName, isRedundant);
					}
				}
			}
			if ((Object)(object)_chooseCardOverlay != (Object)null)
			{
				Object.Destroy((Object)(object)_chooseCardOverlay);
				_chooseCardOverlay = null;
			}
			if (allCards == null)
			{
				return;
			}
			Dictionary<int, int> dictionary2 = new Dictionary<int, int>();
			enumerator = allCards.GetEnumerator();
			while (enumerator.MoveNext())
			{
				CardModel current4 = enumerator.Current;
				CardConfig val4 = ((current4 != null) ? current4.CardConfig : null);
				if ((Object)(object)val4 == (Object)null || ((Object)val4).name == null || !((Object)val4).name.StartsWith("Card_"))
				{
					continue;
				}
				string[] array = ((Object)val4).name.Split('_');
				bool num = array.Length == 3 || (array.Length >= 2 && array[1].ToUpperInvariant() == "E");
				int cost = -999;
				if (num)
				{
					cost = -99;
				}
				else
				{
					try
					{
						CardView cardView = current4.CardView;
						TMP_Text val5 = ((cardView != null) ? cardView._costText : null);
						if ((Object)(object)val5 != (Object)null)
						{
							TryParseCostText(val5.text, out cost);
						}
					}
					catch
					{
					}
					if (cost == -999)
					{
						int num2 = 0;
						try
						{
							CardGemsModel cardGems = current4.CardGems;
							Dictionary<GemConfig, GemManaModifierInfo> val6 = ((cardGems != null) ? cardGems._gemManaModifiers : null);
							if (val6 != null)
							{
								Enumerator<GemConfig, GemManaModifierInfo> enumerator3 = val6.GetEnumerator();
								while (enumerator3.MoveNext())
								{
									KeyValuePair<GemConfig, GemManaModifierInfo> current5 = enumerator3.Current;
									num2 += current5.Value.Count * current5.Value.Amount;
								}
							}
						}
						catch
						{
						}
						cost = val4.manaCost + num2;
					}
				}
				switch (cost)
				{
				case -99:
					TryCacheWildSpriteFromModel(current4);
					break;
				default:
					TryCacheOrbSpriteFromModel(current4, cost);
					break;
				case -98:
					break;
				}
				dictionary2[cost] = ((!dictionary2.TryGetValue(cost, out var value3)) ? 1 : (value3 + 1));
			}
			if (dictionary2.Count > 0)
			{
				_chooseCardOverlay = CreateManaPanel(((Component)modal).gameObject, dictionary2, -440f);
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag2 = default(bool);
			BepInExErrorLogInterpolatedStringHandler val7 = new BepInExErrorLogInterpolatedStringHandler(17, 1, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("[ComboIndicator] ");
				((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<Exception>(ex);
			}
			log.LogError(val7);
		}
	}

	private static string[] ParseComponents(string desc)
	{
		if (string.IsNullOrEmpty(desc))
		{
			return Array.Empty<string>();
		}
		int num = desc.IndexOf(':');
		if (num < 0)
		{
			return Array.Empty<string>();
		}
		return (from s in desc.Substring(num + 1).Replace(".", "").Split(',')
			select s.Trim() into s
			where s.Length > 0
			select s).ToArray();
	}

	private static string Norm(string s)
	{
		return new string(s.ToLowerInvariant().Where(char.IsLetter).ToArray());
	}

	private static string GetBaseName(string assetName)
	{
		if (string.IsNullOrEmpty(assetName))
		{
			return "";
		}
		string[] array = assetName.Split('_');
		if (array.Length < 4)
		{
			return Norm(assetName);
		}
		return Norm(string.Join("", array.Skip(3)));
	}

	private static string GetBaseKey(string assetName)
	{
		if (string.IsNullOrEmpty(assetName))
		{
			return "";
		}
		string[] array = assetName.Split('_');
		if (array.Length >= 4)
		{
			return array[1].ToLowerInvariant() + "_" + array[2] + "_" + Norm(string.Join("", array.Skip(3)));
		}
		return Norm(assetName);
	}

	private static bool CardMatchesComp(CardConfig card, string compNorm)
	{
		if (compNorm.Length == 0)
		{
			return false;
		}
		if (((Object)card).name != null && GetBaseName(((Object)card).name) == compNorm)
		{
			return true;
		}
		if (card.Name != null && Norm(card.Name) == compNorm)
		{
			return true;
		}
		return false;
	}

	private static bool OwnsComp(string compName, List<CardConfig> owned)
	{
		string text = Norm(compName);
		if (text.Length == 0)
		{
			return false;
		}
		foreach (CardConfig item in owned)
		{
			if ((Object)(object)item != (Object)null && CardMatchesComp(item, text))
			{
				return true;
			}
		}
		return false;
	}

	public static void InvalidateCardIndices()
	{
		_allKnownNorms = null;
		_allCompRefs = null;
	}

	private static void EnsureCardIndices()
	{
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Expected O, but got Unknown
		if (_allKnownNorms != null && _allCompRefs != null)
		{
			return;
		}
		HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal);
		HashSet<string> hashSet2 = new HashSet<string>(StringComparer.Ordinal);
		try
		{
			foreach (CardConfig item in Resources.FindObjectsOfTypeAll<CardConfig>())
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				if (!string.IsNullOrEmpty(((Object)item).name))
				{
					string baseName = GetBaseName(((Object)item).name);
					if (baseName.Length > 0)
					{
						hashSet.Add(baseName);
					}
				}
				try
				{
					string name = item.Name;
					if (!string.IsNullOrEmpty(name))
					{
						string text = Norm(name);
						if (text.Length > 0)
						{
							hashSet.Add(text);
						}
					}
				}
				catch
				{
				}
				try
				{
					if (!item.HasEvolution)
					{
						continue;
					}
					string evolveRequirementDescription = item.GetEvolveRequirementDescription();
					if (string.IsNullOrEmpty(evolveRequirementDescription))
					{
						continue;
					}
					string[] array = ParseComponents(evolveRequirementDescription);
					for (int i = 0; i < array.Length; i++)
					{
						string text2 = Norm(array[i]);
						if (text2.Length > 0)
						{
							hashSet2.Add(text2);
						}
					}
				}
				catch
				{
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ComboIndicator] EnsureCardIndices: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val);
		}
		_allKnownNorms = hashSet;
		_allCompRefs = hashSet2;
	}

	private static bool IsKnownCompName(string norm)
	{
		if (norm.Length > 0 && _allKnownNorms != null)
		{
			return _allKnownNorms.Contains(norm);
		}
		return false;
	}

	private static bool IsCardReferencedAsComp(CardConfig c)
	{
		if ((Object)(object)c == (Object)null || _allCompRefs == null)
		{
			return false;
		}
		if (!string.IsNullOrEmpty(((Object)c).name))
		{
			string baseName = GetBaseName(((Object)c).name);
			if (baseName.Length > 0 && _allCompRefs.Contains(baseName))
			{
				return true;
			}
		}
		try
		{
			string name = c.Name;
			if (!string.IsNullOrEmpty(name))
			{
				string text = Norm(name);
				if (text.Length > 0 && _allCompRefs.Contains(text))
				{
					return true;
				}
			}
		}
		catch
		{
		}
		return false;
	}

	private static HashSet<CardConfig> TryAssignComps(string[] comps, List<CardConfig> pool, CardConfig targetEvolved)
	{
		HashSet<CardConfig> hashSet = new HashSet<CardConfig>();
		List<int> list = new List<int>();
		int num = 0;
		for (int i = 0; i < comps.Length; i++)
		{
			string text = Norm(comps[i]);
			if (text.Length == 0)
			{
				continue;
			}
			CardConfig val = null;
			foreach (CardConfig item in pool)
			{
				if (!((Object)(object)item == (Object)null) && !hashSet.Contains(item) && CardMatchesComp(item, text))
				{
					val = item;
					break;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				hashSet.Add(val);
				num++;
				continue;
			}
			if (IsKnownCompName(text))
			{
				return null;
			}
			list.Add(i);
		}
		if (list.Count > 0 && num == 0)
		{
			return null;
		}
		if (list.Count > 0 && (Object)(object)targetEvolved == (Object)null)
		{
			return null;
		}
		foreach (int item2 in list)
		{
			_ = item2;
			CardConfig val2 = null;
			foreach (CardConfig item3 in pool)
			{
				if ((Object)(object)item3 == (Object)null || hashSet.Contains(item3))
				{
					continue;
				}
				bool flag = false;
				for (int j = 0; j < comps.Length; j++)
				{
					string text2 = Norm(comps[j]);
					if (text2.Length > 0 && CardMatchesComp(item3, text2))
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					continue;
				}
				bool flag2 = false;
				if (SameEvolutionTarget(item3, targetEvolved))
				{
					flag2 = true;
				}
				else
				{
					bool flag3 = false;
					try
					{
						flag3 = item3.HasEvolution;
					}
					catch
					{
					}
					if (!flag3 && !IsCardReferencedAsComp(item3))
					{
						flag2 = true;
					}
				}
				if (flag2)
				{
					val2 = item3;
					break;
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return null;
			}
			hashSet.Add(val2);
		}
		return hashSet;
	}

	private static bool SameEvolutionTarget(CardConfig c, CardConfig target)
	{
		if ((Object)(object)c == (Object)null || (Object)(object)target == (Object)null)
		{
			return false;
		}
		try
		{
			if (!c.HasEvolution)
			{
				return false;
			}
			CardConfig evolvedCardConfig = c.EvolvedCardConfig;
			if ((Object)(object)evolvedCardConfig == (Object)null)
			{
				return false;
			}
			if (Object.ReferenceEquals((Object)(object)evolvedCardConfig, (Object)(object)target))
			{
				return true;
			}
			return ((Object)evolvedCardConfig).name == ((Object)target).name;
		}
		catch
		{
			return false;
		}
	}

	private static (bool hasCombo, string evoName, bool isRedundant) CheckCombo(CardConfig offered, List<CardConfig> ownedConfigs)
	{
		EnsureCardIndices();
		if (offered.HasEvolution)
		{
			string[] array = ParseComponents(offered.GetEvolveRequirementDescription());
			if (array.Length != 0)
			{
				List<CardConfig> list = new List<CardConfig>(ownedConfigs);
				if (!list.Contains(offered))
				{
					list.Add(offered);
				}
				HashSet<CardConfig> hashSet = TryAssignComps(array, list, offered.EvolvedCardConfig);
				if (hashSet != null && hashSet.Any((CardConfig c) => !Object.ReferenceEquals((Object)(object)c, (Object)(object)offered) && ownedConfigs.Contains(c)))
				{
					bool item = hashSet.All((CardConfig c) => ownedConfigs.Contains(c));
					CardConfig evolvedCardConfig = offered.EvolvedCardConfig;
					return (true, ((evolvedCardConfig != null) ? evolvedCardConfig.Name : null) ?? "?", item);
				}
			}
		}
		foreach (CardConfig ownedConfig in ownedConfigs)
		{
			if ((Object)(object)ownedConfig == (Object)null || !ownedConfig.HasEvolution)
			{
				continue;
			}
			string[] array2 = ParseComponents(ownedConfig.GetEvolveRequirementDescription());
			if (array2.Length == 0)
			{
				continue;
			}
			List<CardConfig> list2 = new List<CardConfig> { offered };
			foreach (CardConfig ownedConfig2 in ownedConfigs)
			{
				list2.Add(ownedConfig2);
			}
			HashSet<CardConfig> hashSet2 = TryAssignComps(array2, list2, ownedConfig.EvolvedCardConfig);
			if (hashSet2 != null && hashSet2.Contains(offered))
			{
				bool item2 = hashSet2.All((CardConfig c) => ownedConfigs.Contains(c));
				CardConfig evolvedCardConfig2 = ownedConfig.EvolvedCardConfig;
				return (true, ((evolvedCardConfig2 != null) ? evolvedCardConfig2.Name : nul