Decompiled source of P03 Sigilarium v1.1.10

Infiniscryption.P03SigilLibrary.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DigitalRuby.LightningBolt;
using DiskCardGame;
using GBC;
using HarmonyLib;
using Infiniscryption.P03SigilLibrary.Helpers;
using Infiniscryption.P03SigilLibrary.Sigils;
using Infiniscryption.Spells.Patchers;
using Infiniscryption.Spells.Sigils;
using InscryptionAPI.Card;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.Resource;
using InscryptionAPI.RuleBook;
using InscryptionAPI.Saves;
using InscryptionAPI.Slots;
using InscryptionAPI.Sound;
using InscryptionAPI.Triggers;
using InscryptionCommunityPatch.Card;
using Pixelplacement;
using Sirenix.Serialization.Utilities;
using Sirenix.Utilities;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[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 = "")]
[assembly: AssemblyCompany("Infiniscryption.P03SigilLibrary")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("P03 Sigil Library")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Infiniscryption.P03SigilLibrary")]
[assembly: AssemblyTitle("Infiniscryption.P03SigilLibrary")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Infiniscryption.P03KayceeRun.Cards
{
	public class ConduitSpawnUrchin : ConduitSpawn
	{
		public override Ability Ability => AbilityID;

		public static Ability AbilityID { get; private set; }

		static ConduitSpawnUrchin()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Urchin Spawn Conduit";
			val.rulebookDescription = "Empty spaces within a circuit completed by [creature] spawn Urchin Cells at the end of the owner's turn.";
			val.canStack = true;
			val.powerLevel = 3;
			val.opponentUsable = false;
			val.passive = false;
			val.conduit = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ConduitSpawnUrchin), (Texture)(object)TextureHelper.GetImageAsTexture("ability_conduit_urchin.png", typeof(ConduitSpawnUrchin).Assembly, (FilterMode)0)).Id;
		}

		public override string GetSpawnCardId()
		{
			return "P03SIG_UrchinCell";
		}
	}
}
namespace Infiniscryption.P03SigilLibrary
{
	public static class AbilityDocumentation
	{
		public class AbilityDocInfo
		{
			public AbilityInfo info { get; set; }

			public string imageB64 { get; set; }

			public Type behaviour { get; set; }
		}

		public const string ROOT_PATH = "https://github.com/Cosmiscient/P03KayceeMod-Main/blob/main/P03SigilLibrary/assets/";

		private static List<AbilityDocInfo> AllAbilities = new List<AbilityDocInfo>();

		public static void CaptureAbilityInfoForDocumentation(string guid, AbilityInfo info, Type behavior, Texture tex)
		{
			if (guid.Equals("zorro.inscryption.infiniscryption.p03sigillibrary"))
			{
				try
				{
					AllAbilities.Add(new AbilityDocInfo
					{
						info = info,
						behaviour = behavior,
						imageB64 = Convert.ToBase64String(ImageConversion.EncodeToPNG((Texture2D)(object)((tex is Texture2D) ? tex : null)))
					});
				}
				catch
				{
					AllAbilities.Add(new AbilityDocInfo
					{
						info = info,
						behaviour = behavior,
						imageB64 = Convert.ToBase64String(ImageConversion.EncodeToPNG(TextureHelper.DuplicateTexture((Texture2D)(object)((tex is Texture2D) ? tex : null))))
					});
				}
			}
		}

		internal static void GenerateDocumentation()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			string text = "|Icon|Name|Rulebook Description|\n";
			text += "|---|---|---|---|\n";
			foreach (AbilityDocInfo item in AllAbilities.OrderBy((AbilityDocInfo adi) => adi.info.rulebookName))
			{
				FullAbility val = AbilityExtensions.AbilityByID((IEnumerable<FullAbility>)AbilityManager.AllAbilities, item.info.ability);
				text = text + "|[[https://github.com/Cosmiscient/P03KayceeMod-Main/blob/main/P03SigilLibrary/assets/" + ((Object)val.Texture).name + ".png]]";
				text = text + "|" + item.info.rulebookName;
				text = text + "|" + item.info.rulebookDescription;
				text += "|\n";
			}
			if (!Directory.Exists("cardexports"))
			{
				Directory.CreateDirectory("cardexports");
			}
			File.WriteAllText("cardexports/sigil_library.md", text);
		}
	}
	[HarmonyPatch]
	internal static class BugFixes
	{
		[HarmonyPatch(typeof(ItemsUtil), "GetRandomUnlockedConsumable")]
		private static bool AccountForMultipleActs(int randomSeed, ref ConsumableItemData __result)
		{
			//IL_0036: 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)
			AbilityMetaCategory cat = (AbilityMetaCategory)((!SaveManager.SaveFile.IsPart1) ? ((!SaveManager.SaveFile.IsPart3) ? (SaveManager.SaveFile.IsGrimora ? 5 : 6) : 0) : 0);
			List<ConsumableItemData> list = (((int)cat == 0) ? ItemsUtil.GetUnlockedConsumables() : new List<ConsumableItemData>(ItemsUtil.AllConsumables));
			if (list.Any((ConsumableItemData cid) => !cid.notRandomlyGiven))
			{
				list.RemoveAll((ConsumableItemData cid) => cid.notRandomlyGiven);
			}
			if (list.Any((ConsumableItemData cid) => cid.rulebookCategory == cat))
			{
				list.RemoveAll((ConsumableItemData cid) => cid.rulebookCategory != cat);
			}
			__result = list[SeededRandom.Range(0, list.Count, randomSeed)];
			return false;
		}

		[HarmonyPatch(typeof(PlayableCard), "AddTemporaryMod")]
		[HarmonyPrefix]
		[HarmonyPriority(700)]
		private static void ProperlyRemoveSingletonTempMods(PlayableCard __instance, CardModificationInfo mod)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(mod.singletonId))
			{
				return;
			}
			CardModificationInfo val = __instance.temporaryMods.Find((CardModificationInfo x) => string.Equals(x.singletonId, mod.singletonId));
			if (val == null)
			{
				return;
			}
			__instance.temporaryMods.Remove(val);
			foreach (Ability ability in val.abilities)
			{
				__instance.TriggerHandler.RemoveAbility(ability);
			}
		}

		[HarmonyPatch(typeof(CardDisplayer3D), "DisplayInfo")]
		[HarmonyPrefix]
		private static void AlwaysClearThePrefabPortrait(CardDisplayer3D __instance, PlayableCard playableCard)
		{
			if (!((Object)(object)playableCard != (Object)null))
			{
				return;
			}
			CardInfo info = ((CardDisplayer)__instance).info;
			if (((info != null) ? new bool?(info.HasAbility((Ability)61)) : null).GetValueOrDefault(false) && ((Object)(object)((CardDisplayer)__instance).info.animatedPortrait != (Object)null || (Object)(object)((CardDisplayer)__instance).info.evolveParams?.evolution?.animatedPortrait != (Object)null))
			{
				if ((Object)(object)__instance.instantiatedPortraitObj != (Object)null)
				{
					Object.Destroy((Object)(object)__instance.instantiatedPortraitObj);
				}
				__instance.portraitPrefab = null;
			}
		}

		[HarmonyPatch(typeof(Card), "SetInfo")]
		[HarmonyPrefix]
		private static void RemoveApperanceBehavioursBeforeSettingInfo(Card __instance, CardInfo info)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			if (!((Object)(object)__instance.Info != (Object)null) || ((Object)__instance.Info).name.Equals(((Object)info).name))
			{
				return;
			}
			foreach (Appearance item2 in __instance.Info.appearanceBehaviour)
			{
				Appearance current = item2;
				Type type = CustomType.GetType("DiskCardGame", ((object)(Appearance)(ref current)).ToString());
				Component component = ((Component)__instance).gameObject.GetComponent(type);
				if ((Object)(object)component != (Object)null)
				{
					CardAppearanceBehaviour val = (CardAppearanceBehaviour)(object)((component is CardAppearanceBehaviour) ? component : null);
					if (val != null)
					{
						val.ResetAppearance();
					}
					Object.DestroyImmediate((Object)(object)component);
				}
			}
			CardAnimationController anim = __instance.Anim;
			DiskCardAnimationController val2 = (DiskCardAnimationController)(object)((anim is DiskCardAnimationController) ? anim : null);
			if (val2 != null && (Object)(object)val2.holoPortraitParent != (Object)null)
			{
				List<Transform> list = new List<Transform>();
				foreach (Transform item3 in val2.holoPortraitParent)
				{
					Transform item = item3;
					list.Add(item);
				}
				foreach (Transform item4 in list)
				{
					Object.DestroyImmediate((Object)(object)((Component)item4).gameObject);
				}
				((Component)val2.holoPortraitParent).gameObject.SetActive(false);
			}
			CardRenderCamera instance = Singleton<CardRenderCamera>.Instance;
			if (instance != null)
			{
				instance.StopLiveRenderCard(__instance.StatsLayer);
			}
		}

		[HarmonyPatch(typeof(LifeManager), "ShowDamageSequence")]
		[HarmonyPostfix]
		private static IEnumerator ShowDamageSequenceSkipIfLifeLossConditionMet(IEnumerator sequence)
		{
			if (!Singleton<TurnManager>.Instance.LifeLossConditionsMet())
			{
				yield return sequence;
			}
		}

		[HarmonyPatch(typeof(CardAbilityIcons), "SetIconFlipped")]
		[HarmonyPostfix]
		private static void FlipLatchedAbility(ref CardAbilityIcons __instance, Ability ability, bool flipped)
		{
			//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)
			if ((Object)(object)__instance.latchIcon != (Object)null && __instance.latchIcon.Ability == ability)
			{
				__instance.latchIcon.SetFlippedX(flipped);
			}
		}

		[HarmonyPatch(typeof(CombatPhaseManager), "SlotAttackSlot")]
		[HarmonyPrefix]
		[HarmonyBefore(new string[] { "ATS" })]
		private static bool StopSequenceIfAttackerIsNull(CardSlot attackingSlot)
		{
			return (Object)(object)attackingSlot != (Object)null;
		}

		[HarmonyPatch(typeof(PlayableCard), "GetPassiveAttackBuffs")]
		[HarmonyPostfix]
		private static void GemifyBuffWithTempMods(PlayableCard __instance, ref int __result)
		{
			if (!CardExtensions.IsGemified(__instance) || ((Card)__instance).Info.Gemified)
			{
				return;
			}
			if (__instance.OpponentCard)
			{
				OpponentGemsManager instance = Singleton<OpponentGemsManager>.Instance;
				if (((instance != null) ? new bool?(instance.HasGem((GemType)1)) : null).GetValueOrDefault())
				{
					__result++;
				}
			}
			else
			{
				ResourcesManager instance2 = Singleton<ResourcesManager>.Instance;
				if (((instance2 != null) ? new bool?(instance2.HasGem((GemType)1)) : null).GetValueOrDefault())
				{
					__result++;
				}
			}
		}

		[HarmonyPatch(typeof(PlayableCard), "GetPassiveHealthBuffs")]
		[HarmonyPostfix]
		private static void GemifyHealthBuffWithTempMods(PlayableCard __instance, ref int __result)
		{
			if (!CardExtensions.IsGemified(__instance) || ((Card)__instance).Info.Gemified)
			{
				return;
			}
			if (__instance.OpponentCard)
			{
				OpponentGemsManager instance = Singleton<OpponentGemsManager>.Instance;
				if (((instance != null) ? new bool?(instance.HasGem((GemType)0)) : null).GetValueOrDefault())
				{
					__result += 2;
				}
			}
			else
			{
				ResourcesManager instance2 = Singleton<ResourcesManager>.Instance;
				if (((instance2 != null) ? new bool?(instance2.HasGem((GemType)0)) : null).GetValueOrDefault())
				{
					__result += 2;
				}
			}
		}

		[HarmonyPatch(typeof(RenderStatsLayer), "RenderCard")]
		[HarmonyPrefix]
		private static void AllowGemifyToWorkWithTempMods(ref RenderStatsLayer __instance, CardRenderInfo info)
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			RenderStatsLayer obj = __instance;
			DiskRenderStatsLayer val = (DiskRenderStatsLayer)(object)((obj is DiskRenderStatsLayer) ? obj : null);
			if (val == null)
			{
				return;
			}
			PlayableCard playableCard = __instance.PlayableCard;
			if ((Object)(object)playableCard == (Object)null || !CardExtensions.IsGemified(playableCard))
			{
				return;
			}
			val.gemSquares.ForEach(delegate(GameObject o)
			{
				o.SetActive(true);
			});
			if (playableCard.OpponentCard)
			{
				OpponentGemsManager instance = Singleton<OpponentGemsManager>.Instance;
				if (((instance != null) ? new bool?(instance.HasGem((GemType)1)) : null).GetValueOrDefault())
				{
					info.attackTextColor = GameColors.Instance.gold;
				}
				OpponentGemsManager instance2 = Singleton<OpponentGemsManager>.Instance;
				if (((instance2 != null) ? new bool?(instance2.HasGem((GemType)0)) : null).GetValueOrDefault())
				{
					info.attackTextColor = GameColors.Instance.brightLimeGreen;
				}
			}
			else
			{
				if (Singleton<ResourcesManager>.Instance.HasGem((GemType)1))
				{
					info.attackTextColor = GameColors.Instance.gold;
				}
				if (Singleton<ResourcesManager>.Instance.HasGem((GemType)0))
				{
					info.attackTextColor = GameColors.Instance.brightLimeGreen;
				}
			}
		}

		[HarmonyPatch(typeof(BoardStateEvaluator), "EvaluateBoardState")]
		[HarmonyPostfix]
		private static void FixCellEvaluation(BoardState state, ref int __result)
		{
			if (!SaveFile.IsAscension)
			{
				return;
			}
			foreach (SlotState opponentSlot in state.opponentSlots)
			{
				if (opponentSlot.card != null && opponentSlot.card.info.HasCellAbility())
				{
					float num = (float)(state.opponentSlots.Count - 1) / 2f;
					float num2 = Mathf.Abs(num - (float)state.opponentSlots.IndexOf(opponentSlot));
					__result -= 2 * Mathf.RoundToInt(num - num2);
				}
			}
		}
	}
	internal static class Cards
	{
		static Cards()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected I4, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected I4, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected I4, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected I4, but got Unknown
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Expected I4, but got Unknown
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Expected I4, but got Unknown
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Expected I4, but got Unknown
			CardInfo obj = CardExtensions.SetPortrait(CardManager.New("P03SIG", "UrchinCell", "Urch1n Cell", 0, 1, (string)null), TextureHelper.GetImageAsTexture("portrait_urchin_cell.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null);
			int? num = 2;
			CardExtensions.AddAbilities(CardExtensions.SetCardTemple(CardExtensions.SetCost(obj, (int?)0, (int?)0, num, (List<GemType>)null), (CardTemple)2), (Ability[])(object)new Ability[2]
			{
				(Ability)15,
				(Ability)(int)CellDeSubmerge.AbilityID
			});
			CardInfo obj2 = CardExtensions.SetPortrait(CardManager.New("P03SIG", "CHARGE", "Charge!", 0, 0, (string)null), TextureHelper.GetImageAsTexture("portrait_charge.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null);
			num = 0;
			CardExtensions.AddAbilities(CardHelpers.SetInstaGlobalSpell(CardExtensions.SetCost(obj2, (int?)0, (int?)0, num, (List<GemType>)null)), (Ability[])(object)new Ability[1] { (Ability)(int)RefillBattery.AbilityID });
			CardInfo obj3 = CardExtensions.SetPortrait(CardManager.New("P03SIG", "FORCED_UPGRADE", "Upgrade!", 0, 0, (string)null), TextureHelper.GetImageAsTexture("portrait_forced_upgrade.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null);
			num = 2;
			CardExtensions.AddAbilities(CardHelpers.SetTargetedSpell(CardExtensions.SetCost(obj3, (int?)0, (int?)0, num, (List<GemType>)null)), (Ability[])(object)new Ability[1] { (Ability)(int)ForcedUpgrade.AbilityID });
			CardInfo obj4 = CardExtensions.SetPortrait(CardManager.New("P03SIG", "ZAP", "Zap!", 0, 0, (string)null), TextureHelper.GetImageAsTexture("portrait_zap.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null);
			num = 2;
			CardExtensions.AddAbilities(CardHelpers.SetTargetedSpell(CardExtensions.SetCost(obj4, (int?)0, (int?)0, num, (List<GemType>)null)), (Ability[])(object)new Ability[1] { (Ability)(int)Zap.AbilityID });
			CardInfo obj5 = CardExtensions.SetPortrait(CardManager.New("P03SIG", "BLAST", "Blast!", 0, 0, (string)null), TextureHelper.GetImageAsTexture("portrait_blast.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null);
			num = 2;
			CardExtensions.AddAbilities(CardHelpers.SetTargetedSpell(CardExtensions.SetCost(obj5, (int?)0, (int?)0, num, (List<GemType>)null)), (Ability[])(object)new Ability[1] { (Ability)(int)CatchFire.AbilityID });
			CardInfo obj6 = CardExtensions.SetPortrait(CardManager.New("P03SIG", "DEFEND", "Defend!", 0, 0, (string)null), TextureHelper.GetImageAsTexture("portrait_defend.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null);
			num = 2;
			CardExtensions.AddAbilities(CardHelpers.SetTargetedSpell(CardExtensions.SetCost(obj6, (int?)0, (int?)0, num, (List<GemType>)null)), (Ability[])(object)new Ability[1] { (Ability)(int)GainShield.AbilityID });
			CardInfo obj7 = CardExtensions.SetPortrait(CardManager.New("P03SIG", "EMPTY_PILE_OF_SCRAP", "Junk", 0, 1, (string)null), TextureHelper.GetImageAsTexture("portrait_scrappile.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null);
			num = 1;
			CardExtensions.SetCardTemple(CardExtensions.SetCost(obj7, (int?)0, (int?)0, num, (List<GemType>)null), (CardTemple)2);
			CardInfo obj8 = CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("P03SIG", "Salmon", "S4LM0N", 0, 1, (string)null), TextureHelper.GetImageAsTexture("portrait_salmon.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null), TextureHelper.GetImageAsTexture("pixelportrait_salmon.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null);
			num = 1;
			CardExtensions.SetEvolve(CardExtensions.SetCardTemple(CardExtensions.SetCost(obj8, (int?)0, (int?)0, num, (List<GemType>)null), (CardTemple)2), "Angler_Fish_More", 1, (IEnumerable<CardModificationInfo>)null);
			CardExtensions.SetEvolve(CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.BaseGameCards, "Angler_Fish_More"), "Angler_Fish_Good", 1, (IEnumerable<CardModificationInfo>)null);
			CardInfo obj9 = CardExtensions.SetPortrait(CardManager.New("P03SIG", "SEED", "Seed", 0, 1, (string)null), TextureHelper.GetImageAsTexture("portrait_seed.png", typeof(Cards).Assembly, (FilterMode)0), (FilterMode?)null);
			num = 1;
			CardExtensions.AddSpecialAbilities(CardExtensions.SetCardTemple(CardExtensions.SetCost(obj9, (int?)0, (int?)0, num, (List<GemType>)null), (CardTemple)2), (SpecialTriggeredAbility[])(object)new SpecialTriggeredAbility[1] { (SpecialTriggeredAbility)(int)SeedBehaviour.AbilityID });
			CardManager.ModifyCardList += delegate(List<CardInfo> cards)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Expected I4, but got Unknown
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected I4, but got Unknown
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Expected I4, but got Unknown
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Expected I4, but got Unknown
				CardExtensions.AddMetaCategories(CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "CXformerWolf"), (CardMetaCategory[])(object)new CardMetaCategory[1] { (CardMetaCategory)(int)SummonFamiliar.BeastFamiliars });
				CardExtensions.AddMetaCategories(CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "CXformerElk"), (CardMetaCategory[])(object)new CardMetaCategory[1] { (CardMetaCategory)(int)SummonFamiliar.BeastFamiliars });
				CardExtensions.AddMetaCategories(CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "CXformerRaven"), (CardMetaCategory[])(object)new CardMetaCategory[1] { (CardMetaCategory)(int)SummonFamiliar.BeastFamiliars });
				CardExtensions.AddMetaCategories(CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "CXformerAdder"), (CardMetaCategory[])(object)new CardMetaCategory[1] { (CardMetaCategory)(int)SummonFamiliar.BeastFamiliars });
				return cards;
			};
		}
	}
	[BepInPlugin("zorro.inscryption.infiniscryption.p03sigillibrary", "Infiniscryption P03 in Kaycee's Mod - Sigil Library", "1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class P03SigilLibraryPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "zorro.inscryption.infiniscryption.p03sigillibrary";

		public const string PluginName = "Infiniscryption P03 in Kaycee's Mod - Sigil Library";

		public const string PluginVersion = "1.0";

		public const string CardPrefix = "P03SIG";

		internal static P03SigilLibraryPlugin Instance;

		internal static ManualLogSource Log;

		internal static bool Initialized;

		public static int RandomSeed
		{
			get
			{
				int num = ((AscensionSaveData.Data != null) ? AscensionSaveData.Data.currentRunSeed : 0);
				try
				{
					int num2 = num;
					TurnManager instance = Singleton<TurnManager>.Instance;
					num = num2 + 10 * ((instance == null) ? 1 : instance.TurnNumber);
					int num3 = num;
					LifeManager instance2 = Singleton<LifeManager>.Instance;
					num = num3 + 100 * ((instance2 == null) ? 1 : instance2.OpponentDamage);
					int num4 = num;
					LifeManager instance3 = Singleton<LifeManager>.Instance;
					num = num4 + 1000 * ((instance3 == null) ? 1 : instance3.PlayerDamage);
					int num5 = num;
					TurnManager instance4 = Singleton<TurnManager>.Instance;
					num = num5 + ((instance4 == null || instance4.IsPlayerTurn) ? 55 : 121);
					if (Part3SaveData.Data != null && Part3SaveData.Data.deck != null && Part3SaveData.Data.deck.cardIdModInfos != null)
					{
						num += 10000 * Part3SaveData.Data.deck.cardIdModInfos.Select((KeyValuePair<string, List<CardModificationInfo>> kvp) => (kvp.Value?.Count).GetValueOrDefault(0)).Sum();
					}
					num += ((Part3SaveData.Data != null && Part3SaveData.Data.playerPos != null) ? Part3SaveData.Data.playerPos.gridX : 0);
					num += ((Part3SaveData.Data != null && Part3SaveData.Data.playerPos != null) ? (100000 * Part3SaveData.Data.playerPos.gridY) : 0);
					int num6 = num;
					BoardManager instance5 = Singleton<BoardManager>.Instance;
					num = num6 + 11111 * ((instance5 != null) ? instance5.PlayerSlotsCopy[0].Index : 2);
					return num;
				}
				catch
				{
					return num;
				}
			}
		}

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("zorro.inscryption.infiniscryption.p03sigillibrary");
			MethodInfo method = typeof(AbilityManager).GetMethod("Add", BindingFlags.Static | BindingFlags.Public);
			MethodInfo method2 = typeof(AbilityDocumentation).GetMethod("CaptureAbilityInfoForDocumentation", BindingFlags.Static | BindingFlags.Public);
			((BaseUnityPlugin)this).Logger.LogDebug((object)$"Deck editor fixer: Target Method {method}, Patch method {method2}");
			val.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.PatchAll();
			CustomTriggerPatches.SpecialPatchDamageTrigger(val);
			Type[] types = typeof(P03SigilLibraryPlugin).Assembly.GetTypes();
			foreach (Type type in types)
			{
				try
				{
					RuntimeHelpers.RunClassConstructor(type.TypeHandle);
				}
				catch (TypeLoadException ex)
				{
					Log.LogWarning((object)"Failed to force load static constructor!");
					Log.LogWarning((object)ex);
				}
			}
			SceneManager.sceneLoaded += OnSceneLoaded;
			Initialized = true;
			AbilityDocumentation.GenerateDocumentation();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Infiniscryption P03 in Kaycee's Mod - Sigil Library is loaded and ready for action!");
		}

		private void OnDestroy()
		{
			AudioHelper.FlushAudioClipCache();
			AssetBundleManager.CleanUp();
		}

		public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			CardManager.SyncCardList();
			AbilityManager.SyncAbilityList();
			RuleBookManager.SyncRuleBookList();
		}
	}
}
namespace Infiniscryption.P03SigilLibrary.Sigils
{
	[HarmonyPatch]
	public static class AbilityIconBehaviours
	{
		public const string CELL_INVERSE = "InverseCell";

		public const string ORANGE_CELL = "FromOrange";

		public const string GREEN_CELL = "FromGreen";

		public const string BLUE_CELL = "FromBlue";

		public const string GEM_CELL = "FromGem";

		public const string ORANGE_CELL_INVERSE = "FromOrangeInverse";

		public const string GREEN_CELL_INVERSE = "FromEmeraldInverse";

		public const string BLUE_CELL_INVERSE = "FromSapphireInverse";

		public const string GEM_CELL_INVERSE = "FromGemInverse";

		public const string ACTIVE_WHEN_FUELED = "ActiveWhenFueled";

		private static readonly List<Appearance> GemReRenderAppearances = new List<Appearance>();

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

		private static Ability[] _gemReRenderAbilities;

		private static Ability[] GemReRenderAbilities
		{
			get
			{
				if (_gemReRenderAbilities == null)
				{
					_gemReRenderAbilities = (from ai in AbilityManager.AllAbilityInfos
						where ai.IsGemReRender()
						select ai.ability).ToArray();
				}
				return _gemReRenderAbilities;
			}
		}

		public static void AddGemReRenderAppearance(Appearance id)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GemReRenderAppearances.Add(id);
		}

		public static bool IsGemReRender(this AbilityInfo info)
		{
			return AbilityExtensions.GetExtendedPropertyAsBool(info, "FromOrange").GetValueOrDefault() || AbilityExtensions.GetExtendedPropertyAsBool(info, "FromGreen").GetValueOrDefault() || AbilityExtensions.GetExtendedPropertyAsBool(info, "FromBlue").GetValueOrDefault() || AbilityExtensions.GetExtendedPropertyAsBool(info, "FromGem").GetValueOrDefault() || AbilityExtensions.GetExtendedPropertyAsBool(info, "FromOrangeInverse").GetValueOrDefault() || AbilityExtensions.GetExtendedPropertyAsBool(info, "FromEmeraldInverse").GetValueOrDefault() || AbilityExtensions.GetExtendedPropertyAsBool(info, "FromSapphireInverse").GetValueOrDefault() || AbilityExtensions.GetExtendedPropertyAsBool(info, "FromGemInverse").GetValueOrDefault();
		}

		[HarmonyPatch(typeof(CardAbilityIcons), "SetColorOfDefaultIcons")]
		[HarmonyPostfix]
		private static void HandleAllColorationOfAbilities(ref CardAbilityIcons __instance, Color color, bool inConduitCircuit)
		{
			//IL_005c: 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_00ac: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			if (!SaveManager.SaveFile.IsPart3)
			{
				return;
			}
			List<GameObject> defaultIconGroups = __instance.defaultIconGroups;
			foreach (GameObject item in defaultIconGroups)
			{
				if (!item.activeSelf)
				{
					continue;
				}
				AbilityIconInteractable[] componentsInChildren = item.GetComponentsInChildren<AbilityIconInteractable>();
				foreach (AbilityIconInteractable val in componentsInChildren)
				{
					AbilityInfo info = AbilitiesUtil.GetInfo(val.Ability);
					if (info.activated)
					{
						val.SetColor(Color.white);
					}
					else if (AbilityExtensions.GetExtendedPropertyAsBool(info, "InverseCell").GetValueOrDefault())
					{
						val.SetColor(inConduitCircuit ? info.colorOverride : color);
					}
					else if (info.conduitCell)
					{
						val.SetColor((!inConduitCircuit) ? info.colorOverride : color);
					}
					else if (info.hasColorOverride)
					{
						val.SetColor(info.colorOverride);
					}
				}
			}
		}

		[HarmonyPatch(typeof(CardDisplayer3D), "DisplayAbilityIcons")]
		[HarmonyPostfix]
		private static void RecolorGemIcons(CardDisplayer3D __instance, PlayableCard playableCard, CardRenderInfo renderInfo)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			if (!SaveManager.SaveFile.IsPart3)
			{
				return;
			}
			List<GameObject> defaultIconGroups = __instance.AbilityIcons.defaultIconGroups;
			foreach (GameObject item in defaultIconGroups)
			{
				if (!item.activeSelf)
				{
					continue;
				}
				AbilityIconInteractable[] componentsInChildren = item.GetComponentsInChildren<AbilityIconInteractable>();
				foreach (AbilityIconInteractable val in componentsInChildren)
				{
					AbilityInfo info = AbilitiesUtil.GetInfo(val.Ability);
					if (AbilityExtensions.GetExtendedPropertyAsBool(info, "FromGreen").GetValueOrDefault())
					{
						val.SetColor((!playableCard.EligibleForGemBonus((GemType)0)) ? info.colorOverride : renderInfo.defaultAbilityColor);
					}
					else if (AbilityExtensions.GetExtendedPropertyAsBool(info, "FromOrange").GetValueOrDefault())
					{
						val.SetColor((!playableCard.EligibleForGemBonus((GemType)1)) ? info.colorOverride : renderInfo.defaultAbilityColor);
					}
					else if (AbilityExtensions.GetExtendedPropertyAsBool(info, "FromBlue").GetValueOrDefault())
					{
						val.SetColor((!playableCard.EligibleForGemBonus((GemType)2)) ? info.colorOverride : renderInfo.defaultAbilityColor);
					}
					else if (AbilityExtensions.GetExtendedPropertyAsBool(info, "FromEmeraldInverse").GetValueOrDefault())
					{
						val.SetColor(playableCard.EligibleForGemBonus((GemType)0) ? info.colorOverride : renderInfo.defaultAbilityColor);
					}
					else if (AbilityExtensions.GetExtendedPropertyAsBool(info, "FromOrangeInverse").GetValueOrDefault())
					{
						val.SetColor(playableCard.EligibleForGemBonus((GemType)1) ? info.colorOverride : renderInfo.defaultAbilityColor);
					}
					else if (AbilityExtensions.GetExtendedPropertyAsBool(info, "FromSapphireInverse").GetValueOrDefault())
					{
						val.SetColor(playableCard.EligibleForGemBonus((GemType)2) ? info.colorOverride : renderInfo.defaultAbilityColor);
					}
					else if (AbilityExtensions.GetExtendedPropertyAsBool(info, "ActiveWhenFueled").GetValueOrDefault())
					{
						val.SetColor((((Card)(object)playableCard).GetCurrentFuel().GetValueOrDefault() <= 0) ? info.colorOverride : renderInfo.defaultAbilityColor);
					}
				}
			}
		}

		[HarmonyPatch(typeof(CardDisplayer3D), "DisplayAbilityIcons")]
		[HarmonyPostfix]
		private static void ColorizeConduitAbilities(CardDisplayer3D __instance, PlayableCard playableCard)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			if (!SaveManager.SaveFile.IsPart3 || (Object)(object)__instance.AbilityIcons == (Object)null || (Object)(object)playableCard == (Object)null || playableCard.TemporaryMods == null)
			{
				return;
			}
			foreach (CardModificationInfo temporaryMod in playableCard.TemporaryMods)
			{
				if (temporaryMod == null || string.IsNullOrEmpty(temporaryMod.singletonId) || temporaryMod.abilities == null || !DynamicAbilityCardModIds.Contains(temporaryMod.singletonId))
				{
					continue;
				}
				foreach (Ability ability in temporaryMod.abilities)
				{
					if (!((Card)playableCard).Info.HasAbility(ability))
					{
						AbilityIconInteractable? obj = __instance.AbilityIcons.abilityIcons.Find((AbilityIconInteractable a) => a.Ability == ability);
						if (obj != null)
						{
							obj.SetColor(GameColors.Instance.brightGold);
						}
					}
				}
			}
		}

		private static void ReRenderCards()
		{
			if (!GameFlowManager.IsCardBattle)
			{
				return;
			}
			foreach (CardSlot item in Singleton<BoardManager>.Instance.AllSlotsCopy)
			{
				if ((Object)(object)item.Card != (Object)null && (CardExtensions.HasAnyOfAbilities(item.Card, GemReRenderAbilities) || ((Card)item.Card).Info.appearanceBehaviour.Any((Appearance a) => GemReRenderAppearances.Contains(a))))
				{
					((Card)item.Card).RenderCard();
					item.Card.UpdateFaceUpOnBoardEffects();
				}
			}
			foreach (PlayableCard item2 in Singleton<PlayerHand>.Instance.cardsInHand)
			{
				if (CardExtensions.HasAnyOfAbilities(item2, GemReRenderAbilities) || ((Card)item2).Info.appearanceBehaviour.Any((Appearance a) => GemReRenderAppearances.Contains(a)))
				{
					((Card)item2).RenderCard();
				}
			}
		}

		[HarmonyPatch(typeof(ResourcesManager), "AddGem")]
		[HarmonyPostfix]
		private static IEnumerator GemsAddSwitch(IEnumerator sequence)
		{
			yield return sequence;
			if (SaveManager.SaveFile.IsPart3)
			{
				ReRenderCards();
			}
		}

		[HarmonyPatch(typeof(ResourcesManager), "LoseGem")]
		[HarmonyPostfix]
		private static IEnumerator GemsRemoveSwitch(IEnumerator sequence)
		{
			yield return sequence;
			if (SaveManager.SaveFile.IsPart3)
			{
				ReRenderCards();
			}
		}

		[HarmonyPatch(typeof(ResourcesManager), "ForceGemsUpdate")]
		[HarmonyPostfix]
		private static void GemsForceSwitch()
		{
			if (SaveManager.SaveFile.IsPart3)
			{
				ReRenderCards();
			}
		}
	}
	public class AbsorbShield : AbilityBehaviour
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		static AbsorbShield()
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Shield Absorption";
			val.rulebookDescription = "When [creature] is played, all creatures lose their shields. This creature gains 1 attack for each shield lost this way.";
			val.canStack = false;
			val.powerLevel = 2;
			val.opponentUsable = true;
			val.passive = false;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0,
				(AbilityMetaCategory)3
			};
			AbilityExtensions.SetPixelAbilityIcon(val, TextureHelper.GetImageAsTexture("pixelability_shield_vampire.png", typeof(AbsorbShield).Assembly, (FilterMode)0), (FilterMode?)null);
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(AbsorbShield), (Texture)(object)TextureHelper.GetImageAsTexture("ability_shield_vampire.png", typeof(AbsorbShield).Assembly, (FilterMode)0)).Id;
			RuleBookRedirectExtensions.SetAbilityRedirect(val, "shields", (Ability)54, GameColors.Instance.limeGreen);
		}

		public override bool RespondsToResolveOnBoard()
		{
			return true;
		}

		public override IEnumerator OnResolveOnBoard()
		{
			((Card)((AbilityBehaviour)this).Card).Anim.StrongNegationEffect();
			int shields = 0;
			foreach (CardSlot slot in Singleton<BoardManager>.Instance.AllSlotsCopy)
			{
				while ((Object)(object)slot.Card != (Object)null && slot.Card.HasShield())
				{
					yield return slot.Card.TakeDamage(1, (PlayableCard)null);
					shields++;
				}
			}
			if (shields > 0)
			{
				((AbilityBehaviour)this).Card.AddTemporaryMod(new CardModificationInfo(shields, 0));
			}
		}
	}
	public class AcceleratedLifecycle : ActivatedAbilityBehaviour
	{
		internal static List<CardSlot> BuffedSlots;

		private bool ActivatedThisTurn = false;

		public override Ability Ability => AbilityID;

		public static Ability AbilityID { get; private set; }

		public override int EnergyCost => 1;

		static AcceleratedLifecycle()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			BuffedSlots = new List<CardSlot>();
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Rapid Recycle";
			val.rulebookDescription = "Pay 1 Energy to choose another card you control to die and immediately respawn. You may only activate this ability once per turn.";
			val.canStack = false;
			val.powerLevel = 3;
			val.opponentUsable = true;
			val.activated = true;
			val.passive = false;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(AcceleratedLifecycle), (Texture)(object)TextureHelper.GetImageAsTexture("ability_lifecycle.png", typeof(AcceleratedLifecycle).Assembly, (FilterMode)0)).Id;
		}

		public override bool RespondsToUpkeep(bool playerUpkeep)
		{
			return true;
		}

		private int OpponentRecyclePriority(CardSlot slot)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Object.op_Implicit((Object)(object)slot.Card))
				{
					return 0;
				}
				if ((Object)(object)slot.Card == (Object)(object)((AbilityBehaviour)this).Card)
				{
					return 0;
				}
				if (CardExtensions.AllAbilities(slot.Card).Any((Ability ab) => AbilityExtensions.AbilityByID((IEnumerable<FullAbility>)AbilityManager.AllAbilities, ab).AbilityBehavior.IsSubclassOf(typeof(Latch))))
				{
					return slot.Card.HasAbility(LatchDeathLatch.AbilityID) ? 20 : (slot.Card.HasAbility((Ability)57) ? 15 : 10);
				}
				if (slot.Card.HasAbility((Ability)52))
				{
					int num = 0;
					foreach (CardSlot adjacentSlot in Singleton<BoardManager>.Instance.GetAdjacentSlots(slot))
					{
						if ((Object)(object)adjacentSlot == (Object)(object)((AbilityBehaviour)this).Card.slot)
						{
							return 0;
						}
						if ((Object)(object)adjacentSlot.Card != (Object)null)
						{
							num -= adjacentSlot.Card.PowerLevel;
						}
					}
					CardSlot val = CardExtensions.OpposingSlot(slot.Card);
					if ((Object)(object)val.Card != (Object)null)
					{
						num += val.Card.PowerLevel;
					}
					return num;
				}
				return 0;
			}
			catch
			{
				return 0;
			}
		}

		public override IEnumerator OnUpkeep(bool playerUpkeep)
		{
			if (playerUpkeep && !((AbilityBehaviour)this).Card.OpponentCard)
			{
				ActivatedThisTurn = false;
			}
			else if (!playerUpkeep && ((AbilityBehaviour)this).Card.OpponentCard)
			{
				List<CardSlot> possibles = Singleton<BoardManager>.Instance.OpponentSlotsCopy;
				possibles.Sort((CardSlot a, CardSlot b) => OpponentRecyclePriority(b) - OpponentRecyclePriority(a));
				if (OpponentRecyclePriority(possibles[0]) > 0)
				{
					Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
					yield return (object)new WaitForSeconds(0.2f);
					yield return RecycleCard(possibles[0]);
				}
			}
		}

		public override bool CanActivate()
		{
			return GetValidTargets().Count > 0 && !ActivatedThisTurn;
		}

		private List<CardSlot> GetValidTargets()
		{
			List<CardSlot> list = new List<CardSlot>();
			foreach (CardSlot slot in Singleton<BoardManager>.Instance.GetSlots(!((AbilityBehaviour)this).Card.OpponentCard))
			{
				if ((Object)(object)slot.Card != (Object)null && (Object)(object)slot.Card != (Object)(object)((AbilityBehaviour)this).Card)
				{
					list.Add(slot);
				}
			}
			return list;
		}

		private IEnumerator RecycleCard(CardSlot target)
		{
			((Card)((AbilityBehaviour)this).Card).Anim.StrongNegationEffect();
			AudioController.Instance.PlaySound3D("angel_reveal", (MixerGroup)4, ((Component)((AbilityBehaviour)this).Card.Slot).gameObject.transform.position, 1f, 0f, new Pitch((Variation)0), (Repetition)null, (Randomization)null, (Distortion)null, false);
			yield return (object)new WaitForSeconds(1f);
			CardInfo targetInfo = ((Card)target.Card).Info;
			yield return target.Card.Die(false, (PlayableCard)null, true);
			yield return Singleton<BoardManager>.Instance.CreateCardInSlot(targetInfo, target, 0.1f, true);
			ActivatedThisTurn = true;
			Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
		}

		public override IEnumerator Activate()
		{
			Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
			yield return (object)new WaitForSeconds(0.2f);
			yield return Singleton<BoardManager>.Instance.ChooseSlot(GetValidTargets(), true);
			if ((Object)(object)Singleton<BoardManager>.Instance.LastSelectedSlot == (Object)null)
			{
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
				yield break;
			}
			ActivatedThisTurn = true;
			yield return RecycleCard(Singleton<BoardManager>.Instance.LastSelectedSlot);
		}
	}
	public class ActivatedBuffTeam : FuelActivatedAbilityBehaviour, IPassiveAttackBuff, IOnBellRung
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int FuelCost => 1;

		static ActivatedBuffTeam()
		{
			//IL_0092: 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)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Supercharge";
			val.rulebookDescription = "Spend one fuel: friendly cards gain 1 power until the end of the turn. This ability can only be activated once per turn.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = true;
			val.passive = false;
			val.activated = true;
			val.SetDefaultFuel(1);
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedBuffTeam), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_gain_power.png", typeof(ActivatedBuffTeam).Assembly, (FilterMode)0)).Id;
			RuleBookRedirectExtensions.SetUniqueRedirect(val, "fuel", "fuelManagerPage", GameColors.Instance.limeGreen);
		}

		public override IEnumerator ActivateAfterSpendFuel()
		{
			yield return ((AbilityBehaviour)this).LearnAbility(0.1f);
		}

		public int GetPassiveAttackBuff(PlayableCard target)
		{
			return (base.HasActivatedThisTurn && target.OpponentCard == ((AbilityBehaviour)this).Card.OpponentCard) ? 1 : 0;
		}

		public bool RespondsToBellRung(bool playerCombatPhase)
		{
			return ((AbilityBehaviour)this).Card.OpponentCard && !playerCombatPhase;
		}

		public IEnumerator OnBellRung(bool playerCombatPhase)
		{
			if (((AbilityBehaviour)this).Card.OpponentCard && !playerCombatPhase)
			{
				yield return ((TriggerReceiver)this).OnActivatedAbility();
			}
		}
	}
	public class ActivatedCopySigils : ActivatedAbilityBehaviour
	{
		public const string SINGLETON_ID = "COPY_PASTE_SIGILS";

		private CardSlot SelectedCopyFromSlot = null;

		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int EnergyCost => 3;

		private List<CardSlot> CopyFromSlots => (from s in BoardManagerExtensions.GetSlotsCopy(Singleton<BoardManager>.Instance, CardExtensions.IsPlayerCard(((AbilityBehaviour)this).Card))
			where (Object)(object)s.Card != (Object)null && CardExtensions.AllAbilities(s.Card).Count > 0
			select s).ToList();

		private List<CardSlot> CopyToSlots => (from s in BoardManagerExtensions.GetSlotsCopy(Singleton<BoardManager>.Instance, CardExtensions.IsPlayerCard(((AbilityBehaviour)this).Card))
			where (Object)(object)s.Card != (Object)null && (Object)(object)s != (Object)(object)SelectedCopyFromSlot
			select s).ToList();

		public override bool CanActivate()
		{
			return (from s in BoardManagerExtensions.GetSlotsCopy(Singleton<BoardManager>.Instance, CardExtensions.IsPlayerCard(((AbilityBehaviour)this).Card))
				where (Object)(object)s.Card != (Object)null
				select s).Count() >= 2;
		}

		static ActivatedCopySigils()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Copy and Paste";
			val.rulebookDescription = "The controller of [creature] chooses two cards they control. The second card's sigils are replaced with the sigils of the first.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.passive = false;
			val.activated = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedCopySigils), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_copy_sigils.png", typeof(ActivatedCopySigils).Assembly, (FilterMode)0)).Id;
		}

		private int EvaluateCopyFromSlot(CardSlot slot)
		{
			if ((Object)(object)slot.Card == (Object)null)
			{
				return 0;
			}
			return (from a in CardExtensions.AllAbilities(slot.Card)
				select AbilitiesUtil.GetInfo(a).powerLevel).Sum();
		}

		private int EvaluateCopyToSlot(CardSlot slot)
		{
			if ((Object)(object)slot.Card == (Object)null)
			{
				return -10000;
			}
			return -(from a in CardExtensions.AllAbilities(slot.Card)
				select AbilitiesUtil.GetInfo(a).powerLevel).Sum();
		}

		private IEnumerator OnSelectCopyFromSlot(CardSlot slot)
		{
			SelectedCopyFromSlot = slot;
			((Card)slot.Card).Anim.StrongNegationEffect();
			yield break;
		}

		private IEnumerator OnSelectCopyToSlot(CardSlot slot)
		{
			if ((Object)(object)slot.Card == (Object)null)
			{
				yield break;
			}
			List<Ability> targetAbilities = new List<Ability>(((Card)slot.Card).Info.Abilities);
			foreach (CardModificationInfo mod in slot.Card.TemporaryMods.Where((CardModificationInfo m) => !m.IsContinousEffectMod() && m.abilities != null))
			{
				targetAbilities.AddRange(mod.abilities);
			}
			CardModificationInfo newAbilityMod = slot.Card.GetOrCreateSingletonTempMod("COPY_PASTE_SIGILS");
			newAbilityMod.abilities = new List<Ability>(CardExtensions.AllAbilities(SelectedCopyFromSlot.Card));
			newAbilityMod.negateAbilities = targetAbilities.Where((Ability a) => !newAbilityMod.abilities.Contains(a)).ToList();
			((Card)slot.Card).Anim.StrongNegationEffect();
			slot.Card.AddTemporaryMod(newAbilityMod);
		}

		public override IEnumerator Activate()
		{
			yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
			yield return ((AbilityBehaviour)(object)this).CardChooseSlotSequence(OnSelectCopyFromSlot, CopyFromSlots, EvaluateCopyFromSlot, "Choose a card to copy sigils from", aimWeapon: false, (CursorType)4);
			yield return (object)new WaitForSeconds(0.2f);
			yield return ((AbilityBehaviour)(object)this).CardChooseSlotSequence(OnSelectCopyToSlot, CopyToSlots, EvaluateCopyToSlot, "Choose a card to paste sigils onto", aimWeapon: false, (CursorType)2);
			yield return ((AbilityBehaviour)this).LearnAbility(0.2f);
		}
	}
	public class ActivatedDrawBlast : FuelActivatedAbilityBehaviour
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int FuelCost => 1;

		static ActivatedDrawBlast()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Cannon Fire";
			val.rulebookDescription = "Spend one fuel: Create a Blast! card in hand. Blast! is defined as a spell that costs 2 energy and sets the target on fire. This ability can only be activated once per turn.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.passive = false;
			val.activated = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedDrawBlast), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_draw_blast.png", typeof(ActivatedDrawBlast).Assembly, (FilterMode)0)).Id;
			RuleBookRedirectExtensions.SetSlotRedirect(val, "on fire", BurningSlotBase.GetFireLevel(1), GameColors.Instance.limeGreen);
			RuleBookRedirectExtensions.SetUniqueRedirect(val, "fuel", "fuelManagerPage", GameColors.Instance.limeGreen);
		}

		public override IEnumerator ActivateAfterSpendFuel()
		{
			yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
			if ((int)Singleton<ViewManager>.Instance.CurrentView != 1)
			{
				yield return (object)new WaitForSeconds(0.2f);
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
				yield return (object)new WaitForSeconds(0.2f);
			}
			yield return Singleton<CardSpawner>.Instance.SpawnCardToHand(CardLoader.GetCardByName("P03SIG_BLAST"), (List<CardModificationInfo>)null, 0.25f, (Action<PlayableCard>)null);
			yield return (object)new WaitForSeconds(0.45f);
			yield return ((AbilityBehaviour)this).LearnAbility(0.1f);
		}
	}
	public class ActivatedDrawCharge : ActivatedAbilityBehaviour
	{
		public const int ENERGY_COST = 2;

		public override Ability Ability => AbilityID;

		public static Ability AbilityID { get; private set; }

		public override int EnergyCost => 2;

		static ActivatedDrawCharge()
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Recharge Reserves";
			val.rulebookDescription = $"Pay {2} Energy to create a Charge in your hand. Charge is defined as a spell that refills 1 Energy when played.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.activated = true;
			val.passive = false;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0,
				(AbilityMetaCategory)3
			};
			AbilityExtensions.SetPixelAbilityIcon(val, TextureHelper.GetImageAsTexture("pixelability_activated_drawcharge.png", typeof(ActivatedDrawCharge).Assembly, (FilterMode)0), (FilterMode?)null);
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedDrawCharge), (Texture)(object)TextureHelper.GetImageAsTexture("ability_store_charge.png", typeof(ActivatedDrawCharge).Assembly, (FilterMode)0)).Id;
		}

		public override IEnumerator Activate()
		{
			((Card)((AbilityBehaviour)this).Card).Anim.StrongNegationEffect();
			if ((int)Singleton<ViewManager>.Instance.CurrentView != 1)
			{
				yield return (object)new WaitForSeconds(0.2f);
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
				yield return (object)new WaitForSeconds(0.2f);
			}
			yield return Singleton<CardSpawner>.Instance.SpawnCardToHand(CardLoader.GetCardByName("P03SIG_CHARGE"), (List<CardModificationInfo>)null, 0.25f, (Action<PlayableCard>)null);
			yield return (object)new WaitForSeconds(0.25f);
			yield return ((AbilityBehaviour)this).LearnAbility(0f);
		}
	}
	public class ActivatedDrawDefend : ActivatedAbilityBehaviour
	{
		private bool hasActivatedThisTurn = false;

		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int EnergyCost => 2;

		public override bool CanActivate()
		{
			return !hasActivatedThisTurn;
		}

		static ActivatedDrawDefend()
		{
			//IL_008a: 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)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Holo Weaver";
			val.rulebookDescription = "Once per turn, create a Defend! card in hand. Defend! is defined as a spell that costs 2 energy and gives the target a shield.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.passive = false;
			val.activated = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedDrawDefend), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_draw_defend.png", typeof(ActivatedDrawDefend).Assembly, (FilterMode)0)).Id;
			RuleBookRedirectExtensions.SetAbilityRedirect(val, "shield", (Ability)54, GameColors.Instance.limeGreen);
		}

		public override bool RespondsToUpkeep(bool playerUpkeep)
		{
			return playerUpkeep == CardExtensions.IsPlayerCard(((AbilityBehaviour)this).Card);
		}

		public override IEnumerator OnUpkeep(bool playerUpkeep)
		{
			hasActivatedThisTurn = false;
			yield break;
		}

		public override IEnumerator Activate()
		{
			hasActivatedThisTurn = true;
			yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
			if ((int)Singleton<ViewManager>.Instance.CurrentView != 1)
			{
				yield return (object)new WaitForSeconds(0.2f);
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
				yield return (object)new WaitForSeconds(0.2f);
			}
			yield return Singleton<CardSpawner>.Instance.SpawnCardToHand(CardLoader.GetCardByName("P03SIG_DEFEND"), (List<CardModificationInfo>)null, 0.25f, (Action<PlayableCard>)null);
			yield return (object)new WaitForSeconds(0.45f);
			yield return ((AbilityBehaviour)this).LearnAbility(0.1f);
		}
	}
	[HarmonyPatch]
	public class ActivatedFutureSight : ActivatedAbilityBehaviour
	{
		private static readonly ConditionalWeakTable<Deck, CardInfo> _topCardTable;

		private static PlayableCard CurrentDisplayedCard;

		private static bool PlayerClickedCard;

		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int EnergyCost => 1;

		private static CardInfo CachedTopCardOfDeck
		{
			get
			{
				if ((Object)(object)Singleton<CardDrawPiles>.Instance == (Object)null)
				{
					return null;
				}
				List<CardInfo> cards = Singleton<CardDrawPiles>.Instance.Deck.cards;
				if (cards.Count == 0)
				{
					return null;
				}
				if (_topCardTable.TryGetValue(Singleton<CardDrawPiles>.Instance.Deck, out var value))
				{
					if (cards.Contains(value))
					{
						return value;
					}
					CachedTopCardOfDeck = null;
					return null;
				}
				return null;
			}
			set
			{
				if (!((Object)(object)Singleton<CardDrawPiles>.Instance == (Object)null))
				{
					_topCardTable.Remove(Singleton<CardDrawPiles>.Instance.Deck);
					if ((Object)(object)value != (Object)null)
					{
						_topCardTable.Add(Singleton<CardDrawPiles>.Instance.Deck, value);
					}
				}
			}
		}

		public override bool CanActivate()
		{
			return Singleton<CardDrawPiles>.Instance.Deck.cards.Count > 0;
		}

		static ActivatedFutureSight()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			_topCardTable = new ConditionalWeakTable<Deck, CardInfo>();
			CurrentDisplayedCard = null;
			PlayerClickedCard = false;
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Future Sight";
			val.rulebookDescription = "Look at the top card of your deck. You can play it.";
			val.canStack = false;
			val.powerLevel = 4;
			val.opponentUsable = false;
			val.passive = false;
			val.activated = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedFutureSight), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_future_sight.png", typeof(ActivatedFutureSight).Assembly, (FilterMode)0)).Id;
		}

		private static CardInfo GetAndCacheTopCardOfDeck()
		{
			CardInfo cachedTopCardOfDeck = CachedTopCardOfDeck;
			if ((Object)(object)cachedTopCardOfDeck != (Object)null)
			{
				return cachedTopCardOfDeck;
			}
			if ((Object)(object)Singleton<CardDrawPiles>.Instance == (Object)null)
			{
				return null;
			}
			List<CardInfo> cards = Singleton<CardDrawPiles>.Instance.Deck.cards;
			if (cards.Count == 0)
			{
				return null;
			}
			return CachedTopCardOfDeck = cards[SeededRandom.Range(0, cards.Count, Singleton<CardDrawPiles>.Instance.Deck.randomSeed)];
		}

		[HarmonyPatch(typeof(TurnManager), "CleanupPhase")]
		[HarmonyPrefix]
		private static void CleanUpTopOfDeck()
		{
			CachedTopCardOfDeck = null;
		}

		[HarmonyPatch(typeof(Deck), "Draw", new Type[] { typeof(CardInfo) })]
		[HarmonyPrefix]
		private static bool DrawKnownTopCard(Deck __instance, CardInfo specificCard, ref CardInfo __result)
		{
			if ((Object)(object)__instance != (Object)(object)Singleton<CardDrawPiles>.Instance.Deck)
			{
				return true;
			}
			if ((Object)(object)specificCard != (Object)null && __instance.cards.Contains(specificCard))
			{
				CachedTopCardOfDeck = null;
				return true;
			}
			if ((Object)(object)CachedTopCardOfDeck != (Object)null)
			{
				__result = CachedTopCardOfDeck;
				CachedTopCardOfDeck = null;
				__instance.cards.Remove(__result);
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(ViewController), "ManagedLateUpdate")]
		[HarmonyPrefix]
		private static bool SwitchViewsWhenLookingAtFutureCard(ViewController __instance)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Invalid comparison between Unknown and I4
			if ((Object)(object)CurrentDisplayedCard == (Object)null)
			{
				return true;
			}
			if (Singleton<ViewManager>.Instance.CurrentView != CardDrawPiles3D.Instance.pilesView)
			{
				return true;
			}
			if ((int)__instance.LockState != 1 && (InputButtons.GetButtonRepeating((Button)4) || InputButtons.GetButtonRepeating((Button)5)))
			{
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
			}
			return false;
		}

		[HarmonyPatch(typeof(PlayerHand), "PlayCardOnSlot")]
		[HarmonyPostfix]
		private static IEnumerator PlayFutureCard(IEnumerator sequence, PlayableCard card, CardSlot slot)
		{
			if ((Object)(object)card != (Object)(object)CurrentDisplayedCard)
			{
				yield return sequence;
				yield break;
			}
			CardDrawPiles3D.Instance.Pile.Draw();
			((CardDrawPiles)CardDrawPiles3D.Instance).Deck.cards.Remove(CachedTopCardOfDeck);
			CachedTopCardOfDeck = null;
			if (card.TriggerHandler.RespondsToTrigger((Trigger)2, Array.Empty<object>()))
			{
				yield return card.TriggerHandler.OnTrigger((Trigger)2, Array.Empty<object>());
			}
			yield return Singleton<BoardManager>.Instance.ResolveCardOnBoard(card, slot, 0.1f, (Action)null, true);
		}

		[HarmonyPatch(typeof(PlayerHand), "OnCardSelected")]
		[HarmonyPrefix]
		private static bool SpecialPlayerCard(PlayerHand __instance, PlayableCard card)
		{
			if ((Object)(object)CurrentDisplayedCard == (Object)null)
			{
				return true;
			}
			if ((Object)(object)card != (Object)(object)CurrentDisplayedCard)
			{
				return false;
			}
			if (!__instance.AllowCardInHandSelection(card))
			{
				return false;
			}
			PlayerClickedCard = true;
			return false;
		}

		[HarmonyPatch(typeof(BoardManager), "ShowCardNearBoard")]
		[HarmonyPrefix]
		private static bool ShowFutureCard(BoardManager __instance, PlayableCard card, bool showNearBoard)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)card != (Object)(object)CurrentDisplayedCard || showNearBoard)
			{
				return true;
			}
			((InteractableBase)card).SetEnabled(false);
			Tween.LocalPosition(((Component)card).transform, ((Component)card).transform.localPosition + 3f * Vector3.down, 0.2f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)delegate
			{
				Object.Destroy((Object)(object)((Component)card).gameObject);
			}, true);
			return false;
		}

		public override IEnumerator Activate()
		{
			CardInfo info = GetAndCacheTopCardOfDeck();
			if ((Object)(object)info == (Object)null)
			{
				yield break;
			}
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
			Singleton<ViewManager>.Instance.SwitchToView(CardDrawPiles3D.Instance.pilesView, false, false);
			yield return (object)new WaitForSeconds(0.2f);
			PlayableCard card = CardSpawner.SpawnPlayableCard(CardLoader.Clone(info));
			((Component)card).transform.position = new Vector3(3.1f, 6.11f, -3.7f);
			((Component)card).transform.eulerAngles = new Vector3(30f, 22f, 8f);
			if (card.TriggerHandler.RespondsToTrigger((Trigger)1, Array.Empty<object>()))
			{
				yield return ((AbilityBehaviour)this).Card.TriggerHandler.OnTrigger((Trigger)1, Array.Empty<object>());
			}
			if (!card.CanPlay())
			{
				HintsHandler.OnNonplayableCardClicked(card, Singleton<PlayerHand>.Instance.CardsInHand);
				yield return (object)new WaitForSeconds(2f);
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
			}
			else
			{
				CurrentDisplayedCard = card;
				PlayerClickedCard = false;
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
				yield return (object)new WaitUntil((Func<bool>)(() => Singleton<ViewManager>.Instance.CurrentView != CardDrawPiles3D.Instance.pilesView || PlayerClickedCard));
				if (PlayerClickedCard)
				{
					yield return Singleton<PlayerHand>.Instance.SelectSlotForCard(card);
					CurrentDisplayedCard = null;
					yield break;
				}
			}
			Tween.LocalPosition(((Component)card).transform, ((Component)card).transform.localPosition + 3f * Vector3.down, 0.2f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)delegate
			{
				Object.Destroy((Object)(object)card);
			}, true);
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
		}
	}
	public class ActivatedGainBattery : ActivatedAbilityBehaviour
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int BonesCost => 2;

		public override bool CanActivate()
		{
			return Singleton<ResourcesManager>.Instance.PlayerMaxEnergy < 6 || Singleton<ResourcesManager>.Instance.PlayerEnergy < Singleton<ResourcesManager>.Instance.PlayerMaxEnergy;
		}

		static ActivatedGainBattery()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Fossil Fuel";
			val.rulebookDescription = "Provides an additional energy cell.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.passive = false;
			val.activated = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedGainBattery), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_gain_battery.png", typeof(ActivatedGainBattery).Assembly, (FilterMode)0)).Id;
		}

		public override IEnumerator Activate()
		{
			yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
			if (Singleton<ResourcesManager>.Instance is Part3ResourcesManager)
			{
				yield return (object)new WaitForSeconds(0.2f);
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
				yield return (object)new WaitForSeconds(0.2f);
			}
			yield return Singleton<ResourcesManager>.Instance.AddMaxEnergy(1);
			yield return Singleton<ResourcesManager>.Instance.AddEnergy(1);
			if (Singleton<ResourcesManager>.Instance is Part3ResourcesManager)
			{
				yield return (object)new WaitForSeconds(0.3f);
			}
			yield return ((AbilityBehaviour)this).LearnAbility(0.2f);
		}
	}
	public class ActivatedGainPower : ActivatedAbilityBehaviour
	{
		public const int ENERGY_COST = 4;

		public override Ability Ability => AbilityID;

		public static Ability AbilityID { get; private set; }

		public override int EnergyCost => 4;

		static ActivatedGainPower()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Overcharge";
			val.rulebookDescription = $"Pay {4} Energy to increase the Power of this card by 1.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.activated = true;
			val.passive = false;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedGainPower), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activatedexpensivepowerup.png", typeof(TakeDamageSigil).Assembly, (FilterMode)0)).Id;
		}

		public override IEnumerator Activate()
		{
			CardModificationInfo cardModificationInfo = ((AbilityBehaviour)this).Card.TemporaryMods.Find((CardModificationInfo x) => x.singletonId == "statsUp");
			if (cardModificationInfo == null)
			{
				cardModificationInfo = new CardModificationInfo
				{
					singletonId = "statsUp"
				};
				((AbilityBehaviour)this).Card.AddTemporaryMod(cardModificationInfo);
			}
			CardModificationInfo obj = cardModificationInfo;
			obj.attackAdjustment++;
			((AbilityBehaviour)this).Card.OnStatsChanged();
			yield return (object)new WaitForSeconds(0.25f);
		}
	}
	[HarmonyPatch]
	public class ActivatedGainPowerCharge : ActivatedAbilityBehaviour
	{
		private static readonly List<Texture2D> PowerupIcons;

		public override Ability Ability => AbilityID;

		public static Ability AbilityID { get; private set; }

		public override int EnergyCost => Mathf.Min(((AbilityBehaviour)this).Card.NonPassiveAttack() + 2, 6);

		static ActivatedGainPowerCharge()
		{
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			PowerupIcons = new List<Texture2D>
			{
				TextureHelper.GetImageAsTexture("ability_activated_powerup_0.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0),
				TextureHelper.GetImageAsTexture("ability_activated_powerup_1.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0),
				TextureHelper.GetImageAsTexture("ability_activated_powerup_2.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0),
				TextureHelper.GetImageAsTexture("ability_activated_powerup_3.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0),
				TextureHelper.GetImageAsTexture("ability_activated_powerup_4.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0),
				TextureHelper.GetImageAsTexture("ability_activated_powerup_5.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0),
				TextureHelper.GetImageAsTexture("ability_activated_powerup_6.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0)
			};
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Enrage";
			val.rulebookDescription = "Pay Energy equal to the Power of this card plus 2 to increase the Power of this card by 1.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.activated = true;
			val.passive = false;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedGainPowerCharge), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_powerup_2.png", typeof(TakeDamageSigil).Assembly, (FilterMode)0)).Id;
		}

		public override IEnumerator Activate()
		{
			CardModificationInfo cardModificationInfo = ((AbilityBehaviour)this).Card.GetOrCreateSingletonTempMod("statsUp");
			cardModificationInfo.attackAdjustment++;
			((AbilityBehaviour)this).Card.AddTemporaryMod(cardModificationInfo);
			((Card)((AbilityBehaviour)this).Card).RenderInfo.OverrideAbilityIcon(AbilityID, (Texture)(object)PowerupIcons[((ActivatedAbilityBehaviour)this).EnergyCost]);
			((Card)((AbilityBehaviour)this).Card).RenderCard();
			yield return (object)new WaitForSeconds(0.25f);
		}

		[HarmonyPatch(typeof(AbilityIconInteractable), "LoadIcon")]
		[HarmonyPrefix]
		private static bool LoadMissileStrikeIcons(CardInfo info, AbilityInfo ability, ref Texture __result)
		{
			//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 (ability.ability != AbilityID)
			{
				return true;
			}
			int num = CardExtensions.GetPlayableCard(info)?.NonPassiveAttack() ?? info.Attack;
			int index = Mathf.Min(num + 2, 6);
			__result = (Texture)(object)PowerupIcons[index];
			return false;
		}
	}
	[HarmonyPatch]
	public class ActivatedGainItem : ActivatedAbilityBehaviour
	{
		private static readonly List<Texture2D> Icons;

		public const string ACTIVATION_KEY = "NumberOfActivationsRemaining";

		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int EnergyCost => 6;

		private static bool IsCountMod(CardModificationInfo m)
		{
			return !string.IsNullOrEmpty(m.singletonId) && m.singletonId.Equals("NumberOfActivationsRemaining");
		}

		private static int GetNumberOfActivationsRemaining(CardInfo info)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			CardModificationInfo val = ((IEnumerable<CardModificationInfo>)info.mods).FirstOrDefault((Func<CardModificationInfo, bool>)IsCountMod);
			if (val == null)
			{
				val = new CardModificationInfo();
				val.singletonId = "NumberOfActivationsRemaining";
				CardModificationInfoExtensions.SetExtendedProperty(val, "NumberOfActivationsRemaining", (object)AscensionSaveData.Data.currentRun.MaxConsumables, false);
				SaveManager.SaveFile.CurrentDeck.ModifyCard(info, val);
			}
			return CardModificationInfoExtensions.GetExtendedPropertyAsInt(val, "NumberOfActivationsRemaining") ?? (-1);
		}

		public override bool CanActivate()
		{
			return (from s in Singleton<ItemsManager>.Instance.consumableSlots
				where !(s is HammerItemSlot)
				where (Object)(object)((ItemSlot)s).Item != (Object)null
				select s).Count() < AscensionSaveData.Data.currentRun.MaxConsumables && GetNumberOfActivationsRemaining(((Card)((AbilityBehaviour)this).Card).Info) > 0;
		}

		static ActivatedGainItem()
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			Icons = new List<Texture2D>
			{
				TextureHelper.GetImageAsTexture("ability_activatedgainconsumable_1.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0),
				TextureHelper.GetImageAsTexture("ability_activatedgainconsumable_2.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0),
				TextureHelper.GetImageAsTexture("ability_activatedgainconsumable_3.png", typeof(ActivatedGainPowerCharge).Assembly, (FilterMode)0)
			};
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Dispenser";
			val.rulebookDescription = "Gain a random item.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.passive = false;
			val.activated = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedGainItem), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activatedgainconsumable.png", typeof(ActivatedGainItem).Assembly, (FilterMode)0)).Id;
		}

		private void ReduceCount()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			int numberOfActivationsRemaining = GetNumberOfActivationsRemaining(((Card)((AbilityBehaviour)this).Card).Info);
			CardModificationInfo val = ((IEnumerable<CardModificationInfo>)((Card)((AbilityBehaviour)this).Card).Info.Mods).FirstOrDefault((Func<CardModificationInfo, bool>)IsCountMod);
			if (numberOfActivationsRemaining == 1)
			{
				val.negateAbilities = new List<Ability> { AbilityID };
			}
			else
			{
				CardModificationInfoExtensions.SetExtendedProperty(val, "NumberOfActivationsRemaining", (object)(numberOfActivationsRemaining - 1), false);
			}
			SaveManager.SaveFile.CurrentDeck.ModifyCard(((Card)((AbilityBehaviour)this).Card).Info, val);
			((Card)((AbilityBehaviour)this).Card).RenderCard();
		}

		public override IEnumerator Activate()
		{
			yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
			yield return (object)new WaitForSeconds(0.2f);
			Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
			yield return (object)new WaitForSeconds(0.25f);
			string item = ((Object)ItemsUtil.GetRandomUnlockedConsumable(P03SigilLibraryPlugin.RandomSeed)).name;
			foreach (ConsumableItemSlot slot in Singleton<ItemsManager>.Instance.consumableSlots.Where((ConsumableItemSlot s) => !(s is HammerItemSlot)))
			{
				if ((Object)(object)((ItemSlot)slot).Item == (Object)null)
				{
					slot.CreateItem(item, false);
					Singleton<ItemsManager>.Instance.OnUpdateItems(true);
					Singleton<ItemsManager>.Instance.SaveDataItemsList.Add(item);
					yield return (object)new WaitForSeconds(0.2f);
					ReduceCount();
					yield return ((AbilityBehaviour)this).LearnAbility(0f);
					yield break;
				}
			}
		}

		[HarmonyPatch(typeof(AbilityIconInteractable), "LoadIcon")]
		[HarmonyPrefix]
		private static bool LoadMissileStrikeIcons(CardInfo info, AbilityInfo ability, ref Texture __result)
		{
			//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 (ability.ability != AbilityID)
			{
				return true;
			}
			int num = GetNumberOfActivationsRemaining(info) - 1;
			if (num < 0)
			{
				return true;
			}
			__result = (Texture)(object)Icons[num];
			return false;
		}
	}
	public class ActivatedStrafe : FuelActivatedAbilityBehaviour
	{
		protected bool movingLeft;

		public override Ability Ability => AbilityID;

		public static Ability AbilityID { get; private set; }

		public override int FuelCost => 1;

		static ActivatedStrafe()
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Drive";
			val.rulebookDescription = "Spend one fuel: move in the direction inscribed in this sigil. This ability can only be activated once per turn.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.activated = true;
			val.passive = false;
			val.SetDefaultFuel(4);
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedStrafe), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_strafe_right_fuel.png", typeof(ActivatedStrafe).Assembly, (FilterMode)0)).Id;
			AbilityExtensions.SetCustomFlippedTexture(val, TextureHelper.GetImageAsTexture("ability_activated_strafe_left_fuel.png", typeof(ActivatedStrafe).Assembly, (FilterMode)0));
			RuleBookRedirectExtensions.SetUniqueRedirect(val, "fuel", "fuelManagerPage", GameColors.Instance.limeGreen);
		}

		public override IEnumerator ActivateAfterSpendFuel()
		{
			CardSlot toLeft = Singleton<BoardManager>.Instance.GetAdjacent(((AbilityBehaviour)this).Card.Slot, true);
			CardSlot toRight = Singleton<BoardManager>.Instance.GetAdjacent(((AbilityBehaviour)this).Card.Slot, false);
			Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
			yield return (object)new WaitForSeconds(0.25f);
			yield return DoStrafe(toLeft, toRight);
		}

		protected virtual IEnumerator DoStrafe(CardSlot toLeft, CardSlot toRight)
		{
			bool canMoveLeft = (Object)(object)toLeft != (Object)null && (Object)(object)toLeft.Card == (Object)null;
			bool canMoveRight = (Object)(object)toRight != (Object)null && (Object)(object)toRight.Card == (Object)null;
			if (movingLeft && !canMoveLeft)
			{
				movingLeft = false;
			}
			if (!movingLeft && !canMoveRight)
			{
				movingLeft = true;
			}
			CardSlot destination = (movingLeft ? toLeft : toRight);
			bool destinationValid = (movingLeft ? canMoveLeft : canMoveRight);
			yield return MoveToSlot(destination, destinationValid);
			if ((Object)(object)destination != (Object)null && destinationValid)
			{
				yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
				yield return ((AbilityBehaviour)this).LearnAbility(0f);
			}
		}

		protected IEnumerator MoveToSlot(CardSlot destination, bool destinationValid)
		{
			((Card)((AbilityBehaviour)this).Card).RenderInfo.SetAbilityFlipped(((AbilityBehaviour)this).Ability, movingLeft);
			((Card)((AbilityBehaviour)this).Card).RenderInfo.flippedPortrait = movingLeft && ((Card)((AbilityBehaviour)this).Card).Info.flipPortraitForStrafe;
			((Card)((AbilityBehaviour)this).Card).RenderCard();
			if ((Object)(object)destination != (Object)null && destinationValid)
			{
				yield return Singleton<BoardManager>.Instance.AssignCardToSlot(((AbilityBehaviour)this).Card, destination, 0.1f, (Action)null, true);
				yield return (object)new WaitForSeconds(0.25f);
			}
			else
			{
				((Card)((AbilityBehaviour)this).Card).Anim.StrongNegationEffect();
				yield return (object)new WaitForSeconds(0.15f);
			}
		}
	}
	public class ActivatedStrafeSelf : ActivatedAbilityBehaviour
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override bool CanActivate()
		{
			return false;
		}

		public override IEnumerator Activate()
		{
			yield break;
		}

		static ActivatedStrafeSelf()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "D-Pad";
			val.rulebookDescription = "Move to an adjacent empty lane.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.passive = false;
			val.activated = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedStrafeSelf), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_strafe.png", typeof(ActivatedStrafeSelf).Assembly, (FilterMode)0)).Id;
		}

		public override bool RespondsToDrawn()
		{
			return true;
		}

		public override bool RespondsToOtherCardResolve(PlayableCard otherCard)
		{
			return (Object)(object)otherCard == (Object)(object)((AbilityBehaviour)this).Card;
		}

		public override IEnumerator OnOtherCardResolve(PlayableCard otherCard)
		{
			yield return ((TriggerReceiver)this).OnDrawn();
		}

		public override IEnumerator OnDrawn()
		{
			PlayerHand instance = Singleton<PlayerHand>.Instance;
			PlayerHand3D p3d = (PlayerHand3D)(object)((instance is PlayerHand3D) ? instance : null);
			if (p3d != null)
			{
				p3d.MoveCardAboveHand(((AbilityBehaviour)this).Card);
				yield return ((AbilityBehaviour)this).Card.FlipInHand((Action)AddMod);
			}
			else
			{
				AddMod();
			}
			yield return ((AbilityBehaviour)this).LearnAbility(0.5f);
		}

		private void AddMod()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			((AbilityBehaviour)this).Card.Status.hiddenAbilities.Add(((AbilityBehaviour)this).Ability);
			CardModificationInfo val = new CardModificationInfo();
			val.abilities.Add(ActivatedStrafeSelfLeft.AbilityID);
			val.abilities.Add(ActivatedStrafeSelfRight.AbilityID);
			val.negateAbilities.Add(AbilityID);
			((AbilityBehaviour)this).Card.AddTemporaryMod(val);
		}
	}
	[HarmonyPatch]
	public class ActivatedStrafeSelfLeft : ActivatedAbilityBehaviour
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int EnergyCost => 1;

		private List<CardSlot> ValidSlots => (from s in CardSlotExtensions.GetAdjacentSlots(((AbilityBehaviour)this).Card.Slot, true)
			where s.Index < ((AbilityBehaviour)this).Card.Slot.Index
			where (Object)(object)s.Card == (Object)null
			select s).ToList();

		public override bool CanActivate()
		{
			return ValidSlots.Count > 0;
		}

		static ActivatedStrafeSelfLeft()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "D-Pad Left";
			val.rulebookDescription = "Move to the lane to the left, if it is empty.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.passive = false;
			val.activated = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedStrafeSelfLeft), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_strafe_left.png", typeof(ActivatedStrafeSelfLeft).Assembly, (FilterMode)0)).Id;
		}

		public override IEnumerator Activate()
		{
			yield return Singleton<BoardManager>.Instance.AssignCardToSlot(((AbilityBehaviour)this).Card, ValidSlots[0], 0.1f, (Action)null, false);
			yield return (object)new WaitForSeconds(0.15f);
		}

		[HarmonyPatch(typeof(CardAbilityIcons), "GetDistinctShownAbilities")]
		[HarmonyPostfix]
		[HarmonyPriority(100)]
		private static void StraftLeftAlwaysFirst(ref List<Ability> __result)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (__result.Contains(AbilityID))
			{
				__result.Remove(AbilityID);
				__result.Insert(0, AbilityID);
			}
		}
	}
	[HarmonyPatch]
	public class ActivatedStrafeSelfRight : ActivatedAbilityBehaviour
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int EnergyCost => 1;

		private List<CardSlot> ValidSlots => (from s in CardSlotExtensions.GetAdjacentSlots(((AbilityBehaviour)this).Card.Slot, true)
			where s.Index > ((AbilityBehaviour)this).Card.Slot.Index
			where (Object)(object)s.Card == (Object)null
			select s).ToList();

		public override bool CanActivate()
		{
			return ValidSlots.Count > 0;
		}

		static ActivatedStrafeSelfRight()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "D-Pad Right";
			val.rulebookDescription = "Move to the lane to the right, if it is empty.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = false;
			val.passive = false;
			val.activated = true;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedStrafeSelfRight), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_strafe_right.png", typeof(ActivatedStrafeSelfRight).Assembly, (FilterMode)0)).Id;
		}

		public override IEnumerator Activate()
		{
			yield return Singleton<BoardManager>.Instance.AssignCardToSlot(((AbilityBehaviour)this).Card, ValidSlots[0], 0.1f, (Action)null, false);
			yield return (object)new WaitForSeconds(0.15f);
		}

		[HarmonyPatch(typeof(CardAbilityIcons), "GetDistinctShownAbilities")]
		[HarmonyPostfix]
		[HarmonyPriority(100)]
		private static void StraftRightAlwaysLast(ref List<Ability> __result)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (__result.Contains(AbilityID))
			{
				__result.Remove(AbilityID);
				__result.Add(AbilityID);
			}
		}
	}
	[HarmonyPatch]
	public class ActivatedSubmerge : FuelActivatedAbilityBehaviour
	{
		private const string TEMPORARY_MOD_ID = "ACTIVATED_SUBMERGE_MOD";

		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int FuelCost => 1;

		static ActivatedSubmerge()
		{
			//IL_0092: 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)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Submerge";
			val.rulebookDescription = "Spend one fuel: submerge during the opponent's turn. While submerged, opposing creatures attack its owner directly.";
			val.canStack = false;
			val.powerLevel = 1;
			val.opponentUsable = true;
			val.passive = false;
			val.activated = true;
			val.SetDefaultFuel(2);
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedSubmerge), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_submerge.png", typeof(ActivatedSubmerge).Assembly, (FilterMode)0)).Id;
			RuleBookRedirectExtensions.SetUniqueRedirect(val, "fuel", "fuelManagerPage", GameColors.Instance.limeGreen);
		}

		public override IEnumerator ActivateAfterSpendFuel()
		{
			CardModificationInfo mod2 = ((IEnumerable<CardModificationInfo>)((AbilityBehaviour)this).Card.TemporaryMods).FirstOrDefault((Func<CardModificationInfo, bool>)((CardModificationInfo m) => m.singletonId != null && m.singletonId.Equals("ACTIVATED_SUBMERGE_MOD")));
			if (mod2 == null)
			{
				mod2 = new CardModificationInfo((Ability)13);
				mod2.singletonId = "ACTIVATED_SUBMERGE_MOD";
				((AbilityBehaviour)this).Card.Status.hiddenAbilities.Add(AbilityID);
				((AbilityBehaviour)this).Card.AddTemporaryMod(mod2);
			}
			yield break;
		}

		[HarmonyPatch(typeof(Submerge), "OnUpkeep")]
		[HarmonyPostfix]
		private static IEnumerator ResolveActivatedSubmerge(IEnumerator sequence, Submerge __instance)
		{
			yield return sequence;
			CardModificationInfo mod = ((IEnumerable<CardModificationInfo>)((AbilityBehaviour)__instance).Card.TemporaryMods).FirstOrDefault((Func<CardModificationInfo, bool>)((CardModificationInfo m) => m.singletonId != null && m.singletonId.Equals("ACTIVATED_SUBMERGE_MOD")));
			if (mod != null)
			{
				((AbilityBehaviour)__instance).Card.Status.hiddenAbilities.Remove(AbilityID);
				((AbilityBehaviour)__instance).Card.RemoveTemporaryMod(mod, true);
			}
		}
	}
	public class ActivatedTemporaryControl : FuelActivatedAbilityBehaviour
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public override int FuelCost => 1;

		private List<CardSlot> ValidOpposingSlots => (from s in BoardManagerExtensions.GetSlotsCopy(Singleton<BoardManager>.Instance, !CardExtensions.IsPlayerCard(((AbilityBehaviour)this).Card))
			where (Object)(object)s.Card != (Object)null && ((Object)(object)CardExtensions.OpposingCard(s.Card) == (Object)null || (((AbilityBehaviour)this).Card.OpponentCard && (Object)(object)CardExtensions.OpposingCard(s.Card) != (Object)(object)((AbilityBehaviour)this).Card))
			select s).ToList();

		public override bool CanActivate()
		{
			return ValidOpposingSlots.Count > 0 && base.CanActivate();
		}

		static ActivatedTemporaryControl()
		{
			//IL_0092: 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)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Tow Hook";
			val.rulebookDescription = "Spend one fuel: tow an opposing creature to your side of the board until end of turn. Creatures being towed cannot be hammered. This ability can only be activated once per turn.";
			val.canStack = false;
			val.powerLevel = 2;
			val.opponentUsable = true;
			val.passive = false;
			val.activated = true;
			val.SetDefaultFuel(1);
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivatedTemporaryControl), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activated_fishhook.png", typeof(ActivatedTemporaryControl).Assembly, (FilterMode)0)).Id;
			RuleBookRedirectExtensions.SetUniqueRedirect(val, "fuel", "fuelManagerPage", GameColors.Instance.limeGreen);
		}

		private int EvaluateSlot(CardSlot slot)
		{
			PlayableCard card = slot.Card;
			return (card != null) ? (-card.PowerLevel) : 0;
		}

		private IEnumerator OnSelectSlot(CardSlot slot)
		{
			yield return TemporaryControl.GainTemporaryControl(slot.Card);
		}

		public override IEnumerator ActivateAfterSpendFuel()
		{
			yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
			yield return CardEffectsHelper.CardChooseSlotSequence(aimWeapon: CardExtensions.GetExtendedPropertyAsBool(((Card)((AbilityBehaviour)this).Card).Info, "WeaponTowHook").GetValueOrDefault(), behaviour: (AbilityBehaviour)(object)this, slotSelectedCallback: OnSelectSlot, validSlots: ValidOpposingSlots, aiSlotEvaluator: EvaluateSlot, dialogue: null, cursor: (CursorType)19);
			yield return ((AbilityBehaviour)this).LearnAbility(0.2f);
		}
	}
	public class ActivateEverything : AbilityBehaviour
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		private bool useWeaponAnim => CardExtensions.GetExtendedPropertyAsBool(((Card)((AbilityBehaviour)this).Card).Info, "WeaponButtonPusher").GetValueOrDefault();

		static ActivateEverything()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Button Pusher";
			val.rulebookDescription = "When [creature] is played, all activated sigils and sigils that trigger on play or on death are activated.";
			val.canStack = false;
			val.powerLevel = 2;
			val.opponentUsable = true;
			val.passive = false;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(ActivateEverything), (Texture)(object)TextureHelper.GetImageAsTexture("ability_activate_everything.png", typeof(ActivateEverything).Assembly, (FilterMode)0)).Id;
		}

		public override bool RespondsToResolveOnBoard()
		{
			return true;
		}

		private IEnumerator PreTriggerAnimate(CardSlot targetSlot)
		{
			DiskCardAnimationController dcac = default(DiskCardAnimationController);
			int num;
			if (useWeaponAnim)
			{
				CardAnimationController anim = ((Card)((AbilityBehaviour)this).Card).Anim;
				dcac = (DiskCardAnimationController)(object)((anim is DiskCardAnimationController) ? anim : null);
				num = ((dcac != null) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			if (num != 0)
			{
				dcac.AimWeaponAnim(((Component)targetSlot).transform.position);
				dcac.ShowWeaponAnim();
				yield return (object)new WaitForSeconds(0.2f);
			}
			((Card)((AbilityBehaviour)this).Card).Anim.StrongNegationEffect();
			((Card)targetSlot.Card).Anim.StrongNegationEffect();
			yield return (object)new WaitForSeconds(0.25f);
			DiskCardAnimationController dcac2 = default(DiskCardAnimationController);
			int num2;
			if (useWeaponAnim)
			{
				CardAnimationController anim = ((Card)((AbilityBehaviour)this).Card).Anim;
				dcac2 = (DiskCardAnimationController)(object)((anim is DiskCardAnimationController) ? anim : null);
				num2 = ((dcac2 != null) ? 1 : 0);
			}
			else
			{
				num2 = 0;
			}
			if (num2 != 0)
			{
				dcac2.HideWeaponAnim();
			}
		}

		private IEnumerator TriggerHelper(CardSlot slot, Trigger trigger, params object[] otherArgs)
		{
			//IL_0015: 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)
			if ((Object)(object)slot == (Object)null || (Object)(object)slot.Card == (Object)null || slot.Card.Dead)
			{
				yield break;
			}
			foreach (TriggerReceiver receiver in slot.Card.TriggerHandler.GetAllReceivers())
			{
				if (!(receiver is ActivateEverything) && GlobalTriggerHandler.ReceiverRespondsToTrigger(trigger, receiver, otherArgs))
				{
					yield return PreTriggerAnimate(slot);
					yield return Singleton<GlobalTriggerHandler>.Instance.TriggerSequence(trigger, receiver, otherArgs);
				}
			}
		}

		private IEnumerator ActivatedTriggerHelper(CardSlot slot)
		{
			if ((Object)(object)slot == (Object)null || (Object)(object)slot.Card == (Object)null || slot.Card.Dead)
			{
				yield break;
			}
			foreach (Tuple<Ability, AbilityBehaviour> pair in slot.Card.TriggerHandler.triggeredAbilities)
			{
				AbilityBehaviour item = pair.Item2;
				if (item is FuelActivatedAbilityBehaviour fab)
				{
					bool didActivatePrevious = fab.HasActivatedThisTurn;
					fab.HasActivatedThisTurn = false;
					if (((ActivatedAbilityBehaviour)fab).CanActivate())
					{
						yield return PreTriggerAnimate(slot);
						yield return fab.ActivateAfterSpendFuel();
					}
					fab.HasActivatedThisTurn = didActivatePrevious;
				}
				else
				{
					item = pair.Item2;
					ActivatedAbilityBehaviour ab = (ActivatedAbilityBehaviour)(object)((item is ActivatedAbilityBehaviour) ? item : null);
					if (ab != null && ab.CanActivate())
					{
						yield return PreTriggerAnimate(slot);
						yield return ab.Activate();
					}
				}
			}
		}

		public override IEnumerator OnResolveOnBoard()
		{
			List<CardSlot> slots = BoardManagerExtensions.GetSlotsCopy(Singleton<BoardManager>.Instance, CardExtensions.IsPlayerCard(((AbilityBehaviour)this).Card)).Concat(BoardManagerExtensions.GetSlotsCopy(Singleton<BoardManager>.Instance, !CardExtensions.IsPlayerCard(((AbilityBehaviour)this).Card))).ToList();
			foreach (CardSlot slot2 in slots)
			{
				yield return TriggerHelper(slot2, (Trigger)3);
			}
			foreach (CardSlot slot4 in slots)
			{
				yield return ActivatedTriggerHelper(slot4);
			}
			foreach (CardSlot slot3 in slots)
			{
				yield return TriggerHelper(slot3, (Trigger)15, false);
			}
			foreach (CardSlot slot in slots)
			{
				yield return TriggerHelper(slot, (Trigger)12, false, null);
			}
		}
	}
	[HarmonyPatch]
	public class AllControl : AbilityBehaviour
	{
		public override Ability Ability => AbilityID;

		public static Ability AbilityID { get; set; }

		static AllControl()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Parasitic Control";
			val.rulebookDescription = "When [creature] is played, all opposing cards are moved to your side of the board.";
			val.canStack = false;
			val.powerLevel = 6;
			val.opponentUsable = false;
			val.passive = false;
			val.metaCategories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)2,
				(AbilityMetaCategory)0,
				(AbilityMetaCategory)3
			};
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.p03sigillibrary", val, typeof(AllControl), (Texture)(object)TextureHelper.GetImageAsTexture("ability_control_all.png", typeof(AllControl).Assembly, (FilterMode)0)).Id;
		}

		public override bool RespondsToResolveOnBoard()
		{
			return true;
		}

		public override IEnumerator OnResolveOnBoard()
		{
			foreach (CardSlot slot in Singleton<BoardManager>.Instance.OpponentSlotsCopy)
			{
				if (!((Object)(object)slot.Card == (Object)null) && !((Object)(object)slot.opposingSlot.Card != (Object)null))
				{
					((Card)((AbilityBehaviour)this).Card).Anim.StrongNegationEffect();
					yield return TemporaryControl.ReverseOwnerOfCard(slot.Card);
				}
			}
		}
	}
	[HarmonyPatch]
	public class BatteryPower : VariableStatBehaviour
	{
		public static SpecialStatIcon AbilityID { get; private set; }

		public override SpecialStatIcon IconType => AbilityID;

		public static int EnergySpent { get; private set; }

		static BatteryPower()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			StatIconInfo val = StatIconManager.New("zorro.inscryption.infiniscryption.p03sigillibrary", "Energy Power", "The value represented with this sigil will be equal to the number of times the player has spent energy this turn.", typeof(BatteryPower));
			val.appliesToAttack = true;
			val.appliesToHealth = false;
			AbilityExtensions.AddMetaCategories(val, (AbilityMetaCategory[])(object)new AbilityMetaCategory[2]
			{
				(AbilityMetaCategory)2,
				default(AbilityMetaCategory)
			});
			AbilityExtensions.SetIcon(val, TextureHelper.GetImageAsTexture("battery_stat_icon.png", typeof(BatteryPower).Assembly, (FilterMode)0), (FilterMode?)null);
			AbilityID = val.iconType;
		}

		[HarmonyPatch(typeof(ResourcesManager), "SpendEnergy")]
		[HarmonyPrefix]
		private static void IncrementSpendCounter(int amount)
		{
			if (amount > 0)
			{
				EnergySpent++;