Decompiled source of Squirrel Bomb Mod v1.1.1

SquirrelBombMod.dll

Decompiled 19 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Ascension;
using InscryptionAPI.Card;
using InscryptionAPI.Dialogue;
using InscryptionAPI.Encounters;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
using InscryptionAPI.Triggers;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod.Cil;
using Pixelplacement;
using SquirrelBombMod.Abilities;
using SquirrelBombMod.Challenges;
using SquirrelBombMod.Spamton;
using SquirrelBombMod.Triggers;
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(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SquirrelBombMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+55296c95f7b5aaef82de6848ac8acab5c4574899")]
[assembly: AssemblyProduct("SquirrelBombMod")]
[assembly: AssemblyTitle("SquirrelBombMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 SquirrelBombMod
{
	[BepInPlugin("spapi.inscryption.squirrelbombmod", "The Squirrel Bomb Mod", "1.1.1")]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		public static AscensionChallenge DentistryChallenge;

		public static AscensionChallenge ArchivedChallenge;

		public static AscensionChallenge FinalBossV2Challenge;

		public static void AddAbilities()
		{
			AbilityExtensions.SetCanStack(Tools.NewAbility("Pipis", "Pipis.", typeof(Pipis), "ability_pipis.png").SetPart1Rulebook(), true, false);
			Tools.NewAbility("Help", "At the end of the owner's turn [creature] will sacrifice itself to heal the adjacent cards by 1.", typeof(DieHeal), "ability_dieheal").SetPart1Rulebook();
			Tools.NewAbility("Pass-through", "When [creature] is about to get attacked by a card with an attack higher than this card's health, this card perishes.", typeof(PassThrough), "ability_passthrough").SetPart1Rulebook();
			AbilityExtensions.SetConduit(Tools.NewAbility("Spam Call", "Empty spaces within a circuit completed by [creature] spawn Spam Mail at the end of the owner's turn.", typeof(CreateSpamMailConduit), "ability_conduitmail"), true).SetPart1Rulebook();
			AbilityExtensions.SetFlipYIfOpponent(AbilityExtensions.SetPassive(Tools.NewAbility("NEO Strike", "[creature] will strike each opposing space that is occupied by a creature and additionally every side of the board occupied by a creature. It will strike directly if no creatures oppose it.", "NeoStrike", "ability_neostrike.png"), true), true).SetPart1Rulebook();
			AbilityExtensions.SetPassive(Tools.NewAbility("A Call for Help", "At the end of the owner's turn, [creature] will call for help.", "HelpCall", "ability_helpcall"), true).SetPart1Rulebook();
			Tools.NewAbility("Run Forth", "Before [creature] attacks, its power will be set to at least 1.", typeof(RunForth), "ability_runforth").SetPart1Rulebook();
		}

		public static void AddCards()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected I4, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected I4, but got Unknown
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected I4, but got Unknown
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected I4, but got Unknown
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Expected I4, but got Unknown
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Expected I4, but got Unknown
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Expected I4, but got Unknown
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Expected I4, but got Unknown
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Expected I4, but got Unknown
			CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "Pipis", "Pipis", 0, 1, "Pipis."), Tools.LoadTexture("portrait_pipis.png"), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)(int)Tools.FindRegisteredAbility<Pipis>() });
			CardExtensions.SetTribes(CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "FlyingHead", "Flying Head", 1, 1, "The most important part."), Tools.LoadTexture("portrait_flyinghead.png"), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)(int)Tools.FindRegisteredAbility<PassThrough>() }), (Tribe[])(object)new Tribe[1] { (Tribe)1 });
			CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "SpamCart", "Spam Cart", 0, 3, "Filled with spam mail. Absorbs all kinds of attacks."), Tools.LoadTexture("portrait_spamcart.png"), (FilterMode?)null), (Ability[])(object)new Ability[2]
			{
				(Ability)102,
				(Ability)21
			});
			CardInfo obj = CardExtensions.SetPortrait(CardManager.New("morebosses", "SpamMail", "Spam Mail", 0, 2, "Has all kinds of unforgettable deals."), Tools.LoadTexture("portrait_spammail.png"), (FilterMode?)null);
			Ability[] array = new Ability[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			CardExtensions.SetTribes(CardExtensions.AddAbilities(obj, (Ability[])(object)array), (Tribe[])(object)new Tribe[1] { (Tribe)1 });
			CardExtensions.AddAppearances(CardExtensions.AddTraits(CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "BigShooter", "Big Shooter", 2, 1, "Shoots big shots."), Tools.LoadTexture("portrait_bigshooter.png"), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)35 }), (Trait[])(object)new Trait[1] { (Trait)12 }), (Appearance[])(object)new Appearance[1] { (Appearance)2 });
			CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "ChainHeart", "Heart on a Chain", 1, 9, "Beautiful."), Tools.LoadTexture("portrait_chainheart.png"), (FilterMode?)null), (Ability[])(object)new Ability[2]
			{
				(Ability)3,
				(Ability)24
			});
			CardExtensions.SetTribes(CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "Spamgel", "Spamgel", 1, 2, "The result of pressing F1."), Tools.LoadTexture("portrait_spamgel.png"), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)(int)Tools.FindRegisteredAbility<DieHeal>() }), (Tribe[])(object)new Tribe[1] { (Tribe)1 });
			CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "HandPhoneLeft", "Hand Phone", 0, 5, "Do you really need anyone else?"), Tools.LoadTexture("portrait_leftphonehand.png"), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)(int)Tools.FindRegisteredAbility<CreateSpamMailConduit>() });
			CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "HandPhoneRight", "Hand Phone", 0, 5, "Do you really need anyone else?"), Tools.LoadTexture("portrait_rightphonehand.png"), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)47 });
			GameObject val = Tools.assets.LoadAsset<GameObject>("SneoGiantPortrait");
			val.AddComponent<NeoAnimatedPortrait>();
			Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>();
			foreach (Transform val2 in componentsInChildren)
			{
				((Component)val2).gameObject.layer = LayerMask.NameToLayer("CardOffscreen");
			}
			CardExtensions.AddAbilities(CardExtensions.AddSpecialAbilities(CardExtensions.AddTraits(CardExtensions.AddAppearances(CardManager.New("morebosses", "!GIANTCARD_NEO", "THE POWER OF NEO!!!", 1, 40, "Don't you wanna be a big shot?"), (Appearance[])(object)new Appearance[1] { (Appearance)11 }), (Trait[])(object)new Trait[2]
			{
				(Trait)16,
				(Trait)14
			}), (SpecialTriggeredAbility[])(object)new SpecialTriggeredAbility[1] { (SpecialTriggeredAbility)15 }), (Ability[])(object)new Ability[3]
			{
				(Ability)(int)Tools.FindRegisteredAbility("NeoStrike"),
				(Ability)23,
				(Ability)105
			}).animatedPortrait = val;
			CardExtensions.AddAppearances(CardExtensions.AddAbilities(CardExtensions.AddTraits(CardExtensions.SetPortrait(CardManager.New("morebosses", "Receiver", "Receiver", -999, 99999, "The voice runs out eventually."), Tools.LoadTexture("portrait_receiver.png"), (FilterMode?)null), (Trait[])(object)new Trait[1] { (Trait)12 }), (Ability[])(object)new Ability[1] { (Ability)(int)Tools.FindRegisteredAbility("HelpCall") }), (Appearance[])(object)new Appearance[1] { (Appearance)2 }).hideAttackAndHealth = true;
			CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "BearPipis", "Grizzlipis", 0, 1, "Grizzlipis."), Tools.LoadTexture("portrait_bearpipis.png"), (FilterMode?)null), (Ability[])(object)new Ability[2]
			{
				(Ability)(int)Tools.FindRegisteredAbility<Pipis>(),
				(Ability)(int)Tools.FindRegisteredAbility<Pipis>()
			});
			CardInfo obj2 = CardExtensions.SetPortrait(CardManager.New("morebosses", "BearCart", "Bear Cart", 2, 4, "Filled with bears. Absorbs all kinds of attacks."), Tools.LoadTexture("portrait_bearcart.png"), (FilterMode?)null);
			Ability[] array2 = new Ability[3];
			RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			CardExtensions.AddAbilities(obj2, (Ability[])(object)array2);
			CardInfo obj3 = CardExtensions.SetPortrait(CardManager.New("morebosses", "BearMail", "Bear Mail", 0, 3, "Mail for bears."), Tools.LoadTexture("portrait_bearmail.png"), (FilterMode?)null);
			Ability[] array3 = new Ability[4];
			RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			CardExtensions.SetTribes(CardExtensions.AddAbilities(obj3, (Ability[])(object)array3), (Tribe[])(object)new Tribe[1] { (Tribe)1 });
			CardInfo obj4 = CardExtensions.SetPortrait(CardManager.New("morebosses", "BearHeart", "Bear on a Chain", 1, 10, "Bearutiful."), Tools.LoadTexture("portrait_bearheart.png"), (FilterMode?)null);
			Ability[] array4 = new Ability[3];
			RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			CardExtensions.AddAbilities(obj4, (Ability[])(object)array4);
			CardInfo obj5 = CardExtensions.SetPortrait(CardManager.New("morebosses", "HandBearLeft", "Bear Hand", 0, 5, "Do you really need anyone else?"), Tools.LoadTexture("portrait_leftbearhand.png"), (FilterMode?)null);
			Ability[] array5 = new Ability[3];
			RuntimeHelpers.InitializeArray(array5, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			CardExtensions.AddAbilities(obj5, (Ability[])(object)array5);
			CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("morebosses", "HandBearRight", "Bear Hand", 0, 5, "Do you really need anyone else?"), Tools.LoadTexture("portrait_rightbearhand.png"), (FilterMode?)null), (Ability[])(object)new Ability[3]
			{
				(Ability)(int)Tools.FindRegisteredAbility<CreateSpamMailConduit>(),
				(Ability)23,
				(Ability)105
			});
		}

		public void AddChallenges()
		{
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Squirrel Bomb", "Squirrels explode when killed, dealing 10 damage to adjacent cards.", 30, Tools.LoadTexture("ascensionicon_squirrelbomb"), Tools.LoadTexture("ascensionicon_activated_squirrelbomb"), typeof(SquirrelBomb), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Dance Party", "Your cards move each turn. The cards that can't move die.", 30, Tools.LoadTexture("ascensionicon_dance"), Tools.LoadTexture("ascensionicon_activated_dance"), typeof(DanceParty), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "???", "CHALLENGE LOCKED", 20, Tools.LoadTexture("ascensionicon_sus"), Tools.LoadTexture("ascensionicon_activated_sus"), typeof(Sus), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Again", "All opponent cards attack twice.", 60, Tools.LoadTexture("ascensionicon_again"), Tools.LoadTexture("ascensionicon_activated_again"), typeof(Again), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Starving", "Pray.", 2, Tools.LoadTexture("ascensionicon_starve"), ChallengeManager.DEFAULT_ACTIVATED_SPRITE, typeof(Starving), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Dogfish", "Each battle starts with a Bait Bucket that has Guardian.", 30, Tools.LoadTexture("ascensionicon_dogfish"), ChallengeManager.DEFAULT_ACTIVATED_SPRITE, typeof(Dogfish), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Annoying Totems", "Start each battle with an Annoying totem for your most used tribe.", 25, Tools.LoadTexture("ascensionicon_annoyingtotems"), Tools.LoadTexture("ascensionicon_activated_annoyingtotems"), typeof(AnnoyingTotems), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Painful Draws", "Drawing from the main deck deals 1 damage.", 30, Tools.LoadTexture("ascensionicon_painfulmain"), Tools.LoadTexture("ascensionicon_activated_painfulmain"), typeof(PainfulDraws), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Painful Squirrels", "Drawing from the side deck deals 1 damage.", 30, Tools.LoadTexture("ascensionicon_painfulside"), Tools.LoadTexture("ascensionicon_activated_painfulside"), typeof(PainfulSidedecks), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Runes", "Enemy cards of the dominant tribe get random sigils.", 30, Tools.LoadTexture("ascensionicon_runes"), ChallengeManager.DEFAULT_ACTIVATED_SPRITE, typeof(Runes), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			DentistryChallenge = ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Dentistry", "Item events and Trinket Bearer cards only give pliers.", 15, Tools.LoadTexture("ascensionicon_pliers"), Tools.LoadTexture("ascensionicon_activated_pliers"), 0, 1).Challenge.challengeType;
			ArchivedChallenge = ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Archived", "A random card choice is hidden in every card choice event.", 20, Tools.LoadTexture("ascensionicon_archived"), Tools.LoadTexture("ascensionicon_activated_archived"), 0, 1).Challenge.challengeType;
			ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Foundation", "All cards have 1 less attack. Side deck cards have Leader.", 25, Tools.LoadTexture("ascensionicon_foundation"), Tools.LoadTexture("ascensionicon_activated_foundation"), typeof(Foundation), 0, (List<object>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, (Func<FullChallenge[], IEnumerable<AscensionChallenge>>)null, 1);
			FinalBossV2Challenge = ChallengeManager.AddSpecific("spapi.inscryption.squirrelbombmod", "Final Boss v2", "Replaces Leshy as the final boss with a true BIG SHOT.", 60, Tools.LoadTexture("ascensionicon_spamtonbossnew"), Tools.LoadTexture("ascensionicon_activated_spamtonbossnew"), 12, 1).Challenge.challengeType;
			DialogueManager.GenerateEvent("spapi.inscryption.squirrelbombmod", "DancePartyDie", new List<CustomLine> { CustomLine.op_Implicit("You must dance! Don't stop dancing!!") }, new List<List<CustomLine>>
			{
				new List<CustomLine> { CustomLine.op_Implicit("Whoever stops dancing at my party will suffer the consequences.") },
				new List<CustomLine>
				{
					CustomLine.op_Implicit("Is that mechanic annoying?"),
					CustomLine.op_Implicit("Perfect. That's the point of it.")
				},
				new List<CustomLine> { CustomLine.op_Implicit("Dance my puppet! Daaaance.") },
				new List<CustomLine> { CustomLine.op_Implicit("You must dance! Don't stop dancing!!") }
			}, (MaxRepeatsBehaviour)0, (Speaker)0);
		}

		public void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			Tools.Setup();
			new Harmony("spapi.inscryption.squirrelbombmod").PatchAll();
			AddAbilities();
			AddCards();
			AddChallenges();
			AddStarterDecks();
			SpamtonSetup.Awake();
			DialogueManager.GenerateEvent("spapi.inscryption.squirrelbombmod", "PlayerSkipTurn", new List<CustomLine> { CustomLine.op_Implicit("You need to pass, remember?") }, (List<List<CustomLine>>)null, (MaxRepeatsBehaviour)0, (Speaker)0);
		}

		[HarmonyPatch(typeof(AscensionIconInteractable), "AssignInfo")]
		[HarmonyPostfix]
		public static void FixBigShotChallenge(AscensionIconInteractable __instance, AscensionChallengeInfo info)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (info.challengeType == FinalBossV2Challenge)
			{
				((Renderer)__instance.activatedRenderer).sortingOrder = 1;
			}
		}

		public static void AddStarterDecks()
		{
			StarterDeckManager.New("spapi.inscryption.squirrelbombmod", "Caged Potential", Tools.LoadTexture("starterdeck_icon_cage"), new string[3] { "RingWorm", "CagedWolf", "Tadpole" }, 0);
			StarterDeckManager.New("spapi.inscryption.squirrelbombmod", "Ultimate Challenge", Tools.LoadTexture("starterdeck_icon_bell"), new string[3] { "DausBell", "DausBell", "DausBell" }, 0);
			StarterDeckManager.New("spapi.inscryption.squirrelbombmod", "Sus", Tools.LoadTexture("starterdeck_icon_sus"), new string[3] { "Ijiraq", "Mole", "Skink" }, 0);
		}
	}
	public class AssetCollection
	{
		private readonly Dictionary<string, Object> loadedObjects = new Dictionary<string, Object>();

		private readonly List<AssetBundle> bundles = new List<AssetBundle>();

		private readonly List<AudioClip> audio = new List<AudioClip>();

		public readonly ReadOnlyCollection<AudioClip> Audio;

		public AssetCollection(string path)
		{
			string[] manifestResourceNames = Tools.CurrentAssembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (!text.StartsWith(path))
				{
					continue;
				}
				using Stream stream = Tools.CurrentAssembly.GetManifestResourceStream(text);
				try
				{
					AssetBundle val = AssetBundle.LoadFromStream(stream);
					if (Object.op_Implicit((Object)(object)val))
					{
						bundles.Add(val);
					}
				}
				catch
				{
				}
			}
			audio.AddRange(bundles.ConvertAll((AssetBundle x) => x.LoadAllAssets<AudioClip>()).SelectMany((AudioClip[] x) => x));
			Audio = new ReadOnlyCollection<AudioClip>(audio);
		}

		public Object LoadAsset(string name)
		{
			string key = "Object_" + name;
			if (loadedObjects.TryGetValue(key, out var value))
			{
				return value;
			}
			foreach (AssetBundle bundle in bundles)
			{
				try
				{
					Object val = bundle.LoadAsset(name);
					if (val == (Object)null)
					{
						continue;
					}
					loadedObjects[key] = val;
					return val;
				}
				catch
				{
				}
			}
			return null;
		}

		public T LoadAsset<T>(string name) where T : Object
		{
			string key = typeof(T).Name + "_" + name;
			if (loadedObjects.TryGetValue(key, out var value))
			{
				T val = (T)(object)((value is T) ? value : null);
				if (val != null)
				{
					return val;
				}
			}
			foreach (AssetBundle bundle in bundles)
			{
				try
				{
					T val2 = bundle.LoadAsset<T>(name);
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					loadedObjects[key] = (Object)(object)val2;
					return val2;
				}
				catch
				{
				}
			}
			return default(T);
		}

		public void UnloadAll(bool unloadLoadedObjects)
		{
			bundles.ForEach(delegate(AssetBundle x)
			{
				x.Unload(unloadLoadedObjects);
			});
			bundles.Clear();
		}
	}
	[HarmonyPatch]
	public static class DeckOriginPatch
	{
		public static MethodInfo mcfsd_aa = AccessTools.Method(typeof(DeckOriginPatch), "MarkCardFromSideDeck_AddAction", (Type[])null, (Type[])null);

		public static MethodInfo mcfnd_aa = AccessTools.Method(typeof(DeckOriginPatch), "MarkCardFromMainDeck_AddAction", (Type[])null, (Type[])null);

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyILManipulator]
		public static void MarkCardFromSideDeck_Transpiler(ILContext ctx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(ctx);
			if (val.JumpBeforeNext((Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CardSpawner>(x, "SpawnCardToHand")))
			{
				val.Emit(OpCodes.Call, (MethodBase)mcfsd_aa);
			}
		}

		public static Action<PlayableCard> MarkCardFromSideDeck_AddAction(Action<PlayableCard> curr)
		{
			return (Action<PlayableCard>)Delegate.Combine(curr, new Action<PlayableCard>(MarkCardFromSideDeck_Mark));
		}

		public static void MarkCardFromSideDeck_Mark(PlayableCard card)
		{
			((Component)(object)card).AddComponent<CardFromSideDeck>();
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyILManipulator]
		public static void MarkCardFromMainDeck_Transpiler(ILContext ctx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(ctx);
			if (val.JumpBeforeNext((Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CardSpawner>(x, "SpawnCardToHand")))
			{
				val.Emit(OpCodes.Call, (MethodBase)mcfnd_aa);
			}
		}

		public static Action<PlayableCard> MarkCardFromMainDeck_AddAction(Action<PlayableCard> curr)
		{
			return (Action<PlayableCard>)Delegate.Combine(curr, new Action<PlayableCard>(MarkCardFromMainDeck_Mark));
		}

		public static void MarkCardFromMainDeck_Mark(PlayableCard card)
		{
			((Component)(object)card).AddComponent<CardFromMainDeck>();
		}
	}
	public class CardFromSideDeck : MonoBehaviour
	{
	}
	public class CardFromMainDeck : MonoBehaviour
	{
	}
	public static class ILTools
	{
		[CompilerGenerated]
		private sealed class <MatchAfter>d__2 : IEnumerable<object>, IEnumerable, IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private int <>l__initialThreadId;

			private ILCursor crs;

			public ILCursor <>3__crs;

			private Func<Instruction, bool> match;

			public Func<Instruction, bool> <>3__match;

			private bool matchFromStart;

			public bool <>3__matchFromStart;

			private Instruction <curr>5__1;

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

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

			[DebuggerHidden]
			public <MatchAfter>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<curr>5__1 = crs.Next;
					if (matchFromStart)
					{
						crs.Index = 0;
					}
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (crs.JumpToNext(match))
				{
					<>2__current = crs.Previous;
					<>1__state = 1;
					return true;
				}
				crs.Next = <curr>5__1;
				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();
			}

			[DebuggerHidden]
			IEnumerator<object> IEnumerable<object>.GetEnumerator()
			{
				<MatchAfter>d__2 <MatchAfter>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<MatchAfter>d__ = this;
				}
				else
				{
					<MatchAfter>d__ = new <MatchAfter>d__2(0);
				}
				<MatchAfter>d__.crs = <>3__crs;
				<MatchAfter>d__.match = <>3__match;
				<MatchAfter>d__.matchFromStart = <>3__matchFromStart;
				return <MatchAfter>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<object>)this).GetEnumerator();
			}
		}

		[CompilerGenerated]
		private sealed class <MatchArg>d__8 : IEnumerable<object>, IEnumerable, IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private int <>l__initialThreadId;

			private ILCursor crs;

			public ILCursor <>3__crs;

			private Instruction targetInstr;

			public Instruction <>3__targetInstr;

			private int argIndex;

			public int <>3__argIndex;

			private Instruction <curr>5__1;

			private List<Instruction> <argumentInstrs>5__2;

			private List<Instruction>.Enumerator <>s__3;

			private Instruction <arg>5__4;

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

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

			[DebuggerHidden]
			public <MatchArg>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<curr>5__1 = null;
				<argumentInstrs>5__2 = null;
				<arg>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						if (argIndex < 0)
						{
							return false;
						}
						if (targetInstr == null)
						{
							return false;
						}
						<curr>5__1 = crs.Next;
						<argumentInstrs>5__2 = targetInstr.GetArgumentInstructions(crs.Context, argIndex);
						<>s__3 = <argumentInstrs>5__2.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						<arg>5__4 = null;
						break;
					}
					if (<>s__3.MoveNext())
					{
						<arg>5__4 = <>s__3.Current;
						crs.Goto(<arg>5__4, (MoveType)2, false);
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					crs.Next = <curr>5__1;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>s__3).Dispose();
			}

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

			[DebuggerHidden]
			IEnumerator<object> IEnumerable<object>.GetEnumerator()
			{
				<MatchArg>d__8 <MatchArg>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<MatchArg>d__ = this;
				}
				else
				{
					<MatchArg>d__ = new <MatchArg>d__8(0);
				}
				<MatchArg>d__.crs = <>3__crs;
				<MatchArg>d__.targetInstr = <>3__targetInstr;
				<MatchArg>d__.argIndex = <>3__argIndex;
				return <MatchArg>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<object>)this).GetEnumerator();
			}
		}

		[CompilerGenerated]
		private sealed class <MatchBefore>d__3 : IEnumerable<object>, IEnumerable, IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private int <>l__initialThreadId;

			private ILCursor crs;

			public ILCursor <>3__crs;

			private Func<Instruction, bool> match;

			public Func<Instruction, bool> <>3__match;

			private bool matchFromStart;

			public bool <>3__matchFromStart;

			private Instruction <curr>5__1;

			private Instruction <c>5__2;

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

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

			[DebuggerHidden]
			public <MatchBefore>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<curr>5__1 = crs.Next;
					if (matchFromStart)
					{
						crs.Index = 0;
					}
					break;
				case 1:
					<>1__state = -1;
					crs.Goto(<c>5__2, (MoveType)2, false);
					<c>5__2 = null;
					break;
				}
				if (crs.JumpBeforeNext(match))
				{
					<c>5__2 = crs.Next;
					<>2__current = crs.Next;
					<>1__state = 1;
					return true;
				}
				crs.Next = <curr>5__1;
				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();
			}

			[DebuggerHidden]
			IEnumerator<object> IEnumerable<object>.GetEnumerator()
			{
				<MatchBefore>d__3 <MatchBefore>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<MatchBefore>d__ = this;
				}
				else
				{
					<MatchBefore>d__ = new <MatchBefore>d__3(0);
				}
				<MatchBefore>d__.crs = <>3__crs;
				<MatchBefore>d__.match = <>3__match;
				<MatchBefore>d__.matchFromStart = <>3__matchFromStart;
				return <MatchBefore>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<object>)this).GetEnumerator();
			}
		}

		public static bool JumpToNext(this ILCursor crs, Func<Instruction, bool> match, int times = 1)
		{
			for (int i = 0; i < times; i++)
			{
				if (!crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { match }))
				{
					return false;
				}
			}
			return true;
		}

		public static bool JumpBeforeNext(this ILCursor crs, Func<Instruction, bool> match, int times = 1)
		{
			for (int i = 0; i < times; i++)
			{
				if (!crs.TryGotoNext((MoveType)((i != times - 1) ? 2 : 0), new Func<Instruction, bool>[1] { match }))
				{
					return false;
				}
			}
			return true;
		}

		[IteratorStateMachine(typeof(<MatchAfter>d__2))]
		public static IEnumerable MatchAfter(this ILCursor crs, Func<Instruction, bool> match, bool matchFromStart = true)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <MatchAfter>d__2(-2)
			{
				<>3__crs = crs,
				<>3__match = match,
				<>3__matchFromStart = matchFromStart
			};
		}

		[IteratorStateMachine(typeof(<MatchBefore>d__3))]
		public static IEnumerable MatchBefore(this ILCursor crs, Func<Instruction, bool> match, bool matchFromStart = true)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <MatchBefore>d__3(-2)
			{
				<>3__crs = crs,
				<>3__match = match,
				<>3__matchFromStart = matchFromStart
			};
		}

		public static VariableDefinition DeclareLocal<T>(this ILContext ctx)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			VariableDefinition val = new VariableDefinition(ctx.Import(typeof(T)));
			ctx.Body.Variables.Add(val);
			return val;
		}

		public static VariableDefinition DeclareLocal<T>(this ILCursor crs)
		{
			return crs.Context.DeclareLocal<T>();
		}

		public static bool TryGotoArg(this ILCursor crs, Instruction targetInstr, int argIndex, int instance = 0)
		{
			if (argIndex < 0)
			{
				return false;
			}
			if (instance < 0)
			{
				return false;
			}
			if (targetInstr == null)
			{
				return false;
			}
			List<Instruction> argumentInstructions = targetInstr.GetArgumentInstructions(crs.Context, argIndex);
			if (instance >= argumentInstructions.Count)
			{
				return false;
			}
			crs.Goto(argumentInstructions[instance], (MoveType)2, false);
			return true;
		}

		public static bool TryGotoArg(this ILCursor crs, int argIndex, int instance = 0)
		{
			return crs.TryGotoArg(crs.Next, argIndex, instance);
		}

		[IteratorStateMachine(typeof(<MatchArg>d__8))]
		public static IEnumerable MatchArg(this ILCursor crs, Instruction targetInstr, int argIndex)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <MatchArg>d__8(-2)
			{
				<>3__crs = crs,
				<>3__targetInstr = targetInstr,
				<>3__argIndex = argIndex
			};
		}

		public static IEnumerable MatchArg(this ILCursor crs, int argIndex)
		{
			return crs.MatchArg(crs.Next, argIndex);
		}

		private static List<Instruction> GetArgumentInstructions(this Instruction instruction, ILContext context, int argumentIndex)
		{
			int num = instruction.InputCount();
			int num2 = num - argumentIndex - 1;
			if (num2 < 0)
			{
				return new List<Instruction>();
			}
			List<Instruction> list = instruction.PossiblePreviousInstructions(context);
			List<Instruction> list2 = new List<Instruction>();
			foreach (Instruction item in list)
			{
				BacktrackToArg(item, context, num2, list2);
			}
			list2.Sort((Instruction a, Instruction b) => context.IndexOf(a).CompareTo(context.IndexOf(b)));
			return list2;
		}

		private static void BacktrackToArg(Instruction current, ILContext ctx, int remainingMoves, List<Instruction> foundArgs)
		{
			if (remainingMoves <= 0 && current.OutputCount() > 0)
			{
				if (remainingMoves == 0)
				{
					foundArgs.Add(current);
				}
				return;
			}
			remainingMoves -= current.StackDelta();
			List<Instruction> list = current.PossiblePreviousInstructions(ctx);
			foreach (Instruction item in list)
			{
				BacktrackToArg(item, ctx, remainingMoves, foundArgs);
			}
		}

		public static int InputCount(this Instruction instr)
		{
			//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)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected I4, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Invalid comparison between Unknown and I4
			if (instr == null)
			{
				return 0;
			}
			OpCode opCode = instr.OpCode;
			if ((int)((OpCode)(ref opCode)).FlowControl == 2)
			{
				IMethodSignature val = (IMethodSignature)instr.Operand;
				int num = 0;
				if ((int)((OpCode)(ref opCode)).Code != 114 && val.HasThis && !val.ExplicitThis)
				{
					num++;
				}
				if (val.HasParameters)
				{
					num += val.Parameters.Count;
				}
				if ((int)((OpCode)(ref opCode)).Code == 40)
				{
					num++;
				}
				return num;
			}
			StackBehaviour stackBehaviourPop = ((OpCode)(ref opCode)).StackBehaviourPop;
			if (1 == 0)
			{
			}
			int result;
			switch (stackBehaviourPop - 1)
			{
			case 0:
			case 2:
			case 9:
				result = 1;
				break;
			case 1:
			case 3:
			case 4:
			case 5:
			case 7:
			case 8:
			case 10:
			case 11:
				result = 2;
				break;
			case 6:
			case 12:
			case 13:
			case 14:
			case 15:
			case 16:
				result = 3;
				break;
			default:
				result = 0;
				break;
			}
			if (1 == 0)
			{
			}
			return result;
		}

		public static int OutputCount(this Instruction instr)
		{
			//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)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0033: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected I4, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			if (instr == null)
			{
				return 0;
			}
			OpCode opCode = instr.OpCode;
			if ((int)((OpCode)(ref opCode)).FlowControl == 2)
			{
				IMethodSignature val = (IMethodSignature)instr.Operand;
				int num = 0;
				if ((int)((OpCode)(ref opCode)).Code == 114 || (int)val.ReturnType.MetadataType != 1)
				{
					num++;
				}
				return num;
			}
			StackBehaviour stackBehaviourPush = ((OpCode)(ref opCode)).StackBehaviourPush;
			if (1 == 0)
			{
			}
			int result;
			switch (stackBehaviourPush - 20)
			{
			case 0:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
				result = 1;
				break;
			case 1:
				result = 2;
				break;
			default:
				result = 0;
				break;
			}
			if (1 == 0)
			{
			}
			return result;
		}

		public static int StackDelta(this Instruction instr)
		{
			return instr.OutputCount() - instr.InputCount();
		}

		public static List<Instruction> PossiblePreviousInstructions(this Instruction instr, ILContext ctx)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			List<Instruction> list = new List<Instruction>();
			Enumerator<Instruction> enumerator = ctx.Instrs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Instruction current = enumerator.Current;
					if (Array.IndexOf(current.PossibleNextInstructions(), instr) >= 0)
					{
						list.Add(current);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			return list;
		}

		public static Instruction[] PossibleNextInstructions(this Instruction instr)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected I4, but got Unknown
			OpCode opCode = instr.OpCode;
			FlowControl flowControl = ((OpCode)(ref opCode)).FlowControl;
			if (1 == 0)
			{
			}
			Instruction[] result;
			switch ((int)flowControl)
			{
			case 2:
			case 5:
				result = (Instruction[])(object)new Instruction[1] { instr.Next };
				break;
			case 0:
			{
				Instruction branchTarget2 = instr.GetBranchTarget();
				result = (Instruction[])((branchTarget2 == null) ? ((Array)Array.Empty<Instruction>()) : ((Array)new Instruction[1] { branchTarget2 }));
				break;
			}
			case 3:
			{
				Instruction branchTarget = instr.GetBranchTarget();
				result = (Instruction[])(object)((branchTarget == null) ? new Instruction[1] { instr.Next } : new Instruction[2] { instr.Next, branchTarget });
				break;
			}
			default:
				result = Array.Empty<Instruction>();
				break;
			}
			if (1 == 0)
			{
			}
			return result;
		}

		public static Instruction GetBranchTarget(this Instruction branch)
		{
			object operand = branch.Operand;
			Instruction val = (Instruction)((operand is Instruction) ? operand : null);
			if (val != null)
			{
				return val;
			}
			object operand2 = branch.Operand;
			return ((ILLabel)(((operand2 is ILLabel) ? operand2 : null)?)).Target;
		}

		public static string InstructionToString(this Instruction c)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_0040: Invalid comparison between Unknown and I4
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			if (c == null)
			{
				return "Null instruction";
			}
			OpCode opCode;
			try
			{
				return ((object)c).ToString();
			}
			catch
			{
				try
				{
					opCode = c.OpCode;
					OperandType operandType = ((OpCode)(ref opCode)).OperandType;
					if (((int)operandType == 0 || (int)operandType == 15) ? true : false)
					{
						object operand = c.Operand;
						ILLabel val = (ILLabel)((operand is ILLabel) ? operand : null);
						if (val != null)
						{
							object arg = c.Offset;
							opCode = c.OpCode;
							return $"IL_{arg:x4}: {((OpCode)(ref opCode)).Name} IL_{val.Target.Offset:x4}";
						}
					}
					opCode = c.OpCode;
					if ((int)((OpCode)(ref opCode)).OperandType == 10 && c.Operand is IEnumerable<ILLabel> source)
					{
						object arg2 = c.Offset;
						opCode = c.OpCode;
						return string.Format("IL_{0:x4}: {1} {2}", arg2, ((OpCode)(ref opCode)).Name, string.Join(", ", source.Select((ILLabel x) => x.Target.Offset.ToString("x4"))));
					}
				}
				catch
				{
				}
			}
			object arg3 = c.Offset;
			opCode = c.OpCode;
			return $"IL_{arg3:x4}: {((OpCode)(ref opCode)).Name} (This shouldn't be happening)";
		}

		public static T EnumeratorGetField<T>(this object obj, string name)
		{
			return (T)obj.GetType().EnumeratorField(name).GetValue(obj);
		}

		public static void EnumeratorSetField<T>(this object obj, string name, T value)
		{
			obj.GetType().EnumeratorField(name).SetValue(obj, value);
		}

		public static FieldInfo EnumeratorField(this MethodBase method, string name)
		{
			return method.DeclaringType.EnumeratorField(name);
		}

		public static FieldInfo EnumeratorField(this Type tp, string name)
		{
			return tp.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).First((FieldInfo x) => x != null && x.Name != null && (x.Name.Contains("<" + name + ">") || x.Name.Contains("__" + name) || x.Name == name));
		}
	}
	[HarmonyPatch]
	public static class Tools
	{
		private class SkipNextPlayerTurnHolder : MonoBehaviour
		{
			public bool skipNextPlayerTurn;
		}

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

			private object <>2__current;

			public PlayableCard target;

			public CardSlot attacker;

			public int damage;

			private PlayableCard <possibleAttacker>5__1;

			private GameObject <bomb>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<possibleAttacker>5__1 = attacker.Card;
					<bomb>5__2 = Object.Instantiate<GameObject>(detonatorBomb).ApplyTransparent();
					<bomb>5__2.transform.position = ((Component)attacker).transform.position + Vector3.up * 0.1f;
					Tween.Position(<bomb>5__2.transform, ((Component)target).transform.position + Vector3.up * 0.1f, 0.5f, 0f, Tween.EaseLinear, (LoopType)0, (Action)null, (Action)null, true);
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Card)target).Anim.PlayHitAnimation();
					Object.Destroy((Object)(object)<bomb>5__2);
					<>2__current = target.TakeDamage(damage, <possibleAttacker>5__1);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					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 <DealDamageNoKill>d__46 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int damage;

			public bool toplayer;

			private LifeManager <life>5__1;

			private int <currentbalance>5__2;

			private int <dam>5__3;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<life>5__1 = Singleton<LifeManager>.Instance;
					if ((Object)(object)<life>5__1 == (Object)null)
					{
						return false;
					}
					if (damage < 0)
					{
						toplayer = !toplayer;
					}
					<currentbalance>5__2 = <life>5__1.Balance;
					if (toplayer)
					{
						<currentbalance>5__2 = -<currentbalance>5__2;
					}
					<dam>5__3 = Mathf.Min(damage, Mathf.Max(4 - <currentbalance>5__2, 0));
					if (<dam>5__3 <= 0)
					{
						return false;
					}
					<>2__current = <life>5__1.ShowDamageSequence(<dam>5__3, <dam>5__3, toplayer, 0.125f, (GameObject)null, 0f, true);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					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 <Explode>d__23 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CardSlot slot;

			public int damage;

			public bool bombOpposing;

			private List<CardSlot> <adjacentSlots>5__1;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<adjacentSlots>5__1 = Singleton<BoardManager>.Instance.GetAdjacentSlots(slot);
					if (<adjacentSlots>5__1.Count > 0 && <adjacentSlots>5__1[0].Index < slot.Index)
					{
						if ((Object)(object)<adjacentSlots>5__1[0].Card != (Object)null && !<adjacentSlots>5__1[0].Card.Dead)
						{
							<>2__current = BombCard(<adjacentSlots>5__1[0].Card, slot, damage);
							<>1__state = 1;
							return true;
						}
						goto IL_00fa;
					}
					goto IL_0108;
				case 1:
					<>1__state = -1;
					goto IL_00fa;
				case 2:
					<>1__state = -1;
					goto IL_0180;
				case 3:
					{
						<>1__state = -1;
						break;
					}
					IL_00fa:
					<adjacentSlots>5__1.RemoveAt(0);
					goto IL_0108;
					IL_0108:
					if (bombOpposing && (Object)(object)slot.opposingSlot.Card != (Object)null && !slot.opposingSlot.Card.Dead)
					{
						<>2__current = BombCard(slot.opposingSlot.Card, slot, damage);
						<>1__state = 2;
						return true;
					}
					goto IL_0180;
					IL_0180:
					if (<adjacentSlots>5__1.Count > 0 && (Object)(object)<adjacentSlots>5__1[0].Card != (Object)null && !<adjacentSlots>5__1[0].Card.Dead)
					{
						<>2__current = BombCard(<adjacentSlots>5__1[0].Card, slot, damage);
						<>1__state = 3;
						return true;
					}
					break;
				}
				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();
			}
		}

		public const string GUID = "spapi.inscryption.squirrelbombmod";

		public const string NAME = "The Squirrel Bomb Mod";

		public const string VERSION = "1.1.1";

		public const string PREFIX = "spapi";

		public const string ASSETPATH = "SquirrelBombMod.Assets.";

		public static AssetCollection assets = LoadAllAssets();

		public static readonly Dictionary<string, Ability> registeredAbilities = new Dictionary<string, Ability>();

		public static GameObject royalCrosshair = Resources.Load<GameObject>("Prefabs/Cards/SpecificCardModels/CannonTargetIcon");

		public static Material royalCannonTransparent = new Material(Resources.Load<GameObject>("Prefabs/Cards/SpecificCardModels/CannonTargetIcon").GetComponentInChildren<Renderer>().material);

		public static GameObject detonatorBomb = Resources.Load<GameObject>("Prefabs/Cards/SpecificCardModels/DetonatorHoloBomb");

		private static Assembly _assembly;

		public static Assembly CurrentAssembly => _assembly ?? (_assembly = Assembly.GetExecutingAssembly());

		public static List<CardSlot> OpponentSlotsCopy
		{
			get
			{
				BoardManager instance = Singleton<BoardManager>.Instance;
				return ((instance != null) ? instance.OpponentSlotsCopy : null) ?? new List<CardSlot>();
			}
		}

		public static List<CardSlot> PlayerSlotsCopy
		{
			get
			{
				BoardManager instance = Singleton<BoardManager>.Instance;
				return ((instance != null) ? instance.PlayerSlotsCopy : null) ?? new List<CardSlot>();
			}
		}

		public static List<CardSlot> AllSlotsCopy
		{
			get
			{
				BoardManager instance = Singleton<BoardManager>.Instance;
				return ((instance != null) ? instance.AllSlotsCopy : null) ?? new List<CardSlot>();
			}
		}

		public static BoardManager Board => Singleton<BoardManager>.Instance;

		public static TurnManager Game => Singleton<TurnManager>.Instance;

		public static void Setup()
		{
		}

		public static int BetterCostTier(this CardInfo self)
		{
			return self.BloodCost * 3 + self.BonesCost + self.energyCost + self.gemsCost.Count * 3;
		}

		public static Texture2D LoadTexture(string name)
		{
			return TextureHelper.GetImageAsTexture(name + (name.EndsWith(".png") ? "" : ".png"), CurrentAssembly, (FilterMode)0);
		}

		public static Sprite LoadSprite(string name)
		{
			Texture2D obj = LoadTexture(name);
			return (obj != null) ? TextureHelper.ConvertTexture(obj, (Vector2?)null) : null;
		}

		public static AssetBundle LoadAssets(string name)
		{
			try
			{
				return AssetBundle.LoadFromMemory(TextureHelper.GetResourceBytes(name, CurrentAssembly));
			}
			catch
			{
				return null;
			}
		}

		public static AssetCollection LoadAllAssets()
		{
			return new AssetCollection("SquirrelBombMod.Assets.");
		}

		public static bool IsFromSideDeck(this PlayableCard card)
		{
			return Object.op_Implicit((Object)(object)((Component)card).GetComponent<CardFromSideDeck>());
		}

		public static bool IsFromMainDeck(this PlayableCard card)
		{
			return Object.op_Implicit((Object)(object)((Component)card).GetComponent<CardFromMainDeck>());
		}

		public static CardInfo TryGetCard(string name)
		{
			try
			{
				return CardLoader.GetCardByName(name);
			}
			catch
			{
				try
				{
					return CardLoader.GetCardByName("spapi_" + name);
				}
				catch
				{
					Debug.LogError((object)("Unable to get card: " + name));
					return null;
				}
			}
		}

		public static bool IsRareCard(this CardInfo c)
		{
			return c?.metaCategories != null && c.metaCategories.Contains((CardMetaCategory)3);
		}

		[IteratorStateMachine(typeof(<Explode>d__23))]
		public static IEnumerator Explode(CardSlot slot, int damage = 10, bool bombOpposing = true)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Explode>d__23(0)
			{
				slot = slot,
				damage = damage,
				bombOpposing = bombOpposing
			};
		}

		public static CardInfo GetRandomChoosableRareCardWithCost(int randomSeed, int bloodCost)
		{
			List<CardInfo> list = CardLoader.GetUnlockedCards((CardMetaCategory)3, (CardTemple)0).FindAll((CardInfo x) => x.BloodCost == bloodCost);
			if (list.Count == 0)
			{
				return null;
			}
			return CardLoader.Clone(list[SeededRandom.Range(0, list.Count, randomSeed)]);
		}

		public static CardInfo GetRandomChoosableRareCardOfTribe(int randomSeed, Tribe tribe)
		{
			//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)
			List<CardInfo> list = CardLoader.GetUnlockedCards((CardMetaCategory)3, (CardTemple)0).FindAll((CardInfo x) => x.IsOfTribe(tribe));
			if (list.Count == 0)
			{
				return null;
			}
			return CardLoader.Clone(list[SeededRandom.Range(0, list.Count, randomSeed)]);
		}

		public static List<PlayableCard> GetAliveCards(List<CardSlot> slots)
		{
			return slots.FindAll((CardSlot x) => (Object)(object)x.Card != (Object)null && !x.Card.Dead).ConvertAll((CardSlot x) => x.Card);
		}

		public static List<CardSlot> GetEmptySlots(List<CardSlot> slots)
		{
			return slots.FindAll((CardSlot x) => (Object)(object)x.Card == (Object)null || x.Card.Dead);
		}

		public static List<CardSlot> GetFilledSlots(List<CardSlot> slots)
		{
			return slots.FindAll((CardSlot x) => (Object)(object)x.Card != (Object)null && !x.Card.Dead);
		}

		public static CardInfo GetRandomChoosableRareBonesCard(int randomSeed)
		{
			List<CardInfo> list = CardLoader.GetUnlockedCards((CardMetaCategory)3, (CardTemple)0).FindAll((CardInfo x) => x.BonesCost > 0);
			if (list.Count == 0)
			{
				return null;
			}
			return CardLoader.Clone(list[SeededRandom.Range(0, list.Count, randomSeed)]);
		}

		public static CardBlueprint BuildCardBlueprint(string card)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0020: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			return new CardBlueprint
			{
				card = TryGetCard(card),
				difficultyReplace = false,
				difficultyReq = 0,
				maxDifficulty = 1000,
				minDifficulty = 0,
				randomReplaceChance = 0,
				replacement = null
			};
		}

		public static void GlitchModelDeactivate(Transform parent, bool onlyGlitchParent = false, bool doShake = true)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			if (!((Object)(object)parent != (Object)null))
			{
				return;
			}
			GlitchOutAssetEffect.PlayGlitchSound(parent.position);
			GlitchOutAssetEffect.SwitchModelToGlitchMaterial(parent, onlyGlitchParent);
			if (doShake)
			{
				Tween.Shake(parent, parent.localPosition, Vector3.one * 0.2f, 0.1f, 0f, (LoopType)1, (Action)null, (Action)null, false);
			}
			GlitchOutAssetEffect.ShowDeletionInUI(parent);
			CustomCoroutine.WaitThenExecute(0.2f, (Action)delegate
			{
				if ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)null)
				{
					((Component)parent).gameObject.SetActive(false);
				}
			}, true);
		}

		[IteratorStateMachine(typeof(<BombCard>d__42))]
		public static IEnumerator BombCard(PlayableCard target, CardSlot attacker, int damage = 10)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <BombCard>d__42(0)
			{
				target = target,
				attacker = attacker,
				damage = damage
			};
		}

		public static GameObject ApplyTransparent(this GameObject go)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				val.material = new Material(royalCannonTransparent);
			}
			return go;
		}

		public static T MaxElement<T>(this IEnumerable<T> self, Func<T, float> selector)
		{
			T val = default(T);
			float? num = null;
			foreach (T item in self)
			{
				if (item != null && !item.Equals(val))
				{
					float num2 = selector(item);
					if (!num.HasValue || num2 > num)
					{
						val = item;
						num = num2;
					}
				}
			}
			return val;
		}

		public static List<T> SortedCopy<T>(this List<T> list, Comparison<T> comparison)
		{
			List<T> list2 = new List<T>(list);
			list2.Sort(comparison);
			return list2;
		}

		[IteratorStateMachine(typeof(<DealDamageNoKill>d__46))]
		public static IEnumerator DealDamageNoKill(int damage, bool toplayer)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DealDamageNoKill>d__46(0)
			{
				damage = damage,
				toplayer = toplayer
			};
		}

		public static List<CardSlot> GetEmptyQueueSlots()
		{
			TurnManager instance = Singleton<TurnManager>.Instance;
			if (((instance == null) ? null : instance.Opponent?.queuedCards) == null)
			{
				return new List<CardSlot>();
			}
			List<CardSlot> opponentSlotsCopy = Singleton<BoardManager>.Instance.OpponentSlotsCopy;
			opponentSlotsCopy.RemoveAll((CardSlot x) => Object.op_Implicit((Object)(object)Singleton<TurnManager>.Instance.Opponent.queuedCards.Find((PlayableCard y) => (Object)(object)y.QueuedSlot == (Object)(object)x)));
			return opponentSlotsCopy;
		}

		public static CardModificationInfo CreateRandomizedAbilitiesStatsModSeeded(int randomSeed, List<AbilityInfo> validAbilities, int totalStatPoints, int minAttack, int minHealth)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			CardModificationInfo val = new CardModificationInfo();
			int availableStatPoints = totalStatPoints - minAttack * 2 - minHealth;
			validAbilities.RemoveAll((AbilityInfo x) => x.powerLevel > availableStatPoints);
			float num = 0.25f;
			while (validAbilities.Count > 0 && SeededRandom.Value(randomSeed++) > num)
			{
				AbilityInfo val2 = validAbilities[SeededRandom.Range(0, validAbilities.Count, randomSeed++)];
				val.abilities.Add(val2.ability);
				availableStatPoints -= val2.powerLevel;
				validAbilities.Remove(val2);
				validAbilities.RemoveAll((AbilityInfo x) => x.powerLevel > availableStatPoints);
				num += 0.25f;
			}
			int num2 = SeededRandom.Range(0, availableStatPoints + 1, randomSeed++);
			availableStatPoints -= num2;
			int num3 = availableStatPoints / 2;
			val.attackAdjustment = minAttack + num3;
			val.healthAdjustment = minHealth + num2;
			return val;
		}

		public static void SkipNextPlayerTurn()
		{
			TurnManager instance = Singleton<TurnManager>.Instance;
			SkipNextPlayerTurnHolder skipNextPlayerTurnHolder = ((instance == null) ? null : ((Component)(object)instance.Opponent)?.GetOrAddComponent<SkipNextPlayerTurnHolder>());
			if ((Object)(object)skipNextPlayerTurnHolder != (Object)null)
			{
				skipNextPlayerTurnHolder.skipNextPlayerTurn = true;
			}
		}

		public static void UnskipNextPlayerTurn()
		{
			TurnManager instance = Singleton<TurnManager>.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				Opponent opponent = instance.Opponent;
				obj = ((opponent != null) ? ((Component)opponent).GetComponent<SkipNextPlayerTurnHolder>() : null);
			}
			SkipNextPlayerTurnHolder skipNextPlayerTurnHolder = (SkipNextPlayerTurnHolder)obj;
			if ((Object)(object)skipNextPlayerTurnHolder != (Object)null)
			{
				skipNextPlayerTurnHolder.skipNextPlayerTurn = false;
			}
		}

		public static bool DoSkipPlayerTurn()
		{
			TurnManager instance = Singleton<TurnManager>.Instance;
			bool? obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				Opponent opponent = instance.Opponent;
				obj = ((opponent == null) ? null : ((Component)opponent).GetComponent<SkipNextPlayerTurnHolder>()?.skipNextPlayerTurn);
			}
			bool? flag = obj;
			return flag.GetValueOrDefault();
		}

		public static T GetOrAddComponent<T>(this GameObject go) where T : Component
		{
			return ((go != null) ? go.GetComponent<T>() : default(T)) ?? ((go != null) ? go.AddComponent<T>() : default(T));
		}

		public static T GetOrAddComponent<T>(this Component c) where T : Component
		{
			return c.gameObject.GetOrAddComponent<T>();
		}

		public static T AddComponent<T>(this Component c) where T : Component
		{
			return c.gameObject.AddComponent<T>();
		}

		public static Ability FindFromContext()
		{
			//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_0042: Unknown result type (might be due to invalid IL or missing references)
			return FindRegisteredAbility(new StackTrace().GetFrames().Skip(1).FirstOrDefault()?.GetMethod()?.DeclaringType?.Name);
		}

		public static Ability FindRegisteredAbility<T>() where T : AbilityBehaviour
		{
			//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)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return FindRegisteredAbility(typeof(T)?.Name);
		}

		public static Ability FindRegisteredAbility(string name)
		{
			//IL_0023: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(name) && registeredAbilities.TryGetValue(name, out var value))
			{
				return value;
			}
			return (Ability)0;
		}

		public static AbilityInfo RegisterAbility(this AbilityInfo info, string name)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(name) || registeredAbilities.ContainsKey(name))
			{
				return info;
			}
			registeredAbilities.Add(name, info.ability);
			return info;
		}

		public static AbilityInfo NewAbility(string rulebookName, string rulebookDescription, Type behavior, string tex)
		{
			return NewAbility(rulebookName, rulebookDescription, behavior?.Name, tex, behavior);
		}

		public static AbilityInfo NewAbility(string rulebookName, string rulebookDescription, string name, string tex, Type behavior = null)
		{
			string name2 = name ?? behavior?.Name ?? "";
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = rulebookName;
			val.rulebookDescription = rulebookDescription;
			((Object)val).name = name2;
			val.opponentUsable = true;
			if ((object)behavior == null)
			{
				behavior = typeof(AbilityBehaviour);
			}
			AbilityManager.Add("spapi.inscryption.squirrelbombmod", val, behavior, (Texture)(object)LoadTexture(tex));
			val.RegisterAbility(name2);
			return val;
		}

		public static AbilityInfo SetColor(this AbilityInfo info, Color c)
		{
			//IL_0009: 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)
			info.hasColorOverride = true;
			info.colorOverride = c;
			return info;
		}

		public static AbilityInfo SetOpponentUnusable(this AbilityInfo info)
		{
			info.opponentUsable = false;
			return info;
		}

		public static AbilityInfo SetPower(this AbilityInfo info, int power)
		{
			info.powerLevel = power;
			return info;
		}

		public static AbilityInfo SetPart1Rulebook(this AbilityInfo info)
		{
			AbilityExtensions.AddMetaCategories(info, (AbilityMetaCategory[])(object)new AbilityMetaCategory[1]);
			return info;
		}

		public static AbilityInfo SetPart3Rulebook(this AbilityInfo info)
		{
			AbilityExtensions.AddMetaCategories(info, (AbilityMetaCategory[])(object)new AbilityMetaCategory[1] { (AbilityMetaCategory)2 });
			return info;
		}

		public static AbilityInfo SetColor(this AbilityInfo info, byte r, byte g, byte b, byte a = byte.MaxValue)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return info.SetColor(Color32.op_Implicit(new Color32(r, g, b, a)));
		}

		public static T RandomElement<T>(this IList<T> l, int? seed = null)
		{
			if (!seed.HasValue)
			{
				return l[Random.Range(0, l.Count)];
			}
			return l[SeededRandom.Range(0, l.Count, seed.GetValueOrDefault())];
		}

		public static int UnboundedRandomNumber(float repeatChance, int cycles = 1, int? seed = null)
		{
			int num = 0;
			for (int i = 0; i < cycles; i++)
			{
				float num2 = (seed.HasValue ? SeededRandom.Value(seed.GetValueOrDefault()) : Random.value);
				num += (int)Math.Ceiling(Math.Log(num2) / Math.Log(repeatChance));
				if (seed.HasValue)
				{
					seed = seed.GetValueOrDefault() + 1;
				}
			}
			return num;
		}

		[HarmonyPatch(typeof(AudioController), "GetAudioClip")]
		[HarmonyPrefix]
		public static void AddSFX(AudioController __instance)
		{
			__instance.SFX.AddRange(assets.Audio.Where((AudioClip x) => !__instance.SFX.Contains(x)));
		}

		[HarmonyPatch(typeof(AudioController), "GetLoop")]
		[HarmonyPatch(typeof(AudioController), "GetLoopClip")]
		[HarmonyPrefix]
		public static void AddLoops1(AudioController __instance)
		{
			__instance.Loops.AddRange(assets.Audio.Where((AudioClip x) => !__instance.Loops.Contains(x)));
		}
	}
}
namespace SquirrelBombMod.Triggers
{
	public interface IOnModifyOpponentCard
	{
		bool RespondsToModifyOpponentCard(PlayableCard card);

		void OnModifyOpponentCard(PlayableCard card);
	}
	[HarmonyPatch]
	public static class Patches
	{
		[HarmonyPatch(typeof(Part1Opponent), "ModifyQueuedCard")]
		[HarmonyPatch(typeof(Part1Opponent), "ModifySpawnedCard")]
		[HarmonyPostfix]
		public static void TriggerOnOpponentCard(PlayableCard card)
		{
			if (!((Object)(object)card == (Object)null))
			{
				CustomTriggerFinder.CallAll<IOnModifyOpponentCard>(false, (Func<IOnModifyOpponentCard, bool>)((IOnModifyOpponentCard x) => x.RespondsToModifyOpponentCard(card)), (Action<IOnModifyOpponentCard>)delegate(IOnModifyOpponentCard x)
				{
					x.OnModifyOpponentCard(card);
				});
			}
		}
	}
}
namespace SquirrelBombMod.Challenges
{
	public class Again : ChallengeBehaviour, ISetupAttackSequence, IOnPreSlotAttackSequence
	{
		[CompilerGenerated]
		private sealed class <OnPreSlotAttackSequence>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CardSlot attackingSlot;

			public Again <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				((ChallengeBehaviour)<>4__this).ShowActivation();
				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();
			}
		}

		public List<CardSlot> CollectModifyAttackSlots(PlayableCard card, OpposingSlotTriggerPriority modType, List<CardSlot> originalSlots, List<CardSlot> currentSlots, ref int attackCount, ref bool didRemoveDefaultSlot)
		{
			attackCount *= 2;
			List<CardSlot> list = new List<CardSlot>(currentSlots.Count + currentSlots.Count);
			list.AddRange(currentSlots);
			list.AddRange(currentSlots);
			return list;
		}

		public int GetTriggerPriority(PlayableCard card, OpposingSlotTriggerPriority modType, List<CardSlot> originalSlots, List<CardSlot> currentSlots, int attackCount, bool didRemoveDefaultSlot)
		{
			return 88888;
		}

		public bool RespondsToModifyAttackSlots(PlayableCard card, OpposingSlotTriggerPriority modType, List<CardSlot> originalSlots, List<CardSlot> currentSlots, int attackCount, bool didRemoveDefaultSlot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			return (int)modType == 2 && card.OpponentCard;
		}

		public bool RespondsToPreSlotAttackSequence(CardSlot attackingSlot)
		{
			return (Object)(object)((attackingSlot != null) ? attackingSlot.Card : null) != (Object)null && attackingSlot.Card.OpponentCard;
		}

		[IteratorStateMachine(typeof(<OnPreSlotAttackSequence>d__4))]
		public IEnumerator OnPreSlotAttackSequence(CardSlot attackingSlot)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnPreSlotAttackSequence>d__4(0)
			{
				<>4__this = this,
				attackingSlot = attackingSlot
			};
		}
	}
	public class AnnoyingTotems : ChallengeBehaviour
	{
		[CompilerGenerated]
		private sealed class <OnPreBattleCleanup>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AnnoyingTotems <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					((ChallengeBehaviour)<>4__this).ShowActivation();
					((Item)<>4__this.totem).Anim.Play("slow_disassemble", 0, 0f);
					<>2__current = (object)new WaitForSeconds(0.333f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Singleton<TableVisualEffectsManager>.Instance.ThumpTable(0.1f);
					((Item)<>4__this.totem).ShowHighlighted(false, true);
					Object.Destroy((Object)(object)((Component)<>4__this.totem).gameObject, 0.7f);
					AudioController.Instance.PlaySound2D("metal_object_up#2", (MixerGroup)4, 1f, 0.25f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
					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 <OnPreBattleSetup>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AnnoyingTotems <>4__this;

			private Tribe <dominantTribe>5__1;

			private GameObject <totemObj>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_0193: Expected O, but got Unknown
				//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c4: Expected O, but got Unknown
				//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d1: Expected O, but got Unknown
				//IL_01d6: Expected O, but got Unknown
				//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0208: Expected O, but got Unknown
				//IL_022e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0238: Expected O, but got Unknown
				//IL_025e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0268: Expected O, but got Unknown
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Invalid comparison between Unknown and I4
				//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ca: Expected O, but got Unknown
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: 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_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: Unknown result type (might be due to invalid IL or missing references)
				//IL_0158: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					<dominantTribe>5__1 = GetRandomMostDominantBasegameTribe();
					if ((int)<dominantTribe>5__1 == 0 || (int)<dominantTribe>5__1 == 7)
					{
						return false;
					}
					((ChallengeBehaviour)<>4__this).ShowActivation();
					<totemObj>5__2 = Object.Instantiate<GameObject>(ResourceBank.Get<GameObject>("Prefabs/Items/CompositeTotem"), ((Component)Singleton<TurnManager>.Instance.opponent).transform);
					<>4__this.totem = <totemObj>5__2.GetComponent<Totem>();
					Transform transform = ((Component)<>4__this.totem).transform;
					transform.position += new Vector3(-1.75f, 0f, 4f);
					Transform transform2 = ((Component)<>4__this.totem).transform;
					transform2.localScale *= 1.45f;
					Transform transform3 = ((Component)<>4__this.totem).transform;
					transform3.eulerAngles += new Vector3(0f, -20f, 0f);
					<>2__current = (object)new WaitForSeconds(0.15f);
					<>1__state = 1;
					return true;
				}
				case 1:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.3f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					((Item)<>4__this.totem).SetData((ItemData)new TotemItemData
					{
						top = new TotemTopData(<dominantTribe>5__1),
						bottom = new TotemBottomData((Ability)76)
					});
					((Item)<>4__this.totem).Anim.Play("slow_assemble", 0, 0f);
					<>2__current = (object)new WaitForSeconds(0.166f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					Singleton<TableVisualEffectsManager>.Instance.ThumpTable(0.1f);
					<>2__current = (object)new WaitForSeconds(0.166f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					Singleton<TableVisualEffectsManager>.Instance.ThumpTable(0.1f);
					<>2__current = (object)new WaitForSeconds(1.418f);
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					Singleton<TableVisualEffectsManager>.Instance.ThumpTable(0.2f);
					AudioController.Instance.PlaySound2D("metal_object_up#2", (MixerGroup)4, 1f, 0.25f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
					if (!DialogueEventsData.EventIsPlayed("LeshyAnnoyingTotem"))
					{
						<>2__current = (object)new WaitForSeconds(0.25f);
						<>1__state = 6;
						return true;
					}
					break;
				case 6:
					<>1__state = -1;
					<>2__current = Singleton<TextDisplayer>.Instance.PlayDialogueEvent("LeshyAnnoyingTotem", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
					<>1__state = 7;
					return true;
				case 7:
					<>1__state = -1;
					break;
				}
				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();
			}
		}

		public Totem totem;

		public override bool RespondsToPreBattleSetup()
		{
			return DeckHasAnyBasegameTribes();
		}

		[IteratorStateMachine(typeof(<OnPreBattleSetup>d__1))]
		public override IEnumerator OnPreBattleSetup()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnPreBattleSetup>d__1(0)
			{
				<>4__this = this
			};
		}

		public override bool RespondsToPreBattleCleanup()
		{
			return (Object)(object)totem != (Object)null;
		}

		[IteratorStateMachine(typeof(<OnPreBattleCleanup>d__3))]
		public override IEnumerator OnPreBattleCleanup()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnPreBattleCleanup>d__3(0)
			{
				<>4__this = this
			};
		}

		public static Tribe GetRandomMostDominantBasegameTribe(int? randomSeed = null)
		{
			//IL_0019: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			List<Tribe> mostDominantBasegameTribes = GetMostDominantBasegameTribes();
			if (mostDominantBasegameTribes.Count <= 0)
			{
				return (Tribe)0;
			}
			if (mostDominantBasegameTribes.Count == 1)
			{
				return mostDominantBasegameTribes[0];
			}
			return mostDominantBasegameTribes[SeededRandom.Range(0, mostDominantBasegameTribes.Count, randomSeed ?? SaveManager.SaveFile.GetCurrentRandomSeed())];
		}

		public static List<Tribe> GetMostDominantBasegameTribes()
		{
			if (!DeckHasAnyBasegameTribes())
			{
				return new List<Tribe>();
			}
			List<Tribe> list = new List<Tribe>();
			int mostUses = GetMostTribeUses();
			list.AddRange(GetTribesAndUsesForCards(RunState.DeckList).ToList().FindAll((KeyValuePair<Tribe, int> x) => (int)x.Key != 0 && (int)x.Key != 7 && x.Value >= mostUses).ConvertAll((KeyValuePair<Tribe, int> x) => x.Key));
			return list;
		}

		public static bool DeckHasAnyBasegameTribes()
		{
			return GetMostTribeUses() > 0;
		}

		public static int GetMostTribeUses()
		{
			return Mathf.Max(GetTribesAndUsesForCards(RunState.DeckList).ToList().FindAll((KeyValuePair<Tribe, int> x) => (int)x.Key != 0 && (int)x.Key != 7).ConvertAll((KeyValuePair<Tribe, int> x) => x.Value)
				.ToArray());
		}

		public static Dictionary<Tribe, int> GetTribesAndUsesForCards(List<CardInfo> cards)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<Tribe, int> dictionary = new Dictionary<Tribe, int>();
			foreach (Tribe value in Enum.GetValues(typeof(Tribe)))
			{
				if ((int)value == 7)
				{
					continue;
				}
				int num = 0;
				if ((int)value == 0)
				{
					foreach (CardInfo card in cards)
					{
						if ((Object)(object)card != (Object)null && card.tribes.Count <= 0)
						{
							num++;
						}
					}
					dictionary.Add(value, num);
					continue;
				}
				foreach (CardInfo card2 in cards)
				{
					if ((Object)(object)card2 != (Object)null && card2.IsOfTribe(value))
					{
						num++;
					}
				}
				dictionary.Add(value, num);
			}
			return dictionary;
		}
	}
	[HarmonyPatch]
	public static class Archived
	{
		public static MethodInfo acc_ccs_pac = AccessTools.Method(typeof(Archived), "ArchiveCardChoices_CardChoicesSequencer_PickArchivedCards", (Type[])null, (Type[])null);

		public static MethodInfo acc_ccs_macc = AccessTools.Method(typeof(Archived), "ArchiveCardChoices_CardChoicesSequencer_MaybeArchiveCurrentCard", (Type[])null, (Type[])null);

		public static Texture2D archivedCardBack = Tools.LoadTexture("archived");

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyILManipulator]
		public static void ArchiveCardChoices_CardChoicesSequencer_Transpiler(ILContext ctx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0038: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(ctx);
			if (val.JumpToNext((Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CardChoicesSequencer>(x, "SpawnCards")))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Call, (MethodBase)acc_ccs_pac);
				if (val.JumpToNext((Instruction x) => ILPatternMatchingExt.MatchStloc(x, 6)))
				{
					val.Emit(OpCodes.Ldarg_0);
					val.Emit(OpCodes.Call, (MethodBase)acc_ccs_macc);
				}
			}
		}

		public static List<SelectableCard> ArchiveCardChoices_CardChoicesSequencer_PickArchivedCards(List<SelectableCard> cards, IEnumerator enumerator)
		{
			//IL_000f: 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)
			if (cards.Count <= 0 || !AscensionSaveData.Data.ChallengeIsActive(Plugin.ArchivedChallenge))
			{
				return cards;
			}
			int numChallengesOfTypeActive = AscensionSaveData.Data.GetNumChallengesOfTypeActive(Plugin.ArchivedChallenge);
			List<SelectableCard> list = cards.ToList();
			int value = enumerator.EnumeratorGetField<int>("randomSeed");
			for (int i = 0; i < numChallengesOfTypeActive; i++)
			{
				if (list.Count <= 0)
				{
					break;
				}
				int index = SeededRandom.Range(0, list.Count, value++);
				SelectableCard c = list[index];
				list.RemoveAt(index);
				((Component)(object)c).AddComponent<ArchiveSelectedCard>();
			}
			enumerator.EnumeratorSetField("randomSeed", value);
			return cards;
		}

		public static void ArchiveCardChoices_CardChoicesSequencer_MaybeArchiveCurrentCard(IEnumerator enumerator)
		{
			SelectableCard val = enumerator.EnumeratorGetField<object>("1").EnumeratorGetField<SelectableCard>("card");
			if (Object.op_Implicit((Object)(object)((Component)val).GetComponent<ArchiveSelectedCard>()))
			{
				val.Flipped = true;
				((Card)val).SetFaceDown(true, true);
				val.flippedBackTexture = (Texture)(object)archivedCardBack;
			}
		}
	}
	public class ArchiveSelectedCard : MonoBehaviour
	{
	}
	public class DanceParty : ChallengeBehaviour
	{
		[CompilerGenerated]
		private sealed class <OnUpkeep>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public bool playerUpkeep;

			public DanceParty <>4__this;

			private List<CardSlot> <slots>5__1;

			private List<CardSlot>.Enumerator <>s__2;

			private CardSlot <slot>5__3;

			private CardSlot <target>5__4;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 2) <= 2u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<slots>5__1 = null;
				<slot>5__3 = null;
				<target>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
						<>2__current = (object)new WaitForSeconds(0.25f);
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						<slots>5__1 = Singleton<BoardManager>.Instance.PlayerSlotsCopy;
						((ChallengeBehaviour)<>4__this).ShowActivation();
						if (!<>4__this.moveLeft)
						{
							<slots>5__1.Reverse();
						}
						<>s__2 = <slots>5__1.GetEnumerator();
						<>1__state = -3;
						goto IL_0212;
					case 2:
						<>1__state = -3;
						goto IL_0202;
					case 3:
						<>1__state = -3;
						<>2__current = Singleton<TextDisplayer>.Instance.PlayDialogueEvent("DancePartyDie", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
						<>1__state = 4;
						return true;
					case 4:
						{
							<>1__state = -3;
							goto IL_0202;
						}
						IL_0202:
						<target>5__4 = null;
						goto IL_020a;
						IL_020a:
						<slot>5__3 = null;
						goto IL_0212;
						IL_0212:
						if (<>s__2.MoveNext())
						{
							<slot>5__3 = <>s__2.Current;
							CardSlot obj = <slot>5__3;
							if ((Object)(object)((obj != null) ? obj.Card : null) != (Object)null)
							{
								<target>5__4 = Singleton<BoardManager>.Instance.GetAdjacent(<slot>5__3, <>4__this.moveLeft);
								if ((Object)(object)<target>5__4 != (Object)null && ((Object)(object)<target>5__4.Card == (Object)null || <target>5__4.Card.Dead))
								{
									<>2__current = Singleton<BoardManager>.Instance.AssignCardToSlot(<slot>5__3.Card, <target>5__4, 0.1f, (Action)null, true);
									<>1__state = 2;
									return true;
								}
								<>2__current = <slot>5__3.Card.Die(false, (PlayableCard)null, true);
								<>1__state = 3;
								return true;
							}
							goto IL_020a;
						}
						<>m__Finally1();
						<>4__this.moveLeft = !<>4__this.moveLeft;
						return false;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>s__2).Dispose();
			}

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

		public bool moveLeft;

		public override bool RespondsToUpkeep(bool playerUpkeep)
		{
			return playerUpkeep && Singleton<TurnManager>.Instance.TurnNumber > 1;
		}

		[IteratorStateMachine(typeof(<OnUpkeep>d__1))]
		public override IEnumerator OnUpkeep(bool playerUpkeep)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnUpkeep>d__1(0)
			{
				<>4__this = this,
				playerUpkeep = playerUpkeep
			};
		}
	}
	[HarmonyPatch]
	public static class Dentistry
	{
		public static MethodInfo sa_tb_s = AccessTools.Method(typeof(Dentistry), "ShowActivation_TrinketBearer_Show", (Type[])null, (Type[])null);

		public const string PliersId = "Pliers";

		[HarmonyPatch(typeof(ItemsUtil), "GetUnlockedConsumables")]
		[HarmonyPrefix]
		public static bool OverrideConsumables_Unlocked_Prefix(ref List<ConsumableItemData> __result)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!AscensionSaveData.Data.ChallengeIsActive(Plugin.DentistryChallenge))
			{
				return true;
			}
			__result = new List<ConsumableItemData>(1) { ItemsUtil.GetConsumableByName("Pliers") };
			return false;
		}

		[HarmonyPatch(typeof(GainConsumablesSequencer), "GenerateItemChoices")]
		[HarmonyPrefix]
		public static bool OverrideConsumables_ItemNode_Prefix(ref List<ConsumableItemData> __result)
		{
			//IL_0006: 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)
			if (!AscensionSaveData.Data.ChallengeIsActive(Plugin.DentistryChallenge))
			{
				return true;
			}
			ChallengeActivationUI.TryShowActivation(Plugin.DentistryChallenge);
			ConsumableItemData consumableByName = ItemsUtil.GetConsumableByName("Pliers");
			__result = new List<ConsumableItemData>(3) { consumableByName, consumableByName, consumableByName };
			return false;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyILManipulator]
		public static void ShowActivation_TrinketBearer_Transpiler(ILContext ctx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(ctx);
			ILLabel val2 = default(ILLabel);
			if (val.JumpToNext((Instruction x) => ILPatternMatchingExt.MatchBge(x, ref val2)))
			{
				val.Emit(OpCodes.Call, (MethodBase)sa_tb_s);
			}
		}

		public static void ShowActivation_TrinketBearer_Show()
		{
			//IL_0006: 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)
			if (AscensionSaveData.Data.ChallengeIsActive(Plugin.DentistryChallenge))
			{
				ChallengeActivationUI.TryShowActivation(Plugin.DentistryChallenge);
			}
		}
	}
	public class Dogfish : ChallengeBehaviour
	{
		[CompilerGenerated]
		private sealed class <OnOtherCardDie>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PlayableCard card;

			public CardSlot deathSlot;

			public bool fromCombat;

			public PlayableCard killer;

			public Dogfish <>4__this;

			private CardInfo <shark>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Expected O, but got Unknown
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Expected O, but got Unknown
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<shark>5__1 = CardLoader.GetCardByName("Shark");
					((ChallengeBehaviour)<>4__this).ShowActivation();
					<>2__current = Singleton<BoardManager>.Instance.CreateCardInSlot(<shark>5__1, deathSlot, 0.1f, true);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.25f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					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 <OnPostBattleSetup>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Dogfish <>4__this;

			private List<CardSlot> <emptySlots>5__1;

			private CardSlot <randomSlot>5__2;

			private CardInfo <card>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<emptySlots>5__1 = null;
				<randomSlot>5__2 = null;
				<card>5__3 = null;
				<>1__s