Decompiled source of Open CardPack Customiser v1.1.3

BepInEx/plugins/OpenCardPackCustomiser.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CMF;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("77712db8-fe58-4b0a-aa58-4355d55dc7ad")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Cardmod;

internal class CustomCardPatch
{
	private static FieldRef<CardOpeningSequence, List<CardData>> m_SecondaryRolledCardDataList = AccessTools.FieldRefAccess<CardOpeningSequence, List<CardData>>("m_SecondaryRolledCardDataList");

	private static FieldRef<CardOpeningSequence, List<CardData>> m_RolledCardDataList = AccessTools.FieldRefAccess<CardOpeningSequence, List<CardData>>("m_RolledCardDataList");

	private static FieldRef<CardOpeningSequence, List<CardData>> m_CardDataPool = AccessTools.FieldRefAccess<CardOpeningSequence, List<CardData>>("m_CardDataPool");

	private static FieldRef<CardOpeningSequence, List<CardData>> m_CardDataPool2 = AccessTools.FieldRefAccess<CardOpeningSequence, List<CardData>>("m_CardDataPool2");

	private static FieldRef<CardOpeningSequence, List<CardData>> m_ManualOpenCardDataList = AccessTools.FieldRefAccess<CardOpeningSequence, List<CardData>>("m_ManualOpenCardDataList");

	private static FieldRef<CardOpeningSequence, List<float>> m_CardValueList = AccessTools.FieldRefAccess<CardOpeningSequence, List<float>>("m_CardValueList");

	public static MethodInfo getGodPackRollIndexMethod = AccessTools.Method(typeof(CardOpeningSequence), "GetGodPackRollIndex", (Type[])null, (Type[])null);

	private static FieldRef<CardOpeningSequence, ECollectionPackType> m_CollectionPackType = AccessTools.FieldRefAccess<CardOpeningSequence, ECollectionPackType>("m_CollectionPackType");

	private static FieldRef<CardOpeningSequence, bool> m_HasFoilCard = AccessTools.FieldRefAccess<CardOpeningSequence, bool>("m_HasFoilCard");

	private static FieldRef<CardOpeningSequence, bool> m_IsScreenActive = AccessTools.FieldRefAccess<CardOpeningSequence, bool>("m_IsScreenActive");

	private static FieldRef<CardOpeningSequence, List<bool>> m_IsNewlList = AccessTools.FieldRefAccess<CardOpeningSequence, List<bool>>("m_IsNewlList");

	private static FieldRef<CardOpeningSequence, int> m_TotalExpGained = AccessTools.FieldRefAccess<CardOpeningSequence, int>("m_TotalExpGained");

	private static FieldRef<CardOpeningSequence, float> m_TotalCardValue = AccessTools.FieldRefAccess<CardOpeningSequence, float>("m_TotalCardValue");

	private static FieldRef<CardOpeningSequence, int> m_StateIndex = AccessTools.FieldRefAccess<CardOpeningSequence, int>("m_StateIndex");

	private static FieldRef<CardOpeningSequence, int> m_GCCollectCount = AccessTools.FieldRefAccess<CardOpeningSequence, int>("m_GCCollectCount");

	private static FieldRef<CardOpeningSequence, int> m_CurrentOpenedCardIndex = AccessTools.FieldRefAccess<CardOpeningSequence, int>("m_CurrentOpenedCardIndex");

	private static FieldRef<CardOpeningSequence, float> m_StateTimer = AccessTools.FieldRefAccess<CardOpeningSequence, float>("m_StateTimer");

	private static FieldRef<CardOpeningSequence, float> m_HighValueCardThreshold = AccessTools.FieldRefAccess<CardOpeningSequence, float>("m_HighValueCardThreshold");

	public static MethodInfo getPackContentMethod = AccessTools.Method(typeof(CardOpeningSequence), "GetPackContent", new Type[4]
	{
		typeof(bool),
		typeof(int),
		typeof(bool),
		typeof(ECollectionPackType)
	}, (Type[])null);

	[HarmonyPatch(typeof(CardOpeningSequence), "GetPackContent")]
	[HarmonyPrefix]
	public static bool Prefix(ref CardOpeningSequence __instance, bool clearList, int godPackRollIndex, bool isSecondaryRolledData = false, ECollectionPackType overrideCollectionPackType = -1)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Invalid comparison between Unknown and I4
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Invalid comparison between Unknown and I4
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Invalid comparison between Unknown and I4
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0411: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0608: Unknown result type (might be due to invalid IL or missing references)
		//IL_060f: Expected I4, but got Unknown
		//IL_0547: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Invalid comparison between Unknown and I4
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_057b: Unknown result type (might be due to invalid IL or missing references)
		//IL_057e: Invalid comparison between Unknown and I4
		//IL_055f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0566: Expected I4, but got Unknown
		//IL_064e: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a9: Invalid comparison between Unknown and I4
		//IL_0591: Unknown result type (might be due to invalid IL or missing references)
		//IL_0598: Expected I4, but got Unknown
		//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e9: Expected I4, but got Unknown
		//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c3: Expected I4, but got Unknown
		//IL_0538: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_052b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0711: Unknown result type (might be due to invalid IL or missing references)
		//IL_0735: Unknown result type (might be due to invalid IL or missing references)
		//IL_0759: Unknown result type (might be due to invalid IL or missing references)
		//IL_078c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0786: Unknown result type (might be due to invalid IL or missing references)
		//IL_0789: Invalid comparison between Unknown and I4
		//IL_077d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0790: Unknown result type (might be due to invalid IL or missing references)
		//IL_0792: Unknown result type (might be due to invalid IL or missing references)
		//IL_0799: Unknown result type (might be due to invalid IL or missing references)
		//IL_079b: 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_07b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bb: Invalid comparison between Unknown and I4
		//IL_07c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07cf: Invalid comparison between Unknown and I4
		if (Plugin.Highvaluecard.Value)
		{
			m_HighValueCardThreshold.Invoke(__instance) = 1E+15f;
		}
		else
		{
			m_HighValueCardThreshold.Invoke(__instance) = 10f;
		}
		if (clearList)
		{
			if (isSecondaryRolledData)
			{
				m_SecondaryRolledCardDataList.Invoke(__instance).Clear();
			}
			else
			{
				m_RolledCardDataList.Invoke(__instance).Clear();
			}
		}
		List<EMonsterType> list = new List<EMonsterType>();
		List<EMonsterType> list2 = new List<EMonsterType>();
		List<EMonsterType> list3 = new List<EMonsterType>();
		List<EMonsterType> list4 = new List<EMonsterType>();
		List<EMonsterType> list5 = new List<EMonsterType>();
		ECardExpansionType cardExpansionType = InventoryBase.GetCardExpansionType(m_CollectionPackType.Invoke(__instance));
		if (isSecondaryRolledData)
		{
			cardExpansionType = InventoryBase.GetCardExpansionType(overrideCollectionPackType);
		}
		bool openPackCanUseRarity = InventoryBase.GetCardUISetting(cardExpansionType).openPackCanUseRarity;
		bool openPackCanHaveDuplicate = InventoryBase.GetCardUISetting(cardExpansionType).openPackCanHaveDuplicate;
		for (int i = 0; i < InventoryBase.GetShownMonsterList(cardExpansionType).Count; i++)
		{
			EMonsterType monsterType = InventoryBase.GetMonsterData(InventoryBase.GetShownMonsterList(cardExpansionType)[i]).MonsterType;
			ERarity rarity = InventoryBase.GetMonsterData(InventoryBase.GetShownMonsterList(cardExpansionType)[i]).Rarity;
			list.Add(monsterType);
			if ((int)rarity == 3)
			{
				list5.Add(monsterType);
			}
			else if ((int)rarity == 2)
			{
				list4.Add(monsterType);
			}
			else if ((int)rarity == 1)
			{
				list3.Add(monsterType);
			}
			else
			{
				list2.Add(monsterType);
			}
		}
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		int num5 = 1;
		int num6 = 0;
		int num7 = 0;
		int num8 = 0;
		float num9 = 10f;
		float num10 = 2f;
		float num11 = 0.1f;
		float num12 = Plugin.FoilMultiplier.Value;
		ECardBorderType borderType = (ECardBorderType)0;
		float num13 = Plugin.FristEdtionMultiplier.Value;
		float num14 = Plugin.SilverMultiplier.Value;
		float num15 = Plugin.GoldMultiplier.Value;
		float num16 = Plugin.ExMultiplier.Value;
		float num17 = Plugin.FullArtMultiplier.Value;
		ERarity val = (ERarity)0;
		int num18 = 7;
		if ((int)m_CollectionPackType.Invoke(__instance) == 1 || (int)m_CollectionPackType.Invoke(__instance) == 5)
		{
			num5 = 0;
			num6 = 7;
			num9 += 45f;
			num10 += 2f;
			num11 += 1f;
		}
		else if ((int)m_CollectionPackType.Invoke(__instance) == 2 || (int)m_CollectionPackType.Invoke(__instance) == 6)
		{
			num5 = 0;
			num6 = 1;
			num7 = 7;
			num8 = 0;
			num9 += 65f;
			num10 += 45f;
			num11 += 3f;
		}
		else if ((int)m_CollectionPackType.Invoke(__instance) == 3 || (int)m_CollectionPackType.Invoke(__instance) == 7)
		{
			num5 = 0;
			num6 = 0;
			num7 = 1;
			num8 = 7;
			num9 += 65f;
			num10 += 55f;
			num11 += 35f;
		}
		else if ((int)m_CollectionPackType.Invoke(__instance) == 0 || (int)m_CollectionPackType.Invoke(__instance) == 4)
		{
			num5 = 7;
		}
		if (godPackRollIndex > 0)
		{
			num12 = 0f;
			num13 = 0f;
			num14 = 0f;
			num15 = 0f;
			num16 = 0f;
			num17 = 0f;
		}
		switch (godPackRollIndex)
		{
		case 1:
			num13 = 100f;
			break;
		case 2:
			num14 = 100f;
			break;
		case 3:
			num15 = 100f;
			break;
		case 4:
			num16 = 100f;
			break;
		case 5:
			num17 = 100f;
			break;
		case 6:
			num12 = 10000f;
			num13 = 100f;
			break;
		case 7:
			num12 = 10000f;
			num14 = 100f;
			break;
		case 8:
			num12 = 10000f;
			num15 = 100f;
			break;
		case 9:
			num12 = 10000f;
			num16 = 100f;
			break;
		case 10:
			num12 = 10000f;
			num17 = 100f;
			break;
		case 12:
			num12 = 10000f;
			break;
		case 13:
			num12 = 10000f;
			break;
		}
		for (int j = 0; j < num18; j++)
		{
			if (list.Count <= 0)
			{
				break;
			}
			int num19 = Random.Range(0, list.Count);
			if (num8 - num4 > 0 && list5.Count > 0)
			{
				val = (ERarity)3;
				num4++;
			}
			else if (num7 - num3 > 0 && list4.Count > 0)
			{
				val = (ERarity)2;
				num3++;
			}
			else if (num6 - num2 > 0 && list3.Count > 0)
			{
				val = (ERarity)1;
				num2++;
			}
			else if (num5 - num > 0 && list2.Count > 0)
			{
				val = (ERarity)0;
				num++;
			}
			else
			{
				int num20 = Random.Range(0, 10000);
				int num21 = 4 - num2;
				int num22 = 4 - num3;
				int num23 = 4 - num4;
				bool flag = false;
				if (!flag && num11 > 0f && list5.Count > 0 && num23 > 0)
				{
					int num24 = Mathf.RoundToInt(num11 * 100f);
					if (num20 < num24)
					{
						flag = true;
						val = (ERarity)3;
						num4++;
					}
				}
				if (!flag && num10 > 0f && list4.Count > 0 && num22 > 0)
				{
					int num25 = Mathf.RoundToInt(num10 * 100f);
					if (num20 < num25)
					{
						flag = true;
						val = (ERarity)2;
						num3++;
					}
				}
				if (!flag && num9 > 0f && list3.Count > 0 && num21 > 0)
				{
					int num26 = Mathf.RoundToInt(num9 * 100f);
					if (num20 < num26)
					{
						flag = true;
						val = (ERarity)1;
						num2++;
					}
				}
				if (!flag)
				{
					val = (ERarity)0;
					num++;
				}
			}
			int num27;
			if (openPackCanUseRarity)
			{
				if ((int)val == 3)
				{
					num19 = Random.Range(0, list5.Count);
					num27 = (int)list5[num19];
					if (!openPackCanHaveDuplicate)
					{
						list5.RemoveAt(num19);
					}
				}
				else if ((int)val == 2)
				{
					num19 = Random.Range(0, list4.Count);
					num27 = (int)list4[num19];
					if (!openPackCanHaveDuplicate)
					{
						list4.RemoveAt(num19);
					}
				}
				else if ((int)val == 1)
				{
					num19 = Random.Range(0, list3.Count);
					num27 = (int)list3[num19];
					if (!openPackCanHaveDuplicate)
					{
						list3.RemoveAt(num19);
					}
				}
				else
				{
					num19 = Random.Range(0, list2.Count);
					num27 = (int)list2[num19];
					if (!openPackCanHaveDuplicate)
					{
						list2.RemoveAt(num19);
					}
				}
			}
			else
			{
				num19 = Random.Range(0, list.Count);
				num27 = (int)list[num19];
				if (!openPackCanHaveDuplicate)
				{
					list.RemoveAt(num19);
				}
			}
			CardData val2 = m_CardDataPool.Invoke(__instance)[j];
			if (isSecondaryRolledData)
			{
				val2 = m_CardDataPool2.Invoke(__instance)[j];
			}
			val2.monsterType = (EMonsterType)num27;
			if (Random.Range(0, 10000) < Mathf.RoundToInt(num12 * 100f))
			{
				val2.isFoil = true;
				m_HasFoilCard.Invoke(__instance) = true;
			}
			else
			{
				val2.isFoil = false;
			}
			if (CPlayerData.m_TutorialIndex < 10 && CPlayerData.m_GameReportDataCollectPermanent.cardPackOpened == 0 && !m_HasFoilCard.Invoke(__instance) && j == num18 - 1)
			{
				val2.isFoil = true;
				m_HasFoilCard.Invoke(__instance) = true;
			}
			bool flag2 = false;
			if (Random.Range(0, 10000) < Mathf.RoundToInt(num17 * 100f))
			{
				borderType = (ECardBorderType)5;
				flag2 = true;
			}
			if (!flag2 && Random.Range(0, 10000) < Mathf.RoundToInt(num16 * 100f))
			{
				borderType = (ECardBorderType)4;
				flag2 = true;
			}
			if (!flag2 && Random.Range(0, 10000) < Mathf.RoundToInt(num15 * 100f))
			{
				borderType = (ECardBorderType)3;
				flag2 = true;
			}
			if (!flag2 && Random.Range(0, 10000) < Mathf.RoundToInt(num14 * 100f))
			{
				borderType = (ECardBorderType)2;
				flag2 = true;
			}
			if (!flag2 && Random.Range(0, 10000) < Mathf.RoundToInt(num13 * 100f))
			{
				borderType = (ECardBorderType)1;
				flag2 = true;
			}
			if (!flag2 || (int)cardExpansionType == 2)
			{
				borderType = (ECardBorderType)0;
			}
			val2.borderType = borderType;
			val2.expansionType = cardExpansionType;
			if ((int)val2.expansionType == 0)
			{
				val2.isDestiny = false;
			}
			else if ((int)val2.expansionType == 1)
			{
				val2.isDestiny = true;
			}
			else if ((int)val2.expansionType == 2)
			{
				int num28 = Random.Range(0, 100);
				val2.isDestiny = num28 < 50;
			}
			else
			{
				val2.isDestiny = false;
			}
			if (isSecondaryRolledData)
			{
				m_SecondaryRolledCardDataList.Invoke(__instance).Add(val2);
			}
			else
			{
				m_RolledCardDataList.Invoke(__instance).Add(val2);
			}
		}
		list.Clear();
		list2.Clear();
		list3.Clear();
		list4.Clear();
		list5.Clear();
		m_GCCollectCount.Invoke(__instance)++;
		if (m_GCCollectCount.Invoke(__instance) >= 100)
		{
			m_GCCollectCount.Invoke(__instance) = 0;
			GC.Collect();
		}
		return false;
	}

	[HarmonyPatch(typeof(CardOpeningSequence), "OpenScreen")]
	[HarmonyPrefix]
	public static bool Prefix_OpenScreen(ref CardOpeningSequence __instance, ECollectionPackType collectionPackType, bool isMultiPack, bool isPremiumPack = false)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected I4, but got Unknown
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Invalid comparison between Unknown and I4
		//IL_043b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0441: Invalid comparison between Unknown and I4
		//IL_058c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0592: Invalid comparison between Unknown and I4
		//IL_064d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0657: Expected O, but got Unknown
		m_IsScreenActive.Invoke(__instance) = true;
		m_CollectionPackType.Invoke(__instance) = (ECollectionPackType)(int)collectionPackType;
		m_IsNewlList.Invoke(__instance).Clear();
		m_TotalExpGained.Invoke(__instance) = 0;
		m_TotalCardValue.Invoke(__instance) = 0f;
		m_HasFoilCard.Invoke(__instance) = false;
		if (isMultiPack)
		{
			m_ManualOpenCardDataList.Invoke(__instance).Clear();
			m_RolledCardDataList.Invoke(__instance).Clear();
			m_CardValueList.Invoke(__instance).Clear();
			m_SecondaryRolledCardDataList.Invoke(__instance).Clear();
			m_StateIndex.Invoke(__instance) = -1;
			int godPackRollIndex = (int)getGodPackRollIndexMethod.Invoke(__instance, null);
			Prefix(ref __instance, clearList: false, godPackRollIndex, isSecondaryRolledData: false, (ECollectionPackType)(-1));
			godPackRollIndex = (int)getGodPackRollIndexMethod.Invoke(__instance, null);
			Prefix(ref __instance, clearList: false, godPackRollIndex, isSecondaryRolledData: false, (ECollectionPackType)(-1));
			godPackRollIndex = (int)getGodPackRollIndexMethod.Invoke(__instance, null);
			Prefix(ref __instance, clearList: false, godPackRollIndex, isSecondaryRolledData: false, (ECollectionPackType)(-1));
			godPackRollIndex = (int)getGodPackRollIndexMethod.Invoke(__instance, null);
			Prefix(ref __instance, clearList: false, godPackRollIndex, isSecondaryRolledData: false, (ECollectionPackType)(-1));
			godPackRollIndex = (int)getGodPackRollIndexMethod.Invoke(__instance, null);
			Prefix(ref __instance, clearList: false, godPackRollIndex, isSecondaryRolledData: false, (ECollectionPackType)(-1));
		}
		else
		{
			int num = (int)getGodPackRollIndexMethod.Invoke(__instance, null);
			m_StateIndex.Invoke(__instance) = 0;
			Prefix(ref __instance, clearList: false, num, isSecondaryRolledData: false, (ECollectionPackType)(-1));
			m_ManualOpenCardDataList.Invoke(__instance).Clear();
			m_CardValueList.Invoke(__instance).Clear();
			for (int i = 0; i < m_RolledCardDataList.Invoke(__instance).Count; i++)
			{
				m_ManualOpenCardDataList.Invoke(__instance).Add(m_RolledCardDataList.Invoke(__instance)[i]);
				m_CardValueList.Invoke(__instance).Add(CPlayerData.GetCardMarketPrice(m_RolledCardDataList.Invoke(__instance)[i]));
			}
			ECardExpansionType cardExpansionType = InventoryBase.GetCardExpansionType(collectionPackType);
			if (((int)cardExpansionType == 0 || (int)cardExpansionType == 1) && Plugin.EnableGhostCounter.Value && CPlayerData.m_ShopLevel > 1)
			{
				getPackContentMethod.Invoke(__instance, new object[4]
				{
					true,
					num,
					true,
					(object)(ECollectionPackType)8
				});
				if (m_SecondaryRolledCardDataList.Invoke(__instance).Count > 0)
				{
					if (num == 11 || num == 12)
					{
						for (int j = 0; j < m_SecondaryRolledCardDataList.Invoke(__instance).Count; j++)
						{
							m_ManualOpenCardDataList.Invoke(__instance)[j] = m_SecondaryRolledCardDataList.Invoke(__instance)[j];
							m_CardValueList.Invoke(__instance)[j] = CPlayerData.GetCardMarketPrice(m_SecondaryRolledCardDataList.Invoke(__instance)[j]);
						}
					}
					else
					{
						int num2 = Mathf.Min(Plugin.GhostCount.Value, m_SecondaryRolledCardDataList.Invoke(__instance).Count);
						for (int k = 0; k < num2; k++)
						{
							m_ManualOpenCardDataList.Invoke(__instance)[k] = m_SecondaryRolledCardDataList.Invoke(__instance)[k];
							m_CardValueList.Invoke(__instance)[k] = CPlayerData.GetCardMarketPrice(m_SecondaryRolledCardDataList.Invoke(__instance)[k]);
						}
					}
				}
			}
		}
		m_CurrentOpenedCardIndex.Invoke(__instance) = 0;
		for (int l = 0; l < __instance.m_Card3dUIList.Count; l++)
		{
			((Component)__instance.m_Card3dUIList[l]).gameObject.SetActive(false);
		}
		for (int m = 0; m < m_ManualOpenCardDataList.Invoke(__instance).Count; m++)
		{
			CPlayerData.AddCard(m_ManualOpenCardDataList.Invoke(__instance)[m], 1);
			__instance.m_Card3dUIList[m].m_CardUI.SetCardUI(m_ManualOpenCardDataList.Invoke(__instance)[m]);
			if ((int)m_ManualOpenCardDataList.Invoke(__instance)[m].monsterType > 0 && CPlayerData.GetCardAmount(m_ManualOpenCardDataList.Invoke(__instance)[m]) == 1)
			{
				m_ManualOpenCardDataList.Invoke(__instance)[m].isNew = true;
				if (CSingleton<CGameManager>.Instance.m_OpenPackShowNewCard)
				{
					m_IsNewlList.Invoke(__instance).Add(item: true);
				}
				else
				{
					m_IsNewlList.Invoke(__instance).Add(item: false);
				}
			}
			else
			{
				m_ManualOpenCardDataList.Invoke(__instance)[m].isNew = false;
				m_IsNewlList.Invoke(__instance).Add(item: false);
			}
		}
		CSingleton<InteractionPlayerController>.Instance.m_CollectionBinderFlipAnimCtrl.SetCanUpdateSort(true);
		if (isMultiPack)
		{
			m_StateTimer.Invoke(__instance) = 0f;
			m_StateTimer.Invoke(__instance) = 0f;
			m_StateIndex.Invoke(__instance) = 101;
			for (int n = 0; n < m_ManualOpenCardDataList.Invoke(__instance).Count; n++)
			{
				__instance.m_Card3dUIList[n].m_CardUI.SetCardUI(m_ManualOpenCardDataList.Invoke(__instance)[n]);
				if ((int)m_ManualOpenCardDataList.Invoke(__instance)[n].monsterType > 0 && CPlayerData.GetCardAmount(m_ManualOpenCardDataList.Invoke(__instance)[n]) == 1)
				{
					m_ManualOpenCardDataList.Invoke(__instance)[n].isNew = true;
					if (CSingleton<CGameManager>.Instance.m_OpenPackShowNewCard)
					{
						m_IsNewlList.Invoke(__instance).Add(item: true);
					}
					else
					{
						m_IsNewlList.Invoke(__instance).Add(item: false);
					}
				}
				else
				{
					m_ManualOpenCardDataList.Invoke(__instance)[n].isNew = false;
					m_IsNewlList.Invoke(__instance).Add(item: false);
				}
			}
			CEventManager.QueueEvent((CEvent)new CEventPlayer_SetCanvasGroupVisibility(false));
		}
		return false;
	}
}
public class Main : MonoBehaviour
{
	public static bool showgui;

	public CursorLockMode lockmode;

	public AdvancedWalkerController controller;

	public CameraController camera;

	public Rect windowRect = new Rect(30f, 30f, 600f, 650f);

	private int ghostCountValue;

	public static float GhostMultiplier;

	public void Update()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Invalid comparison between Unknown and I4
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut value = Plugin.OpenMenu.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			SoundManager.GenericMenuOpen(1f, 1f);
			showgui = !showgui;
			if (showgui)
			{
				lockmode = Cursor.lockState;
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
				camera = Object.FindObjectOfType<CameraController>();
				((Behaviour)camera).enabled = false;
			}
			else if ((int)lockmode == 1)
			{
				Cursor.lockState = (CursorLockMode)1;
				Cursor.visible = false;
				camera = Object.FindObjectOfType<CameraController>();
				((Behaviour)camera).enabled = true;
			}
		}
	}

	public void OnGUI()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		if (showgui)
		{
			GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.9f);
			GUI.contentColor = Color.red;
			windowRect = GUI.Window(0, windowRect, new WindowFunction(DoModWindow), "OpenCardPackCustomiser");
		}
	}

	public void DoModWindow(int windowID)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Expected O, but got Unknown
		//IL_0073: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_050f: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0780: Unknown result type (might be due to invalid IL or missing references)
		//IL_0852: Unknown result type (might be due to invalid IL or missing references)
		//IL_0939: Unknown result type (might be due to invalid IL or missing references)
		new GUIStyle(GUI.skin.label)
		{
			fontSize = 18
		}.normal.textColor = Color.green;
		GUIStyle val = new GUIStyle(GUI.skin.label);
		val.fontSize = 22;
		val.fontStyle = (FontStyle)1;
		val.normal.textColor = Color.green;
		GUIStyle val2 = new GUIStyle(GUI.skin.button);
		val2.fontSize = 12;
		val2.normal.textColor = Color.white;
		val2.hover.textColor = Color.yellow;
		GUIStyle val3 = new GUIStyle(GUI.skin.toggle);
		val3.fontSize = 12;
		val3.normal.textColor = Color.white;
		val3.hover.textColor = Color.yellow;
		GUILayout.Space(10f);
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("Multipliers Configuration", val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(280f) });
		GUILayout.Space(10f);
		GUI.backgroundColor = Color.blue;
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Foil Multiplier", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		Plugin.FoilMultiplier.Value = GUILayout.HorizontalSlider(Plugin.FoilMultiplier.Value, 0f, 200f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		GUILayout.Label(Plugin.FoilMultiplier.Value.ToString("0.000"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		if (GUILayout.Button("Reset", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			Plugin.FoilMultiplier.Value = 5f;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("First Edition Multiplier", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		Plugin.FristEdtionMultiplier.Value = GUILayout.HorizontalSlider(Plugin.FristEdtionMultiplier.Value, 0f, 200f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		GUILayout.Label(Plugin.FristEdtionMultiplier.Value.ToString("0.000"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		GUI.backgroundColor = Color.blue;
		if (GUILayout.Button("Reset", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			Plugin.FristEdtionMultiplier.Value = 20f;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Silver Multiplier", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		Plugin.SilverMultiplier.Value = GUILayout.HorizontalSlider(Plugin.SilverMultiplier.Value, 0f, 200f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		GUILayout.Label(Plugin.SilverMultiplier.Value.ToString("0.000"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		GUI.backgroundColor = Color.blue;
		if (GUILayout.Button("Reset", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			Plugin.SilverMultiplier.Value = 8f;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Gold Multiplier", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		Plugin.GoldMultiplier.Value = GUILayout.HorizontalSlider(Plugin.GoldMultiplier.Value, 0f, 200f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		GUILayout.Label(Plugin.GoldMultiplier.Value.ToString("0.000"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		GUI.backgroundColor = Color.blue;
		if (GUILayout.Button("Reset", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			Plugin.GoldMultiplier.Value = 4f;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("EX Multiplier", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		Plugin.ExMultiplier.Value = GUILayout.HorizontalSlider(Plugin.ExMultiplier.Value, 0f, 200f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		GUILayout.Label(Plugin.ExMultiplier.Value.ToString("0.000"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		GUI.backgroundColor = Color.blue;
		if (GUILayout.Button("Reset", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			Plugin.ExMultiplier.Value = 1f;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Full Art Multiplier", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		Plugin.FullArtMultiplier.Value = GUILayout.HorizontalSlider(Plugin.FullArtMultiplier.Value, 0f, 200f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		GUILayout.Label(Plugin.FullArtMultiplier.Value.ToString("0.000"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		GUI.backgroundColor = Color.blue;
		if (GUILayout.Button("Reset", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			Plugin.FullArtMultiplier.Value = 0.25f;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Ghost Multiplier", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		Plugin.GhostMultiplier.Value = GUILayout.HorizontalSlider(Plugin.GhostMultiplier.Value, 0.001f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
		GUILayout.Label(Plugin.GhostMultiplier.Value.ToString("0.000"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		GUI.backgroundColor = Color.blue;
		if (GUILayout.Button("Reset", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			Plugin.GhostMultiplier.Value = 0.002f;
		}
		GUILayout.EndHorizontal();
		if (GUILayout.Button("Random", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			Random();
		}
		GUILayout.EndVertical();
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Space(5f);
		GUILayout.Label("Ghost Counter", val, Array.Empty<GUILayoutOption>());
		GUILayout.Space(10f);
		GUI.backgroundColor = Color.white;
		GUILayout.Label("Enable Ghost Counter", Array.Empty<GUILayoutOption>());
		Plugin.EnableGhostCounter.Value = GUILayout.Toggle(Plugin.EnableGhostCounter.Value, Plugin.EnableGhostCounter.Value ? "Enabled" : "Disabled", Array.Empty<GUILayoutOption>());
		GUILayout.Label("Set number 1-7 to get the amount of ghost cards", Array.Empty<GUILayoutOption>());
		ghostCountValue = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)ghostCountValue, 0f, 7f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }));
		Plugin.GhostCount.Value = ghostCountValue;
		GUILayout.Label(Plugin.GhostCount.Value.ToString("0"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
		GUI.backgroundColor = Color.blue;
		if (GUILayout.Button("Reset", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			ghostCountValue = 1;
			Plugin.GhostCount.Value = ghostCountValue;
		}
		GUILayout.EndVertical();
		GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
		GUILayout.Label("Misc", val, Array.Empty<GUILayoutOption>());
		GUILayout.Label("HighValue Card Icon", Array.Empty<GUILayoutOption>());
		Plugin.Highvaluecard.Value = GUILayout.Toggle(Plugin.Highvaluecard.Value, Plugin.Highvaluecard.Value ? "HighCardIcon Disabled" : "HighCardIcon Enabled", val3, Array.Empty<GUILayoutOption>());
		GUILayout.EndVertical();
		GUILayout.Space(10f);
		GUILayout.EndVertical();
		GUILayout.Space(10f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUI.backgroundColor = Color.blue;
		if (GUILayout.Button("Rest all to defualt", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }))
		{
			SoundManager.GenericLightTap(1f, 1f);
			Plugin.FoilMultiplier.Value = 5f;
			Plugin.FristEdtionMultiplier.Value = 20f;
			Plugin.SilverMultiplier.Value = 8f;
			Plugin.GoldMultiplier.Value = 4f;
			Plugin.ExMultiplier.Value = 1f;
			Plugin.FullArtMultiplier.Value = 0.25f;
			GhostMultiplier = 0.002f;
			Plugin.EnableGhostCounter.Value = false;
			Plugin.Highvaluecard.Value = false;
		}
		GUILayout.EndHorizontal();
		GUI.DragWindow();
	}

	public void Random()
	{
		new Random();
		Plugin.FoilMultiplier.Value = Random.Range(0f, 200f);
		Plugin.FristEdtionMultiplier.Value = Random.Range(0f, 200f);
		Plugin.SilverMultiplier.Value = Random.Range(0f, 200f);
		Plugin.GoldMultiplier.Value = Random.Range(0f, 200f);
		Plugin.ExMultiplier.Value = Random.Range(0f, 200f);
		Plugin.FullArtMultiplier.Value = Random.Range(0f, 200f);
	}
}
[BepInPlugin("Selegends-OpenCardPackCustomiser", "OpenCardPackCustomiser", "2.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	public static ConfigEntry<float> FullArtMultiplier;

	public static ConfigEntry<bool> EnableGhostCounter;

	public static ConfigEntry<bool> Highvaluecard;

	public static ConfigEntry<int> GhostCount;

	public static ConfigEntry<float> ExMultiplier;

	public static ConfigEntry<float> GoldMultiplier;

	public static ConfigEntry<float> FristEdtionMultiplier;

	public static ConfigEntry<float> FoilMultiplier;

	public static ConfigEntry<float> SilverMultiplier;

	public static ConfigEntry<float> GhostMultiplier;

	public static ConfigEntry<float> MarketMultiplier;

	public static ConfigEntry<float> HighCardVAlue;

	internal static ConfigEntry<float> m_ConfigSellOnlyGreaterThanMP;

	internal static ConfigEntry<int> CardsToHold;

	public static string KeyboardShortcutExampleKey = "Rest all Multiplier to default";

	public static string OpenMenuKeyText = "OpenMenu Ingame";

	public static ConfigEntry<KeyboardShortcut> KeyboardShortcutExample;

	public static ConfigEntry<KeyboardShortcut> OpenMenu;

	private static readonly Harmony Harmony = new Harmony("Sellegends_OpenCardPackCustomiser");

	private void Awake()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Expected O, but got Unknown
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Expected O, but got Unknown
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Expected O, but got Unknown
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Expected O, but got Unknown
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Expected O, but got Unknown
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Expected O, but got Unknown
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Expected O, but got Unknown
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Expected O, but got Unknown
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Expected O, but got Unknown
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Expected O, but got Unknown
		EnableGhostCounter = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Ghost Counter", false, "Enable Ghost Counter");
		Highvaluecard = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable HighValueCardIcon", false, "Enable HighValueCardIcon");
		FullArtMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cards", "Full Art  Multiplier", 0.25f, new ConfigDescription("Amount to Multiply the Full Art Card", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
		ExMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cards", "Ex Multiplier", 1f, new ConfigDescription("Amount to Multiply the Ex Card", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
		GoldMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cards", "Gold Multiplier", 4f, new ConfigDescription("Amount to Multiply the Gold Card", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
		FristEdtionMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cards", "FirstEdtion Multiplier", 20f, new ConfigDescription("Amount to Multiply the FristEdtion Card", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
		FoilMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cards", "Foil Multiplier", 5f, new ConfigDescription("Amount to Multiply the Foil Card", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
		SilverMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cards", "Silver Multiplier", 8f, new ConfigDescription("Amount to Multiply the Silver Card", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
		GhostMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cards", "Ghost Multiplier", 0.002f, new ConfigDescription("Amount to Multiply the Ghost Card", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.001f, 1f), Array.Empty<object>()));
		GhostCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Ghost Count", 0, new ConfigDescription("Amount of ghost cards", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 7), Array.Empty<object>()));
		HighCardVAlue = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HighCardValue", 0.002f, new ConfigDescription(" Set Ammount to remove HighCardValue popup", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20000f), Array.Empty<object>()));
		KeyboardShortcutExample = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", KeyboardShortcutExampleKey, new KeyboardShortcut((KeyCode)120, Array.Empty<KeyCode>()), "Keyboard shortcut for example action");
		OpenMenu = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", OpenMenuKeyText, new KeyboardShortcut((KeyCode)111, Array.Empty<KeyCode>()), "Keyboard shortcut to open menu");
		KeyboardShortcutExample.SettingChanged += ConfigSettingChanged;
		((Component)this).gameObject.AddComponent<Main>();
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		Log = ((BaseUnityPlugin)this).Logger;
		try
		{
			MethodInfo methodInfo = AccessTools.Method(typeof(CardOpeningSequence), "GetPackContent", (Type[])null, (Type[])null);
			MethodInfo method = typeof(CustomCardPatch).GetMethod("Prefix");
			if (methodInfo != null && method != null)
			{
				Harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else
			{
				Log.LogWarning((object)"Could not find GetPackContent or Prefix method!");
			}
		}
		catch (Exception arg)
		{
			Log.LogError((object)$"Harmony patching failed: {arg}");
		}
		((BaseUnityPlugin)this).Config.Save();
		try
		{
			MethodInfo method2 = typeof(CardOpeningSequence).GetMethod("OpenScreen");
			MethodInfo method3 = typeof(CustomCardPatch).GetMethod("Prefix_OpenScreen");
			if (method2 != null && method3 != null)
			{
				Harmony.Patch((MethodBase)method2, new HarmonyMethod(method3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else
			{
				Log.LogWarning((object)"Could not find GetPackContent or Prefix method!");
			}
		}
		catch (Exception arg2)
		{
			Log.LogError((object)$"Harmony patching failed: {arg2}");
		}
	}

	private void ConfigSettingChanged(object sender, EventArgs e)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		SettingChangedEventArgs val = (SettingChangedEventArgs)(object)((e is SettingChangedEventArgs) ? e : null);
		if (val.ChangedSetting.Definition.Key == KeyboardShortcutExampleKey)
		{
			_ = (KeyboardShortcut)val.ChangedSetting.BoxedValue;
		}
		if (val.ChangedSetting.Definition.Key == OpenMenuKeyText)
		{
			_ = (KeyboardShortcut)val.ChangedSetting.BoxedValue;
		}
	}

	private void Update()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut value = KeyboardShortcutExample.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			FullArtMultiplier.Value = 0.25f;
			ExMultiplier.Value = 1f;
			GoldMultiplier.Value = 4f;
			FristEdtionMultiplier.Value = 20f;
			FoilMultiplier.Value = 5f;
			SilverMultiplier.Value = 8f;
			GhostMultiplier.Value = 0.002f;
			Log.LogInfo((object)"Settings rest to default!");
		}
		_ = !CSingleton<CGameManager>.Instance.m_IsGameLevel;
	}

	public void Destroy()
	{
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}
}