Decompiled source of CorruptedCardsManager v1.3.0

plugins/CorruptedCardsManager.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using CardChoiceSpawnUniqueCardPatch.CustomCategories;
using CardThemeLib;
using CorruptedCardsManager.Extensions;
using CorruptedCardsManager.MonoBehaviours;
using CorruptedCardsManager.StatsGroup;
using CorruptedCardsManager.Utils;
using FancyCardBar;
using HarmonyLib;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using ModdingUtils.Patches;
using ModdingUtils.Utils;
using RandomCardsGenerators;
using RandomCardsGenerators.Cards;
using RandomCardsGenerators.StatsGroup;
using RandomCardsGenerators.Utils;
using RarityLib.Utils;
using TMPro;
using TabInfo.Utils;
using UnboundLib;
using UnboundLib.GameModes;
using UnboundLib.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CorruptedCardsManager
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.aalund13.rounds.corrupted_cards_manager", "Corrupted Cards Manager", "1.3.0")]
	[BepInProcess("Rounds.exe")]
	public class Main : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <WhenBattleStarts>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler handler;

			public Main <>4__this;

			private List<Player>.Enumerator <>s__1;

			private Player <player>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WhenBattleStarts>d__10(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<player>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				<>s__1 = PlayerManager.instance.players.GetEnumerator();
				try
				{
					while (<>s__1.MoveNext())
					{
						<player>5__2 = <>s__1.Current;
						<player>5__2.data.GetAdditionalData().CorruptedCardSpawnChance += <player>5__2.data.GetAdditionalData().CorruptedCardSpawnChancePerFight;
						<player>5__2 = null;
					}
				}
				finally
				{
					((IDisposable)<>s__1).Dispose();
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WhenGameStart>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler handler;

			public Main <>4__this;

			private List<Player>.Enumerator <>s__1;

			private Player <player>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WhenGameStart>d__11(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<player>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				<>s__1 = PlayerManager.instance.players.GetEnumerator();
				try
				{
					while (<>s__1.MoveNext())
					{
						<player>5__2 = <>s__1.Current;
						<player>5__2.data.GetAdditionalData().CorruptedCardSpawnChance = 0f;
						<player>5__2 = null;
					}
				}
				finally
				{
					((IDisposable)<>s__1).Dispose();
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const string modId = "com.aalund13.rounds.corrupted_cards_manager";

		private const string modName = "Corrupted Cards Manager";

		internal const string modInitials = "CCM";

		internal static Main Instance;

		internal static AssetBundle Assets;

		internal static ManualLogSource ModLogger;

		internal static GameObject CorruptedCardFancyIconPrefab;

		internal static GameObject CorruptedCardsArtVisualPrefab;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			ModLogger = ((BaseUnityPlugin)this).Logger;
			new Harmony("com.aalund13.rounds.corrupted_cards_manager").PatchAll();
			Assets = AssetUtils.LoadAssetBundleFromResources("corruptedmanager_assets", typeof(Main).Assembly);
			CorruptedCardsArtVisualPrefab = Assets.LoadAsset<GameObject>("C_CorruptedCards");
			CorruptedCardFancyIconPrefab = Assets.LoadAsset<GameObject>("I_Corrupted");
			Debug.Log("Corrupted Cards Manager loaded!");
		}

		private void Start()
		{
			List<BaseUnityPlugin> list = (List<BaseUnityPlugin>)typeof(Chainloader).GetField("_plugins", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
			if (list.Exists((BaseUnityPlugin plugin) => plugin.Info.Metadata.GUID == "com.willuwontu.rounds.tabinfo"))
			{
				TabinfoInterface.Setup();
			}
			GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)WhenBattleStarts);
			GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)WhenGameStart);
			CorruptedCardsManager.Init();
		}

		[IteratorStateMachine(typeof(<WhenBattleStarts>d__10))]
		private IEnumerator WhenBattleStarts(IGameModeHandler handler)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WhenBattleStarts>d__10(0)
			{
				<>4__this = this,
				handler = handler
			};
		}

		[IteratorStateMachine(typeof(<WhenGameStart>d__11))]
		private IEnumerator WhenGameStart(IGameModeHandler handler)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WhenGameStart>d__11(0)
			{
				<>4__this = this,
				handler = handler
			};
		}
	}
	public enum CorruptedCardRarity
	{
		Trinket,
		Common,
		Scarce,
		Uncommon,
		Exotic,
		Rare,
		Epic,
		Legendary,
		Mythical,
		Divine
	}
	public static class CorruptedCardsManager
	{
		public static readonly Dictionary<CardInfo, DrawableRandomCard> DrawableCorruptedCards = new Dictionary<CardInfo, DrawableRandomCard>();

		public static readonly CardCategory CantCorruptedCardCategory = CustomCardCategories.instance.CardCategory("CantCorruptedCardCategory");

		public static ModRandomCardsGenerators<CorruptedCardRarity> CorruptedCardsGenerators;

		private static readonly Dictionary<CorruptedCardRarity, RandomCardsGenerator> cardGenerators = new Dictionary<CorruptedCardRarity, RandomCardsGenerator>();

		public static CardThemeColorType CorruptedCardThemeColor { get; private set; }

		internal static void Init()
		{
			//IL_0020: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			CreateCardGenerators();
			CorruptedCardsGenerators = new ModRandomCardsGenerators<CorruptedCardRarity>(cardGenerators);
			CorruptedCardThemeColor = CardThemeLib.instance.CreateOrGetType("CorruptedDarkGray", new CardThemeColor
			{
				bgColor = new Color(0f, 0f, 0f, 1f),
				targetColor = new Color(0.5f, 0.5f, 0.5f, 1f)
			});
			LoggerUtils.LogInfo("Corrupted Cards Manager initialized!");
			LoggerUtils.LogInfo(GenerateCorruptedCardMarkdown());
		}

		private static void CreateCardGenerators()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Expected O, but got Unknown
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Expected O, but got Unknown
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Expected O, but got Unknown
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Expected O, but got Unknown
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Expected O, but got Unknown
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Expected O, but got Unknown
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Expected O, but got Unknown
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Expected O, but got Unknown
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Expected O, but got Unknown
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Expected O, but got Unknown
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Expected O, but got Unknown
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Expected O, but got Unknown
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Expected O, but got Unknown
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Expected O, but got Unknown
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Expected O, but got Unknown
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Expected O, but got Unknown
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Expected O, but got Unknown
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Expected O, but got Unknown
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Expected O, but got Unknown
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Expected O, but got Unknown
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Expected O, but got Unknown
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Expected O, but got Unknown
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Expected O, but got Unknown
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Expected O, but got Unknown
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Expected O, but got Unknown
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Expected O, but got Unknown
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Expected O, but got Unknown
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05df: Expected O, but got Unknown
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Expected O, but got Unknown
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_0610: Expected O, but got Unknown
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Expected O, but got Unknown
			//IL_0637: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Expected O, but got Unknown
			//IL_0657: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Expected O, but got Unknown
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Expected O, but got Unknown
			//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: Expected O, but got Unknown
			//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Expected O, but got Unknown
			//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Expected O, but got Unknown
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			//IL_0711: Expected O, but got Unknown
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Expected O, but got Unknown
			//IL_073d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0747: Expected O, but got Unknown
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Expected O, but got Unknown
			//IL_076e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0778: Expected O, but got Unknown
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			//IL_078e: Expected O, but got Unknown
			//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Expected O, but got Unknown
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ce: Expected O, but got Unknown
			//IL_0808: Unknown result type (might be due to invalid IL or missing references)
			//IL_0812: Expected O, but got Unknown
			//IL_0823: Unknown result type (might be due to invalid IL or missing references)
			//IL_082d: Expected O, but got Unknown
			//IL_083e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0848: Expected O, but got Unknown
			//IL_0859: Unknown result type (might be due to invalid IL or missing references)
			//IL_0863: Expected O, but got Unknown
			//IL_0874: Unknown result type (might be due to invalid IL or missing references)
			//IL_087e: Expected O, but got Unknown
			//IL_088f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0899: Expected O, but got Unknown
			//IL_08aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b4: Expected O, but got Unknown
			//IL_08c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ca: Expected O, but got Unknown
			//IL_08db: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e5: Expected O, but got Unknown
			//IL_08f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fb: Expected O, but got Unknown
			//IL_0911: Unknown result type (might be due to invalid IL or missing references)
			//IL_091b: Expected O, but got Unknown
			//IL_0931: Unknown result type (might be due to invalid IL or missing references)
			//IL_093b: Expected O, but got Unknown
			//IL_0975: Unknown result type (might be due to invalid IL or missing references)
			//IL_097f: Expected O, but got Unknown
			//IL_0990: Unknown result type (might be due to invalid IL or missing references)
			//IL_099a: Expected O, but got Unknown
			//IL_09ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b5: Expected O, but got Unknown
			//IL_09c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d0: Expected O, but got Unknown
			//IL_09e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09eb: Expected O, but got Unknown
			//IL_09fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a06: Expected O, but got Unknown
			//IL_0a17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a21: Expected O, but got Unknown
			//IL_0a2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a37: Expected O, but got Unknown
			//IL_0a48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a52: Expected O, but got Unknown
			//IL_0a5e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a68: Expected O, but got Unknown
			//IL_0a7e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a88: Expected O, but got Unknown
			//IL_0a9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa8: Expected O, but got Unknown
			//IL_0ae3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aed: Expected O, but got Unknown
			//IL_0afe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b08: Expected O, but got Unknown
			//IL_0b19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b23: Expected O, but got Unknown
			//IL_0b34: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3e: Expected O, but got Unknown
			//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b59: Expected O, but got Unknown
			//IL_0b6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b74: Expected O, but got Unknown
			//IL_0b85: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8f: Expected O, but got Unknown
			//IL_0b9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba5: Expected O, but got Unknown
			//IL_0bb6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc0: Expected O, but got Unknown
			//IL_0bcc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd6: Expected O, but got Unknown
			//IL_0bec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf6: Expected O, but got Unknown
			//IL_0c0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c16: Expected O, but got Unknown
			LoggerUtils.LogInfo("Creating corrupted card generators...");
			CreateRandomCardsGenerator(CorruptedCardRarity.Trinket, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.15f, 0.1f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.1f, 0.1f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.1f, 0.1f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.05f, 0.05f, 0.01f),
				(RandomStatGenerator)new HealthStatGenerator(-0.1f, 0.1f, 0.05f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.1f, 0.1f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-1f, 1f)
			}, 1, 2);
			CreateRandomCardsGenerator(CorruptedCardRarity.Common, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.3f, 0.3f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.3f, 0.15f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.3f, 0.15f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.1f, 0.1f, 0.05f),
				(RandomStatGenerator)new HealthStatGenerator(-0.3f, 0.3f, 0.05f),
				(RandomStatGenerator)new BlockCooldownStatGenerator(-0.05f, 0.05f, 0.025f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.3f, 0.3f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-2f, 2f),
				(RandomStatGenerator)(object)new CorruptedCardSpawnChanceStatGenerator(-0.05f, 0.05f)
			}, 1, 3);
			CreateRandomCardsGenerator(CorruptedCardRarity.Scarce, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.35f, 0.4f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.4f, 0.2f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.4f, 0.2f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.15f, 0.2f, 0.05f),
				(RandomStatGenerator)new HealthStatGenerator(-0.25f, 0.4f, 0.05f),
				(RandomStatGenerator)new BlockCooldownStatGenerator(-0.1f, 0.1f, 0.025f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.3f, 0.35f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-2f, 3f),
				(RandomStatGenerator)(object)new CorruptedCardSpawnChanceStatGenerator(-0.075f, 0.075f)
			}, 1, 3);
			CreateRandomCardsGenerator(CorruptedCardRarity.Uncommon, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.4f, 0.5f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.45f, 0.255f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.45f, 0.25f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.15f, 0.25f, 0.05f),
				(RandomStatGenerator)new HealthStatGenerator(-0.25f, 0.5f, 0.05f),
				(RandomStatGenerator)new BlockCooldownStatGenerator(-0.15f, 0.1f, 0.025f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.3f, 0.4f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-2f, 4f),
				(RandomStatGenerator)new RegenStatGenerator(0f, 5f, 1f),
				(RandomStatGenerator)new AdditionalBlocksStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.15f, 1f)),
				(RandomStatGenerator)(object)new CorruptedCardSpawnChanceStatGenerator(-0.1f, 0.1f)
			}, 1, 3);
			CreateRandomCardsGenerator(CorruptedCardRarity.Exotic, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.45f, 0.6f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.5f, 0.25f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.5f, 0.25f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.2f, 0.3f, 0.05f),
				(RandomStatGenerator)new HealthStatGenerator(-0.3f, 0.6f, 0.05f),
				(RandomStatGenerator)new BlockCooldownStatGenerator(-0.2f, 0.15f, 0.025f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.3f, 0.5f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-3f, 5f),
				(RandomStatGenerator)new RegenStatGenerator(0f, 8f, 1f),
				(RandomStatGenerator)new AdditionalBlocksStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.2f, 1f)),
				(RandomStatGenerator)(object)new CorruptedCardSpawnChanceStatGenerator(-0.15f, 0.15f)
			}, 1, 4);
			CreateRandomCardsGenerator(CorruptedCardRarity.Rare, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.5f, 0.8f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.6f, 0.3f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.6f, 0.3f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.2f, 0.35f, 0.05f),
				(RandomStatGenerator)new HealthStatGenerator(-0.35f, 0.75f, 0.05f),
				(RandomStatGenerator)new BlockCooldownStatGenerator(-0.25f, 0.15f, 0.025f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.3f, 0.6f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-3f, 6f),
				(RandomStatGenerator)new RegenStatGenerator(0f, 15f, 1f),
				(RandomStatGenerator)new JumpStatGenerator(0f, 1f),
				(RandomStatGenerator)new AdditionalBlocksStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.25f, 1f)),
				(RandomStatGenerator)(object)new CorruptedCardSpawnChanceStatGenerator(-0.2f, 0.2f)
			}, 1, 4);
			CreateRandomCardsGenerator(CorruptedCardRarity.Epic, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.55f, 0.9f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.7f, 0.35f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.7f, 0.35f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.25f, 0.4f, 0.05f),
				(RandomStatGenerator)new HealthStatGenerator(-0.45f, 0.9f, 0.05f),
				(RandomStatGenerator)new BlockCooldownStatGenerator(-0.3f, 0.2f, 0.025f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.3f, 0.65f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-4f, 7f),
				(RandomStatGenerator)new RegenStatGenerator(0f, 25f, 1f),
				(RandomStatGenerator)new JumpStatGenerator(0f, 1.5f),
				(RandomStatGenerator)new AdditionalBlocksStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.3f, 1f)),
				(RandomStatGenerator)new ExtraLiveStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.275f, 1f)),
				(RandomStatGenerator)(object)new CorruptedCardSpawnChanceStatGenerator(-0.25f, 0.25f)
			}, 1, 5);
			CreateRandomCardsGenerator(CorruptedCardRarity.Legendary, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.6f, 1f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.75f, 0.4f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.75f, 0.4f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.25f, 0.45f, 0.05f),
				(RandomStatGenerator)new HealthStatGenerator(-0.5f, 1f, 0.05f),
				(RandomStatGenerator)new BlockCooldownStatGenerator(-0.35f, 0.2f, 0.025f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.3f, 0.75f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-4f, 8f),
				(RandomStatGenerator)new RegenStatGenerator(0f, 35f, 1f),
				(RandomStatGenerator)new JumpStatGenerator(0f, 2f),
				(RandomStatGenerator)new AdditionalBlocksStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.4f, 1f)),
				(RandomStatGenerator)new ExtraLiveStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.35f, 1f)),
				(RandomStatGenerator)(object)new CorruptedCardSpawnChanceStatGenerator(-0.35f, 0.35f)
			}, 1, 5);
			CreateRandomCardsGenerator(CorruptedCardRarity.Mythical, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.65f, 1.25f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.8f, 0.45f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.8f, 0.45f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.3f, 0.5f, 0.05f),
				(RandomStatGenerator)new HealthStatGenerator(-0.55f, 1.25f, 0.05f),
				(RandomStatGenerator)new BlockCooldownStatGenerator(-0.4f, 0.25f, 0.025f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.3f, 0.8f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-5f, 10f),
				(RandomStatGenerator)new RegenStatGenerator(0f, 45f, 1f),
				(RandomStatGenerator)new JumpStatGenerator(0f, 2.5f),
				(RandomStatGenerator)new AdditionalBlocksStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.5f, 1f)),
				(RandomStatGenerator)new ExtraLiveStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.45f, 1f)),
				(RandomStatGenerator)(object)new CorruptedCardSpawnChanceStatGenerator(-0.4f, 0.4f)
			}, 1, 6);
			CreateRandomCardsGenerator(CorruptedCardRarity.Divine, new List<RandomStatGenerator>
			{
				(RandomStatGenerator)new DamageStatGenerator(-0.7f, 1.5f, 0.05f),
				(RandomStatGenerator)new ReloadTimeStatGenerator(-0.85f, 0.5f, 0.05f),
				(RandomStatGenerator)new AttackSpeedStatGenerator(-0.85f, 0.5f, 0.05f),
				(RandomStatGenerator)new MovementSpeedStatGenerator(-0.35f, 0.55f, 0.05f),
				(RandomStatGenerator)new HealthStatGenerator(-0.65f, 1.5f, 0.05f),
				(RandomStatGenerator)new BlockCooldownStatGenerator(-0.45f, 0.25f, 0.025f),
				(RandomStatGenerator)new BulletSpeedStatGenerator(-0.3f, 0.85f, 0.05f),
				(RandomStatGenerator)new AmmoStatGenerator(-6f, 15f),
				(RandomStatGenerator)new RegenStatGenerator(0f, 60f, 1f),
				(RandomStatGenerator)new JumpStatGenerator(0f, 3f),
				(RandomStatGenerator)new AdditionalBlocksStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.2f, 2f)),
				(RandomStatGenerator)new ExtraLiveStatGenerator(0f, RandomStatsUtils.ScaleStatByIntensity(0.5f, 2f)),
				(RandomStatGenerator)(object)new CorruptedCardSpawnChanceStatGenerator(-0.5f, 0.5f)
			}, 1, 6);
			LoggerUtils.LogInfo("Created all corrupted card generators!");
		}

		private static void CreateRandomCardsGenerator(CorruptedCardRarity rarity, List<RandomStatGenerator> statGenerators, int min, int max)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			cardGenerators[rarity] = new RandomCardsGenerator($"CorruptedCardsGenerator_{rarity}", CreateCardOption(RarityUtils.GetRarity(rarity.ToString()), min, max), statGenerators);
			RandomCardsGenerator obj = cardGenerators[rarity];
			obj.OnCardGenerated = (Action<GeneratedCardInfo>)Delegate.Combine(obj.OnCardGenerated, (Action<GeneratedCardInfo>)delegate(GeneratedCardInfo generatedCardInfo)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				((Component)generatedCardInfo.CardInfo).gameObject.AddComponent<FancyIcon>().fancyIcon = Main.CorruptedCardFancyIconPrefab;
				((Component)generatedCardInfo.CardInfo).gameObject.AddComponent<GlitchingCardEffect>();
				((Component)generatedCardInfo.CardInfo).gameObject.AddComponent<CorruptedCardInfo>().Init(generatedCardInfo);
				generatedCardInfo.CardInfo.cardArt = Main.CorruptedCardsArtVisualPrefab;
				generatedCardInfo.CardInfo.colorTheme = CorruptedCardThemeColor;
			});
			DrawableRandomCard val = new DrawableRandomCard(cardGenerators[rarity]);
			DrawableCorruptedCards[val.CardInfo] = val;
			LoggerUtils.LogInfo($"Created {rarity} corrupted card generator!");
		}

		public static bool TryGetCorruptedCardRarity(Rarity rarity, out CorruptedCardRarity corruptedCardRarity)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<CorruptedCardRarity, RandomCardsGenerator> cardGenerator in cardGenerators)
			{
				if (cardGenerator.Value.RandomCardOption.CardRarity == rarity)
				{
					corruptedCardRarity = cardGenerator.Key;
					return true;
				}
			}
			corruptedCardRarity = CorruptedCardRarity.Trinket;
			return false;
		}

		public static Rarity GetCorruptedCardRarity(CorruptedCardRarity rarity)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return cardGenerators[rarity].RandomCardOption.CardRarity;
		}

		public static CorruptedCardRarity GetClosestCorruptedCardRarity(Rarity rarity)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			CorruptedCardRarity result = CorruptedCardRarity.Trinket;
			float num = 2.1474836E+09f;
			foreach (KeyValuePair<CorruptedCardRarity, RandomCardsGenerator> cardGenerator in cardGenerators)
			{
				float calculatedRarity = RarityUtils.GetRarityData(cardGenerator.Value.RandomCardOption.CardRarity).calculatedRarity;
				float calculatedRarity2 = RarityUtils.GetRarityData(rarity).calculatedRarity;
				float num2 = Mathf.Abs(calculatedRarity - calculatedRarity2);
				if (num2 < num)
				{
					num = num2;
					result = cardGenerator.Key;
				}
			}
			return result;
		}

		private static RandomCardOption CreateCardOption(Rarity rarity, int min, int max)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			return new RandomCardOption("Corrupted Card", "CCM", "A corrupted card", "CO", min, max, rarity, (CardThemeColorType)4);
		}

		private static string GenerateCorruptedCardMarkdown()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("## Corrupted Cards Rarities");
			foreach (KeyValuePair<CorruptedCardRarity, RandomCardsGenerator> cardGenerator in cardGenerators)
			{
				stringBuilder.AppendLine($"### {cardGenerator.Key}");
				stringBuilder.AppendLine("- **Stats**:");
				foreach (RandomStatGenerator statGenerator in cardGenerator.Value.StatGenerators)
				{
					stringBuilder.AppendLine("  - **" + statGenerator.StatName + "**: `" + statGenerator.GetStatString(statGenerator.MinValue) + "` - `" + statGenerator.GetStatString(statGenerator.MaxValue) + "`");
				}
				stringBuilder.AppendLine("- **Card Option**:");
				stringBuilder.AppendLine($"  - **Min Stats**: {cardGenerator.Value.RandomCardOption.Min}");
				stringBuilder.AppendLine($"  - **Max Stats**: {cardGenerator.Value.RandomCardOption.Max}");
			}
			return stringBuilder.ToString();
		}
	}
	public class CorruptedStatModifers : MonoBehaviour
	{
		public float CorruptedCardSpawnChance = 0f;

		public float CorruptedCardSpawnChancePerPick = 0f;

		public float CorruptedCardSpawnChancePerFight = 0f;

		public void Apply(Player player)
		{
			CharacterData data = player.data;
			CorruptedCharacterData additionalData = data.GetAdditionalData();
			additionalData.CorruptedCardSpawnChance = Mathf.Max(additionalData.CorruptedCardSpawnChance + CorruptedCardSpawnChance, 0f);
			additionalData.CorruptedCardSpawnChancePerPick += CorruptedCardSpawnChancePerPick;
			additionalData.CorruptedCardSpawnChancePerFight += CorruptedCardSpawnChancePerFight;
		}
	}
	public class TabinfoInterface
	{
		public static void Setup()
		{
			StatCategory val = TabInfoManager.RegisterCategory("CCM Stats", 3);
			TabInfoManager.RegisterStat(val, "Corrupted Cards Spawn Chance", (Func<Player, bool>)((Player p) => p.data.GetAdditionalData().CorruptedCardSpawnChance != 0f), (Func<Player, string>)((Player p) => $"{p.data.GetAdditionalData().CorruptedCardSpawnChance * 100f:0}%"));
			TabInfoManager.RegisterStat(val, "Corrupted Cards Spawn Chance Per Pick", (Func<Player, bool>)((Player p) => p.data.GetAdditionalData().CorruptedCardSpawnChancePerPick != 0f), (Func<Player, string>)((Player p) => $"{p.data.GetAdditionalData().CorruptedCardSpawnChancePerPick * 100f:0}%"));
			TabInfoManager.RegisterStat(val, "Corrupted Cards Spawn Chance Per Fight", (Func<Player, bool>)((Player p) => p.data.GetAdditionalData().CorruptedCardSpawnChancePerFight != 0f), (Func<Player, string>)((Player p) => $"{p.data.GetAdditionalData().CorruptedCardSpawnChancePerFight * 100f:0}%"));
		}
	}
}
namespace CorruptedCardsManager.Utils
{
	internal static class LoggerUtils
	{
		private const bool logging = true;

		public static void LogInfo(string message)
		{
			bool flag = true;
			Main.ModLogger.LogInfo((object)message);
		}

		public static void LogWarn(string message)
		{
			Main.ModLogger.LogWarning((object)message);
		}

		public static void LogError(string message)
		{
			Main.ModLogger.LogError((object)message);
		}
	}
}
namespace CorruptedCardsManager.Patches
{
	[HarmonyPatch(typeof(ApplyCardStats), "ApplyStats")]
	public class ApplyCardStatsPatch
	{
		public static void Postfix(ApplyCardStats __instance, Player ___playerToUpgrade)
		{
			CorruptedStatModifers component = ((Component)__instance).GetComponent<CorruptedStatModifers>();
			if ((Object)(object)component != (Object)null)
			{
				component.Apply(___playerToUpgrade);
			}
		}
	}
	[HarmonyPatch(typeof(CardChoice), "StartPick")]
	public class CardChoicePatch
	{
		private static void Prefix(int pickerIDToSet)
		{
			Player val = PlayerManager.instance.players[pickerIDToSet];
			val.data.GetAdditionalData().CorruptedCardSpawnChance += val.data.GetAdditionalData().CorruptedCardSpawnChancePerPick;
		}
	}
	[HarmonyPatch(typeof(CardChoicePatchGetRanomCard), "EfficientGetRanomCard", new Type[]
	{
		typeof(Player),
		typeof(CardInfo[])
	})]
	public class CardChoicePatchGetRanomCardPatch
	{
		private static void Prefix(Player player, ref CardInfo[] cards)
		{
			if (!((Object)(object)player == (Object)null) && cards != null && cards.Length != 0 && Random.Range(0f, 1f) < player.data.GetAdditionalData().CorruptedCardSpawnChance)
			{
				cards = CorruptedCardsManager.DrawableCorruptedCards.Keys.ToArray();
			}
		}
	}
	[HarmonyPatch(typeof(CharacterStatModifiers), "ResetStats")]
	public class CharacterStatModifiersPatch
	{
		public static void Prefix(CharacterStatModifiers __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			CharacterData block = (CharacterData)Traverse.Create((object)__instance).Field("data").GetValue();
			block.GetAdditionalData().Reset();
		}
	}
	[HarmonyPatch(typeof(CardChoice), "SpawnUniqueCard")]
	[HarmonyAfter(new string[] { "com.Root.Null" })]
	internal class SpawnUniqueCardPatch
	{
		[HarmonyPriority(0)]
		private static void Postfix(int ___pickrID, ref GameObject __result)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			Player val = PlayerManager.instance.players.Find((Player p) => p.playerID == ___pickrID);
			CardInfo component = __result.GetComponent<CardInfo>();
			if (!((Object)(object)val == (Object)null) && !((Component)component).GetComponents<MonoBehaviour>().Any((MonoBehaviour x) => ((object)x).GetType().Name == "NullCard") && Random.Range(0f, 1f) < val.data.GetAdditionalData().CorruptedCardSpawnChance && !component.categories.Contains(CorruptedCardsManager.CantCorruptedCardCategory))
			{
				CorruptedCardRarity corruptedCardRarity = CorruptedCardRarity.Trinket;
				if (!CorruptedCardsManager.TryGetCorruptedCardRarity(component.rarity, out corruptedCardRarity))
				{
					corruptedCardRarity = CorruptedCardsManager.GetClosestCorruptedCardRarity(component.rarity);
				}
				CardInfo key = CorruptedCardsManager.DrawableCorruptedCards.FirstOrDefault((KeyValuePair<CardInfo, DrawableRandomCard> x) => x.Value.CardInfo.rarity == CorruptedCardsManager.GetCorruptedCardRarity(corruptedCardRarity)).Key;
				GameObject val2 = CardChoicePatchGetRanomCard.OrignialGetRanomCard((CardInfo[])(object)new CardInfo[1] { key });
				__result = CorruptedCardsManager.DrawableCorruptedCards[val2.GetComponent<CardInfo>()].ReplaceCard(component, val);
			}
		}
	}
}
namespace CorruptedCardsManager.MonoBehaviours
{
	public class CorruptedCardInfo : MonoBehaviour
	{
		public GeneratedCardInfo randomCardInfo;

		public CardInfo cardInfo;

		internal void Init(GeneratedCardInfo GeneratedCardInfo)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			randomCardInfo = GeneratedCardInfo;
			if (!((Object)(object)GeneratedCardInfo.Player != (Object)null))
			{
				return;
			}
			List<CardInfo> source = (typeof(CardManager).GetField("activeCards", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as ObservableCollection<CardInfo>).ToList();
			List<CardInfo> list = source.Where((CardInfo cardInfo) => cardInfo.rarity == GeneratedCardInfo.CardInfo.rarity && Cards.instance.PlayerIsAllowedCard(GeneratedCardInfo.Player, cardInfo)).ToList();
			if (list.Count > 0)
			{
				CardInfo val = list[GeneratedCardInfo.Random.Next(0, list.Count - 1)];
				GeneratedCardInfo.CardInfo.cardArt = val.cardArt;
				cardInfo = val;
			}
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)this, 1, (Action)delegate
			{
				TextMeshProUGUI[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<TextMeshProUGUI>();
				if (componentsInChildren.Length != 0)
				{
					((TMP_Text)((Component)componentsInChildren.Where((TextMeshProUGUI obj) => ((Object)((Component)obj).gameObject).name == "Text_Name").FirstOrDefault()).GetComponent<TextMeshProUGUI>()).text = cardInfo.cardName;
				}
			});
		}
	}
	public class CorruptedCardsArtVisual : MonoBehaviour
	{
		[SerializeField]
		public RectTransform ArtTransform;

		[SerializeField]
		private float setRandomFrameChance = 0.05f;

		private Animator[] animators;

		private void Awake()
		{
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)this, 5, (Action)delegate
			{
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				CorruptedCardInfo componentInParent = ((Component)this).GetComponentInParent<CorruptedCardInfo>();
				CardInfo val;
				if ((Object)(object)componentInParent.cardInfo == (Object)null)
				{
					CardInfo[] array = (from c in CardManager.cards
						where (Object)(object)c.Value.cardInfo.cardArt != (Object)null
						select c.Value.cardInfo).ToArray();
					if (array.Length == 0)
					{
						return;
					}
					val = array[Random.Range(0, array.Length)];
				}
				else
				{
					val = componentInParent.cardInfo;
				}
				if ((Object)(object)val != (Object)null)
				{
					GameObject val2 = Object.Instantiate<GameObject>(val.cardArt, (Transform)(object)ArtTransform);
					val2.transform.localScale = Vector3.one;
					val2.transform.localPosition = Vector3.zero;
					animators = val2.GetComponentsInChildren<Animator>(true);
				}
			});
		}

		private void FixedUpdate()
		{
			if (animators != null && Random.value < setRandomFrameChance)
			{
				SetRandomFrameForAnimators();
			}
		}

		private void SetRandomFrameForAnimators()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			Animator[] array = animators;
			foreach (Animator val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				AnimatorClipInfo[] currentAnimatorClipInfo = val.GetCurrentAnimatorClipInfo(0);
				if (currentAnimatorClipInfo.Length != 0)
				{
					AnimationClip clip = ((AnimatorClipInfo)(ref currentAnimatorClipInfo[0])).clip;
					if (!((Object)(object)clip == (Object)null))
					{
						AnimatorStateInfo currentAnimatorStateInfo = val.GetCurrentAnimatorStateInfo(0);
						float normalizedTime = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime;
						float length = clip.length;
						float num = normalizedTime % 1f * length;
						float num2 = num - Random.Range(Mathf.Min(-0.5f, length * -0.1f), Mathf.Max(0.5f, length * 0.1f));
						float num3 = num2 % length / length;
						val.Play(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash, 0, num3);
						val.Update(0f);
					}
				}
			}
		}
	}
	public class GlitchingCardEffect : MonoBehaviour
	{
		private void Start()
		{
			if (((Component)this).gameObject.transform.childCount == 0)
			{
				return;
			}
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)this, 1, (Action)delegate
			{
				GlitchingTextMono orAddComponent = ExtensionMethods.GetOrAddComponent<GlitchingTextMono>(((Component)this).gameObject, false);
				orAddComponent.EffectAllText = false;
				TextMeshProUGUI[] componentsInChildren = ((Component)((Component)this).gameObject.transform.GetChild(0).Find("Canvas/Front/Grid")).GetComponentsInChildren<TextMeshProUGUI>();
				TextMeshProUGUI[] array = componentsInChildren;
				foreach (TextMeshProUGUI textMesh in array)
				{
					orAddComponent.AddTextMesh(textMesh);
				}
				TextMeshProUGUI component = ((Component)((Component)this).gameObject.transform.GetChild(0).Find("Canvas/Front/Text_Name")).GetComponent<TextMeshProUGUI>();
				orAddComponent.AddTextMesh(component);
			});
		}
	}
	public class GlitchingTextMono : MonoBehaviour
	{
		private const string CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=<>?:\"{}|,./;'[]\\'~";

		private const string GLITCH_TAG_REGEX = "<glitch>(.*?)(<\\/glitch>|$)";

		public static Regex regex = new Regex("<glitch>(.*?)(<\\/glitch>|$)", RegexOptions.Compiled);

		public bool UseGlitchTag = false;

		public bool EffectAllText = true;

		private List<(TextMeshProUGUI, string)> textMeshes = new List<(TextMeshProUGUI, string)>();

		private List<char> characters = new List<char>();

		private void Start()
		{
			characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=<>?:\"{}|,./;'[]\\'~".ToList();
			if (EffectAllText)
			{
				TextMeshProUGUI[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<TextMeshProUGUI>();
				textMeshes.AddRange(componentsInChildren.Select((TextMeshProUGUI obj) => (obj, ((TMP_Text)obj).text)));
			}
		}

		public void AddTextMesh(TextMeshProUGUI textMesh)
		{
			textMeshes.Add((textMesh, ((TMP_Text)textMesh).text));
		}

		private void Update()
		{
			if (textMeshes.Count == 0)
			{
				return;
			}
			foreach (var (val, originalText) in textMeshes)
			{
				if (UseGlitchTag)
				{
					string text = ProcessTextWithGlitchTag(originalText);
					((TMP_Text)val).text = text;
				}
				else
				{
					GlitchCharacters(val, originalText);
				}
			}
		}

		private void GlitchCharacters(TextMeshProUGUI textMesh, string originalText)
		{
			((TMP_Text)textMesh).text = "<mspace=0.5em>";
			for (int i = 0; i < originalText.Length; i++)
			{
				((TMP_Text)textMesh).text = ((TMP_Text)textMesh).text + characters[Random.Range(0, characters.Count)];
			}
		}

		private string ProcessTextWithGlitchTag(string originalText)
		{
			return regex.Replace(originalText, delegate(Match match)
			{
				string value = match.Groups[1].Value;
				string text = GenerateGlitchedText(value.Length);
				return "<mspace=0.5em>" + text + "</mspace>";
			});
		}

		private string GenerateGlitchedText(int length)
		{
			char[] array = new char[length];
			for (int i = 0; i < length; i++)
			{
				array[i] = characters[Random.Range(0, characters.Count)];
			}
			return new string(array);
		}
	}
}
namespace CorruptedCardsManager.MonoBehaviours.CardbarsScripts
{
	public class EnableTextFromCardbar : MonoBehaviour
	{
		[HideInInspector]
		public TextMeshProUGUI text;

		private void OnEnable()
		{
			text = ((Component)((Component)this).transform.parent).GetComponentInChildren<TextMeshProUGUI>();
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)this, 1, (Action)delegate
			{
				((Behaviour)text).enabled = true;
			});
		}
	}
	[RequireComponent(typeof(EnableTextFromCardbar))]
	public class GlitchedTextCardbar : MonoBehaviour
	{
		public void Start()
		{
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)this, 1, (Action)delegate
			{
				EnableTextFromCardbar component = ((Component)this).GetComponent<EnableTextFromCardbar>();
				((Component)component.text).gameObject.AddComponent<GlitchingTextMono>();
			});
		}
	}
}
namespace CorruptedCardsManager.Extensions
{
	public class CorruptedCharacterData
	{
		public float CorruptedCardSpawnChance = 0f;

		public float CorruptedCardSpawnChancePerPick = 0f;

		public float CorruptedCardSpawnChancePerFight = 0f;

		public void Reset()
		{
			CorruptedCardSpawnChancePerPick = 0f;
			CorruptedCardSpawnChancePerFight = 0f;
		}
	}
	public static class CorruptedCharacterDataExtensions
	{
		public static readonly ConditionalWeakTable<CharacterData, CorruptedCharacterData> data = new ConditionalWeakTable<CharacterData, CorruptedCharacterData>();

		public static CorruptedCharacterData GetAdditionalData(this CharacterData block)
		{
			return data.GetOrCreateValue(block);
		}

		public static void AddData(this CharacterData block, CorruptedCharacterData value)
		{
			try
			{
				data.Add(block, value);
			}
			catch (Exception)
			{
			}
		}
	}
}
namespace CorruptedCardsManager.StatsGroup
{
	public class CorruptedCardSpawnChanceStatGenerator : RandomStatGenerator
	{
		public float ThresholdToZero;

		public override string StatName => "Corrupted Cards Spawn Chance";

		public CorruptedCardSpawnChanceStatGenerator(float minValue, float maxValue, float thresholdToZero = 0.05f)
			: base(minValue, maxValue)
		{
			ThresholdToZero = thresholdToZero;
		}

		public override bool ShouldApply(float value)
		{
			return Mathf.Abs(value) >= ThresholdToZero;
		}

		public override void Apply(float value, CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
		{
			CorruptedStatModifers orAddComponent = ExtensionMethods.GetOrAddComponent<CorruptedStatModifers>(((Component)cardInfo).gameObject, false);
			orAddComponent.CorruptedCardSpawnChance += value;
		}

		public override bool IsPositive(float value)
		{
			return value < 0f;
		}
	}
}