Decompiled source of Curses v1.1.4

Infiniscryption.Curses.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using Infiniscryption.Achievements;
using Infiniscryption.Curses.Cards;
using Infiniscryption.Curses.Components;
using Infiniscryption.Curses.Helpers;
using Infiniscryption.Curses.Patchers;
using Infiniscryption.Curses.Sequences;
using Infiniscryption.Spells.Sigils;
using InscryptionAPI.Ascension;
using InscryptionAPI.Card;
using InscryptionAPI.Dialogue;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
using InscryptionAPI.Saves;
using InscryptionAPI.Sound;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Infiniscryption.Curses")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Infinite Inscryption - Curses")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("Infiniscryption.Curses")]
[assembly: AssemblyTitle("Infiniscryption.Curses")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
namespace Infiniscryption.Curses
{
	[BepInPlugin("zorro.inscryption.infiniscryption.curses", "Infiniscryption Curses", "0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CursePlugin : BaseUnityPlugin
	{
		internal const string PluginGuid = "zorro.inscryption.infiniscryption.curses";

		internal const string PluginName = "Infiniscryption Curses";

		internal const string PluginVersion = "0.1";

		internal const string CardPrefix = "CURSES";

		internal static ManualLogSource Log;

		internal static CursePlugin Instance;

		internal string DebugCode => ((BaseUnityPlugin)this).Config.Bind<string>("CurseMod", "DebugCode", "nothing", new ConfigDescription("A special code to use for debugging purposes only. Don't change this unless your name is DivisionByZorro or he told you how it works.", (AcceptableValueBase)null, Array.Empty<object>())).Value;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("zorro.inscryption.infiniscryption.curses");
			RandomSigils.Register(val);
			HarderBosses.Register(val);
			DeathcardHaunt.Register(val);
			ThreeCandles.Register(val);
			GoldenPeltStart.Register(val);
			NoOneHitKills.Register(val);
			DrawDynamite.Register(val);
			StartWithTribalTotems.Register(val);
			BiggerMoon.Register(val);
			BoonsAssist.Register(val);
			CursedAchievements.Register();
			val.PatchAll(typeof(AudioHelper));
			val.PatchAll(typeof(CursePlugin));
			Instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin Infiniscryption Curses is loaded with debug code " + DebugCode));
		}
	}
}
namespace Infiniscryption.Curses.Sequences
{
	public class AnglerBossHardOpponent : AnglerBossOpponent
	{
		public static readonly string MEGA_SHARK = "CURSES_Angler_Shark";

		public override int StartingLives => 3;

		public override IEnumerator IntroSequence(EncounterData encounter)
		{
			yield return <>n__0(encounter);
			yield return HarderBosses.ShowExtraBossCandle((Part1BossOpponent)(object)this, "AnglerExtraCandle");
		}

		public override IEnumerator StartNewPhaseSequence()
		{
			if (((Opponent)this).NumLives >= 2)
			{
				yield return <>n__1();
				yield break;
			}
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
			Singleton<ViewManager>.Instance.SwitchToView((View)21, false, false);
			yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("AnglerPhaseThree", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
			Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
			yield return ((Opponent)this).ClearQueue();
			yield return ((Opponent)this).ClearBoard();
			((Opponent)this).Blueprint = null;
			((Opponent)this).ReplaceAndAppendTurnPlan(new List<List<CardInfo>>());
			List<CardSlot> slots = Singleton<BoardManager>.Instance.OpponentSlotsCopy;
			int numberOfSharks = 2;
			if (SaveFile.IsAscension && AscensionSaveData.Data.currentRun.regionTier == 0)
			{
				numberOfSharks = 1;
			}
			for (int i = 0; i < numberOfSharks; i++)
			{
				int slotNum = i switch
				{
					2 => 2, 
					1 => 3, 
					0 => 1, 
					_ => 0, 
				};
				CardInfo shark = CardLoader.GetCardByName(MEGA_SHARK);
				if (SaveFile.IsAscension && AscensionSaveData.Data.currentRun.regionTier == 2)
				{
					shark.mods.Add(new CardModificationInfo(1, 1));
				}
				yield return Singleton<BoardManager>.Instance.CreateCardInSlot(shark, slots[slotNum], 0.1f, true);
				yield return (object)new WaitForSeconds(0.15f);
			}
			yield return (object)new WaitForSeconds(0.75f);
			Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private IEnumerator <>n__0(EncounterData encounter)
		{
			return ((AnglerBossOpponent)this).IntroSequence(encounter);
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private IEnumerator <>n__1()
		{
			return ((AnglerBossOpponent)this).StartNewPhaseSequence();
		}
	}
	public class AnglerBossHardSequencer : AnglerBattleSequencer
	{
	}
	public class ProspectorBossHardOpponent : ProspectorBossOpponent
	{
		public static readonly string DYNAMITE = "CURSES_Prospector_Dynamite";

		public override int StartingLives => 3;

		public override IEnumerator IntroSequence(EncounterData encounter)
		{
			yield return <>n__0(encounter);
			yield return HarderBosses.ShowExtraBossCandle((Part1BossOpponent)(object)this, "ProspectorExtraCandle");
		}

		public override IEnumerator StartNewPhaseSequence()
		{
			if (((Opponent)this).NumLives >= 2)
			{
				yield return <>n__1();
				yield break;
			}
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
			Singleton<ViewManager>.Instance.SwitchToView((View)21, false, false);
			yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("ProspectorPhaseThree", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
			Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
			yield return ((Opponent)this).ClearQueue();
			yield return ((Opponent)this).ClearBoard();
			foreach (CardSlot slot2 in Singleton<BoardManager>.Instance.PlayerSlotsCopy)
			{
				if ((Object)(object)slot2.Card != (Object)null && ((Object)((Card)slot2.Card).Info).name == "GoldNugget")
				{
					((Card)slot2.Card).ExitBoard(0.4f, Vector3.zero);
				}
			}
			((Opponent)this).Blueprint = null;
			((Opponent)this).ReplaceAndAppendTurnPlan(new List<List<CardInfo>>());
			foreach (CardSlot slot in Singleton<BoardManager>.Instance.OpponentSlotsCopy)
			{
				CardInfo bigBoulder = CardLoader.GetCardByName("Boulder");
				bigBoulder.Mods.Add(new CardModificationInfo((Ability)23));
				if (RunState.CurrentRegionTier == 0)
				{
					bigBoulder.Mods.Add(new CardModificationInfo(0, -3));
				}
				if (RunState.CurrentRegionTier == 1)
				{
					bigBoulder.Mods.Add(new CardModificationInfo(0, -1));
				}
				if (RunState.CurrentRegionTier == 2)
				{
					bigBoulder.Mods.Add(new CardModificationInfo(0, 1));
				}
				yield return Singleton<BoardManager>.Instance.CreateCardInSlot(bigBoulder, slot, 0.1f, true);
				yield return (object)new WaitForSeconds(0.15f);
			}
			yield return (object)new WaitForSeconds(0.35f);
			Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private IEnumerator <>n__0(EncounterData encounter)
		{
			return ((ProspectorBossOpponent)this).IntroSequence(encounter);
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private IEnumerator <>n__1()
		{
			return ((ProspectorBossOpponent)this).StartNewPhaseSequence();
		}
	}
	public class ProspectorBossHardSequencer : ProspectorBattleSequencer
	{
		public override IEnumerator PlayerPostDraw()
		{
			if (Singleton<TurnManager>.Instance.Opponent.NumLives <= 1)
			{
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
				yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("CatchDynamite", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
				Singleton<ViewManager>.Instance.SwitchToView((View)0, false, false);
				PlayableCard dynamite = CardSpawner.SpawnPlayableCard(CardLoader.GetCardByName(ProspectorBossHardOpponent.DYNAMITE));
				yield return Singleton<PlayerHand>.Instance.AddCardToHand(dynamite, Vector3.zero, 0f);
				Singleton<PlayerHand>.Instance.OnCardInspected(dynamite);
				Singleton<PlayerHand>.Instance.InspectingLocked = true;
				((Card)dynamite).Anim.PlayHitAnimation();
				yield return (object)new WaitForSeconds(0.6f);
				Singleton<PlayerHand>.Instance.InspectingLocked = false;
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
				yield return (object)new WaitForSeconds(0.33f);
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
			}
		}

		private List<CardSlot> EmptyLanes()
		{
			return Singleton<BoardManager>.Instance.OpponentSlotsCopy.Where((CardSlot s) => (Object)(object)s.Card == (Object)null && (Object)(object)s.opposingSlot.Card == (Object)null).ToList();
		}

		public override bool RespondsToTurnEnd(bool playerTurnEnd)
		{
			return !playerTurnEnd && EmptyLanes().Count > 0 && Singleton<TurnManager>.Instance.Opponent.NumLives == 1;
		}

		public override IEnumerator OnTurnEnd(bool playerTurnEnd)
		{
			List<CardSlot> wolfSlots = EmptyLanes();
			if (playerTurnEnd || wolfSlots.Count == 0 || Singleton<TurnManager>.Instance.Opponent.NumLives > 1)
			{
				yield break;
			}
			foreach (CardSlot slot in wolfSlots)
			{
				yield return Singleton<TurnManager>.Instance.Opponent.QueueCard(CardLoader.GetCardByName("Wolf"), slot, true, true, true);
				if (DialogueEventsData.GetEventRepeatCount("ProspectorWolfSpawn") == 0)
				{
					yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("ProspectorWolfSpawn", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
				}
			}
		}
	}
	public class TrapperTraderBossHardOpponent : TrapperTraderBossOpponent
	{
		public static readonly string LEAPING_TRAP = "Trap";

		public static readonly string BOW_CARD = "CURSES_Trapper_Bow";

		public static readonly string CAPTURE_CARD = "CURSES_Trapper_Capture";

		public static readonly string SPIKE_TRAP_CARD = "CURSES_Trapper_Spike_Trap";

		private static Vector3 BOSS_CARD_RECEIVE_OFFSET = new Vector3(0f, 2f, 8f);

		private static SpecialStatIcon[] USELESS_STAT_ICONS;

		public override int StartingLives => 3;

		public override IEnumerator IntroSequence(EncounterData encounter)
		{
			yield return <>n__0(encounter);
			yield return HarderBosses.ShowExtraBossCandle((Part1BossOpponent)(object)this, "TrapperTraderExtraCandle");
		}

		private void RemoveCovered(List<CardInfo> list, Func<CardInfo, bool> predicate, int count)
		{
			List<CardInfo> list2 = list.Where(predicate).Take(count).ToList();
			foreach (CardInfo item in list2)
			{
				list.Remove(item);
			}
		}

		private bool CardUsableByBoss(CardInfo card)
		{
			if (!card.Sacrificable)
			{
				return false;
			}
			if (card.Health == 0)
			{
				return false;
			}
			if (card.Attack == 0 && USELESS_STAT_ICONS.Any((SpecialStatIcon st) => st == card.SpecialStatIcon))
			{
				return false;
			}
			return true;
		}

		private List<CardInfo> BuildPhaseThreeDeck(List<CardInfo> trapperDeck)
		{
			List<CardInfo> list = new List<CardInfo>();
			for (int i = 0; i < 2; i++)
			{
				list.Add(CardLoader.GetCardByName(LEAPING_TRAP));
				list.Add(CardLoader.GetCardByName(SPIKE_TRAP_CARD));
				list.Add(CardLoader.GetCardByName(CAPTURE_CARD));
				list.Add(CardLoader.GetCardByName(BOW_CARD));
			}
			List<CardInfo> list2 = new List<CardInfo>(trapperDeck);
			RemoveCovered(list2, (CardInfo card) => !card.HasAbility((Ability)19) && card.HasAbility((Ability)35), 3);
			Func<CardInfo, bool> func = (CardInfo card) => !card.HasAbility((Ability)19) && (card.Health == 1 || card.Attack <= 2 || card.Health == 2);
			RemoveCovered(list2, func, 2);
			Func<CardInfo, bool> func2 = (CardInfo card) => card.Health <= 2;
			RemoveCovered(list2, func2, 2);
			list2.Sort((CardInfo a, CardInfo b) => b.Health - a.Health);
			list2.RemoveRange(0, Math.Min(4, list2.Count));
			for (int j = 0; j < 2; j++)
			{
				CardInfo val = list2.Find(func.Invoke);
				if ((Object)(object)val != (Object)null)
				{
					list.Add(CardLoader.GetCardByName(SPIKE_TRAP_CARD));
					list2.Remove(val);
				}
			}
			List<CardInfo> list3 = list2.Where((CardInfo card) => card.Health <= 2).ToList();
			foreach (CardInfo item in list3)
			{
				list.Add(CardLoader.GetCardByName(BOW_CARD));
				list2.Remove(item);
			}
			CardInfo val2 = list2.Find(func2.Invoke);
			if ((Object)(object)val2 != (Object)null)
			{
				list.Add(CardLoader.GetCardByName(BOW_CARD));
				list.Add(CardLoader.GetCardByName(BOW_CARD));
				list2.Remove(val2);
			}
			for (int k = 0; k < list2.Count; k++)
			{
				list.Add(CardLoader.GetCardByName(LEAPING_TRAP));
			}
			if (!RunState.Run.consumables.Any((string c) => c.ToLowerInvariant() == "fishhook"))
			{
				list.Add(CardLoader.GetCardByName(CAPTURE_CARD));
			}
			if (!RunState.Run.consumables.Any((string c) => c.ToLowerInvariant() == "scissors"))
			{
				list.Add(CardLoader.GetCardByName(LEAPING_TRAP));
			}
			int num = trapperDeck.Where((CardInfo card) => card.HasAbility((Ability)26)).Count();
			for (int l = 0; l < num; l++)
			{
				list.Add(CardLoader.GetCardByName(LEAPING_TRAP));
			}
			list.Add(CardLoader.GetCardByName(BOW_CARD));
			list.Add(CardLoader.GetCardByName(BOW_CARD));
			if (RunState.CurrentRegionTier == 0)
			{
				list.Add(CardLoader.GetCardByName(CAPTURE_CARD));
			}
			return list;
		}

		private IEnumerator FlyBothDecksIntoOpponent()
		{
			CardDrawPiles3D drawPiles = CardDrawPiles3D.Instance;
			yield return drawPiles.Pile.DestroyCards(BOSS_CARD_RECEIVE_OFFSET, 30f, 0.5f);
			((CardDrawPiles)drawPiles).Deck.ClearCards();
			yield return drawPiles.SidePile.DestroyCards(BOSS_CARD_RECEIVE_OFFSET, 30f, 0.5f);
			drawPiles.SideDeck.ClearCards();
		}

		private IEnumerator GeneratePhaseThreeDeck(List<CardInfo> currentDeck)
		{
			List<CardInfo> phaseThreeDeck = BuildPhaseThreeDeck(currentDeck);
			CardDrawPiles3D drawPiles = CardDrawPiles3D.Instance;
			Traverse pileTraverse = Traverse.Create((object)drawPiles);
			((CardDrawPiles)drawPiles).Deck.Initialize(phaseThreeDeck, SaveManager.SaveFile.GetCurrentRandomSeed());
			yield return drawPiles.Pile.SpawnCards(phaseThreeDeck.Count, 0.5f);
			pileTraverse.Method("AssignHintActionToPiles", Array.Empty<object>()).GetValue();
			drawPiles.Pile.Draw();
			yield return ((CardDrawPiles)drawPiles).DrawCardFromDeck(((CardDrawPiles)drawPiles).Deck.GetCardByName(LEAPING_TRAP), (Action<PlayableCard>)null);
			drawPiles.Pile.Draw();
			yield return ((CardDrawPiles)drawPiles).DrawCardFromDeck(((CardDrawPiles)drawPiles).Deck.GetCardByName(SPIKE_TRAP_CARD), (Action<PlayableCard>)null);
			drawPiles.Pile.Draw();
			yield return ((CardDrawPiles)drawPiles).DrawCardFromDeck(((CardDrawPiles)drawPiles).Deck.GetCardByName(BOW_CARD), (Action<PlayableCard>)null);
			drawPiles.Pile.Draw();
			yield return ((CardDrawPiles)drawPiles).DrawCardFromDeck(((CardDrawPiles)drawPiles).Deck.GetCardByName(BOW_CARD), (Action<PlayableCard>)null);
		}

		private CardInfo CloneWithModsForTrapperDeck(CardInfo info)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			object obj = info.Clone();
			CardInfo val = (CardInfo)((obj is CardInfo) ? obj : null);
			foreach (CardModificationInfo mod in info.Mods)
			{
				List<CardModificationInfo> mods = val.Mods;
				object obj2 = mod.Clone();
				mods.Add((CardModificationInfo)((obj2 is CardModificationInfo) ? obj2 : null));
			}
			CardModificationInfo val2 = new CardModificationInfo();
			val2.negateAbilities = new List<Ability>();
			foreach (Ability item in val.Abilities.Where((Ability ab) => !AbilitiesUtil.GetInfo(ab).opponentUsable))
			{
				val2.negateAbilities.Add(item);
			}
			val.Mods.Add(val2);
			return val;
		}

		private List<List<CardInfo>> BuildTurnPlan(List<CardInfo> currentDeck)
		{
			List<List<CardInfo>> list = new List<List<CardInfo>>();
			int num = 0;
			while (num < currentDeck.Count)
			{
				List<CardInfo> list2 = new List<CardInfo>();
				list2.Add(CloneWithModsForTrapperDeck(currentDeck[num]));
				num++;
				if (num < currentDeck.Count)
				{
					list2.Add(CloneWithModsForTrapperDeck(currentDeck[num]));
					num++;
				}
				list.Add(list2);
				if (list.Count > 5)
				{
					list.Add(new List<CardInfo>());
				}
			}
			return list;
		}

		public override IEnumerator StartNewPhaseSequence()
		{
			if (((Opponent)this).NumLives >= 2)
			{
				yield return <>n__1();
				yield break;
			}
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
			Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
			yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("TrapperTraderPhaseThree", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
			yield return ((Opponent)this).ClearQueue();
			yield return ((Opponent)this).ClearBoard();
			foreach (CardSlot cardSlot in Singleton<BoardManager>.Instance.PlayerSlotsCopy)
			{
				if ((Object)(object)cardSlot.Card != (Object)null)
				{
					((Card)cardSlot.Card).ExitBoard(0.4f, Vector3.zero);
					yield return (object)new WaitForSeconds(0.1f);
				}
			}
			yield return Singleton<PlayerHand>.Instance.CleanUp();
			yield return FlyBothDecksIntoOpponent();
			List<CardInfo> currentDeck2 = ((CardCollectionInfo)SaveManager.SaveFile.CurrentDeck).Cards;
			currentDeck2.Sort((CardInfo a, CardInfo b) => a.PowerLevel - b.PowerLevel);
			currentDeck2 = currentDeck2.Where(CardUsableByBoss).ToList();
			Singleton<PlayerHand>.Instance.Initialize();
			yield return GeneratePhaseThreeDeck(currentDeck2);
			((Opponent)this).Blueprint = null;
			((Opponent)this).ReplaceAndAppendTurnPlan(BuildTurnPlan(currentDeck2));
			yield return ((Opponent)this).QueueNewCards(true, true);
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
		}

		static TrapperTraderBossHardOpponent()
		{
			//IL_0037: 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)
			SpecialStatIcon[] array = new SpecialStatIcon[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			USELESS_STAT_ICONS = (SpecialStatIcon[])(object)array;
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private IEnumerator <>n__0(EncounterData encounter)
		{
			return ((TrapperTraderBossOpponent)this).IntroSequence(encounter);
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private IEnumerator <>n__1()
		{
			return ((TrapperTraderBossOpponent)this).StartNewPhaseSequence();
		}
	}
	public class TrapperTraderBossHardSequencer : TrapperTraderBattleSequencer
	{
	}
}
namespace Infiniscryption.Curses.Patchers
{
	[HarmonyPatch]
	internal static class CursedAchievements
	{
		internal static Achievement HIGH_LEVEL { get; private set; }

		internal static Achievement LOW_LEVEL { get; private set; }

		internal static Achievement DOUBLE_CHAOS { get; private set; }

		internal static Achievement TRIPLE_HAUNT { get; private set; }

		internal static Achievement SUPER_CELLO { get; private set; }

		internal static Achievement SHARK_POP { get; private set; }

		internal static Achievement HOT_POTATO { get; private set; }

		internal static void Register()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			AchievementGroup iD = ModdedAchievementManager.NewGroup("zorro.inscryption.infiniscryption.curses", "Cursed Achievements", TextureHelper.GetImageAsTexture("achievement_locked.png", typeof(CursedAchievements).Assembly, (FilterMode)0)).ID;
			LOW_LEVEL = ModdedAchievementManager.New("zorro.inscryption.infiniscryption.curses", "Here For A Good Time", "Complete a run with a negative challenge level", false, iD, TextureHelper.GetImageAsTexture("achievement_251.png", typeof(CursedAchievements).Assembly, (FilterMode)0)).ID;
			HIGH_LEVEL = ModdedAchievementManager.New("zorro.inscryption.infiniscryption.curses", "Here For A Hard Time", "Complete a run with a challenge level above 250", false, iD, TextureHelper.GetImageAsTexture("achievement_251.png", typeof(CursedAchievements).Assembly, (FilterMode)0)).ID;
			DOUBLE_CHAOS = ModdedAchievementManager.New("zorro.inscryption.infiniscryption.curses", "Utter Insanity", "Complete a run with two Chaotic Enemy skulls active", false, iD, TextureHelper.GetImageAsTexture("achievement_double_chaos.png", typeof(CursedAchievements).Assembly, (FilterMode)0)).ID;
			TRIPLE_HAUNT = ModdedAchievementManager.New("zorro.inscryption.infiniscryption.curses", "Too Spooky", "Reach the maximum deathcard haunt level", false, iD, TextureHelper.GetImageAsTexture("achievement_triple_haunt.png", typeof(CursedAchievements).Assembly, (FilterMode)0)).ID;
			SUPER_CELLO = ModdedAchievementManager.New("zorro.inscryption.infiniscryption.curses", "That's No Moon", "Defeat the Limoncello with the Bigger Moon skull active", false, iD, TextureHelper.GetImageAsTexture("achievement_pirate.png", typeof(CursedAchievements).Assembly, (FilterMode)0)).ID;
			SHARK_POP = ModdedAchievementManager.New("zorro.inscryption.infiniscryption.curses", "'Tis But A Flesh Wound", "Retrieve a damaged card from the belly of a Mega Shark", false, iD, TextureHelper.GetImageAsTexture("achievement_sharkpop.png", typeof(CursedAchievements).Assembly, (FilterMode)0)).ID;
			HOT_POTATO = ModdedAchievementManager.New("zorro.inscryption.infiniscryption.curses", "Munitions Expert", "Safely dispose of a stick of dynamite", false, iD, TextureHelper.GetImageAsTexture("achievement_safety.png", typeof(CursedAchievements).Assembly, (FilterMode)0)).ID;
			CursePlugin.Log.LogDebug((object)$"Cursed Achievements Have Been Loaded. Group number is {iD}");
		}

		[HarmonyPatch(typeof(AscensionMenuScreens), "ConfigurePostGameScreens")]
		[HarmonyPrefix]
		private static void AscensionCompleteAchievements()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			if (AscensionMenuScreens.ReturningFromSuccessfulRun)
			{
				if (AscensionSaveData.Data.GetNumChallengesOfTypeActive(RandomSigils.ID) >= 2)
				{
					AchievementManager.Unlock(DOUBLE_CHAOS);
				}
				if (AscensionSaveData.Data.GetActiveChallengePoints() > 250)
				{
					AchievementManager.Unlock(HIGH_LEVEL);
				}
				if (AscensionSaveData.Data.GetActiveChallengePoints() < 0)
				{
					AchievementManager.Unlock(LOW_LEVEL);
				}
				if (AscensionSaveData.Data.ChallengeIsActive(BiggerMoon.ID) && AscensionSaveData.Data.ChallengeIsActive((AscensionChallenge)15))
				{
					AchievementManager.Unlock(SUPER_CELLO);
				}
			}
		}
	}
	public static class BiggerMoon
	{
		public const string MOON = "!GIANTCARD_MOON";

		public const string PIRATESHIP = "!GIANTCARD_SHIP";

		public static AscensionChallenge ID { get; private set; }

		public static void Register(Harmony harmony)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			ID = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Full Moon", "Giant cards like the moon have more attack and health", 20, TextureHelper.GetImageAsTexture("challenge_bigger_moon.png", typeof(BiggerMoon).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("activated_challenge_bigger_moon.png", typeof(BiggerMoon).Assembly, (FilterMode)0), 0, false).Challenge.challengeType;
			CardManager.ModifyCardList += delegate(List<CardInfo> cards)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				if (AscensionSaveData.Data.ChallengeIsActive(ID))
				{
					CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "!GIANTCARD_MOON").baseAttack = 2;
					CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "!GIANTCARD_MOON").baseHealth = 80;
					CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "!GIANTCARD_SHIP").baseAttack = 3;
					CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "!GIANTCARD_SHIP").baseHealth = 120;
				}
				return cards;
			};
			harmony.PatchAll(typeof(BiggerMoon));
		}

		[HarmonyPatch(typeof(BoardManager), "CreateCardInSlot")]
		[HarmonyPostfix]
		private static IEnumerator ShowChallengeWhenMakingMoon(IEnumerator sequence, CardInfo info)
		{
			if (((Object)info).name.Equals("!GIANTCARD_MOON") && SaveFile.IsAscension && AscensionSaveData.Data.ChallengeIsActive(ID))
			{
				ChallengeActivationUI.TryShowActivation(ID);
			}
			yield return sequence;
		}
	}
	public static class BoonsAssist
	{
		public static AscensionChallenge ID { get; private set; }

		public static void Register(Harmony harmony)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			ID = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Minor Boon of the Bone Lord", "Start the game with a Minor Boon of the Bone Lord", -5, TextureHelper.GetImageAsTexture("assist_bones_boon.png", typeof(BoonsAssist).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("activated_assist_bones_boon.png", typeof(BoonsAssist).Assembly, (FilterMode)0), 0, true).Challenge.challengeType;
			harmony.PatchAll(typeof(BoonsAssist));
		}

		[HarmonyPatch(typeof(AscensionSaveData), "NewRun")]
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "zorro.inscryption.infiniscryption.kayceestarters" })]
		public static void AddBoonToStart(ref AscensionSaveData __instance)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < AscensionSaveData.Data.GetNumChallengesOfTypeActive(ID); i++)
			{
				__instance.currentRun.playerDeck.AddBoon((Type)7);
			}
		}
	}
	public class DeathcardGenerator
	{
		private static readonly string[] DEATHCARD_NAMES = new string[26]
		{
			"Aaron", "Mad Hatter", "Julian", "Joseph", "Ingo", "Green", "Never Named", "Matzie", "Lily", "Deer Sir",
			"Gary", "Ara", "Bitty", "Papi", "Hayper", "Slime", "Blind", "Kek", "Cactus", "xXxStoner420BongMasterxXx",
			"Void", "Warrior", "Spritz", "Penguin", "Jury", "Thunder"
		};

		public static CardModificationInfo GenerateMod(int hauntLevel)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			List<AbilityInfo> list = ScriptableObjectLoader<AbilityInfo>.AllData.FindAll((AbilityInfo x) => x.metaCategories.Contains((AbilityMetaCategory)1) && x.opponentUsable);
			int num = 3 + hauntLevel + 2 * RunState.Run.regionTier;
			CardModificationInfo val = CardInfoGenerator.CreateRandomizedAbilitiesStatsMod(list, num, 1, 2);
			int num2 = SaveManager.saveFile.GetCurrentRandomSeed() + 110;
			FigurineType val2 = (FigurineType)SeededRandom.Range(0, 8, num2++);
			if ((double)SeededRandom.Value(num2++) < 0.2)
			{
				val.deathCardInfo = new DeathCardInfo(val2, true);
			}
			else
			{
				val.deathCardInfo = new DeathCardInfo(val2, SeededRandom.Range(0, 6, num2++), SeededRandom.Range(0, 6, num2++));
			}
			val.nameReplacement = DEATHCARD_NAMES[SeededRandom.Range(0, DEATHCARD_NAMES.Length, num2++)];
			return val;
		}
	}
	public static class DeathcardHaunt
	{
		public class IntWrapper
		{
			public int Value { get; set; }
		}

		public class TalkWhenGhostDiesHandler : TriggerReceiver
		{
			public override bool RespondsToPreDeathAnimation(bool wasSacrifice)
			{
				return true;
			}

			public override IEnumerator OnPreDeathAnimation(bool wasSacrifice)
			{
				return DeathcardOuttroSequence();
			}
		}

		private static ConditionalWeakTable<CardInfo, IntWrapper> deathcardAnimationPlayTable = new ConditionalWeakTable<CardInfo, IntWrapper>();

		private static ConditionalWeakTable<CardTriggerHandler, List<TriggerReceiver>> _customReceivers = new ConditionalWeakTable<CardTriggerHandler, List<TriggerReceiver>>();

		internal const string DEATHCARD_INTRO_CLIP = "wind_blowing_loop";

		private const float FADE_IN_DURATION = 1f;

		private const float FADE_OUT_DURATION = 1f;

		private static CardInfo _deathcardOnBoard = null;

		private static bool _sawDeathcard = false;

		private static string _oldLoopName = null;

		private static float _oldVolume = 0f;

		private static Vector3[] SLOT_OFFSETS = (Vector3[])(object)new Vector3[4]
		{
			new Vector3(-2f, -1f, 1.5f),
			new Vector3(-0.5f, -1f, 1.5f),
			new Vector3(1f, -1f, 1.5f),
			new Vector3(2.4f, -1f, 1.5f)
		};

		private const int MAX_HAUNT_LEVEL = 11;

		private static List<GameObject> _orbitingFace = null;

		private static Vector3 UP_REF = Vector3.up;

		private static Vector3 START_REF = Vector3.forward;

		public static AscensionChallenge ID { get; private set; }

		private static int HauntLevel => ModdedSaveManager.RunState.GetValueAsInt("zorro.inscryption.infiniscryption.curses", "Curse.BaseHauntLevel") + (RunState.Run.survivorsDead ? 3 : 0) + RunState.Run.playerDeck.Boons.FindAll((BoonData boon) => (int)boon.type == 7).Count + RunState.Run.playerDeck.Boons.FindAll((BoonData boon) => (int)boon.type == 6).Count * 2;

		private static bool HasExplainedHaunt
		{
			get
			{
				return ModdedSaveManager.SaveData.GetValueAsBoolean("zorro.inscryption.infiniscryption.curses", "Curses.HauntExplanation");
			}
			set
			{
				ModdedSaveManager.SaveData.SetValue("zorro.inscryption.infiniscryption.curses", "Curses.HauntExplanation", (object)value);
			}
		}

		private static void SetHauntedCardFlag(CardInfo card)
		{
			if (!deathcardAnimationPlayTable.TryGetValue(card, out var _))
			{
				deathcardAnimationPlayTable.Add(card, new IntWrapper
				{
					Value = -1
				});
			}
		}

		private static bool GetHauntedCardFlag(CardInfo card)
		{
			IntWrapper value;
			return deathcardAnimationPlayTable.TryGetValue(card, out value);
		}

		private static void SetHauntedCardSlot(CardInfo card, int slot)
		{
			if (!deathcardAnimationPlayTable.TryGetValue(card, out var value))
			{
				deathcardAnimationPlayTable.Add(card, new IntWrapper
				{
					Value = slot
				});
			}
			else
			{
				value.Value = slot;
			}
		}

		private static int GetHauntedCardSlot(CardInfo card)
		{
			if (deathcardAnimationPlayTable.TryGetValue(card, out var value))
			{
				return value.Value;
			}
			return -1;
		}

		public static CardInfo GetRandomDeathcard()
		{
			CardModificationInfo val = DeathcardGenerator.GenerateMod(HauntLevel);
			CardInfo val2 = CardLoader.CreateDeathCard(val);
			SetHauntedCardFlag(val2);
			return val2;
		}

		public static void AddReceiver(CardTriggerHandler handler, TriggerReceiver receiver)
		{
			List<TriggerReceiver> value = null;
			if (!_customReceivers.TryGetValue(handler, out value))
			{
				value = new List<TriggerReceiver>();
				_customReceivers.Add(handler, value);
			}
			value.Add(receiver);
		}

		public static List<TriggerReceiver> GetReceivers(CardTriggerHandler handler)
		{
			List<TriggerReceiver> value = null;
			_customReceivers.TryGetValue(handler, out value);
			return value;
		}

		[HarmonyPatch(typeof(PlayableCard), "AttachAbilities")]
		[HarmonyPostfix]
		public static void AttachDeathListener(CardInfo info, ref PlayableCard __instance)
		{
			CursePlugin.Log.LogInfo((object)("In Opponent.CreateCard " + ((Object)info).name));
			if (GetHauntedCardFlag(info))
			{
				CursePlugin.Log.LogInfo((object)"Adding ghostdieshandler");
				TalkWhenGhostDiesHandler receiver = ((Component)__instance).gameObject.AddComponent<TalkWhenGhostDiesHandler>();
				AddReceiver(__instance.TriggerHandler, (TriggerReceiver)(object)receiver);
			}
		}

		[HarmonyPatch(typeof(CardTriggerHandler), "GetAllReceivers")]
		[HarmonyPostfix]
		public static void GetCustomListeners(ref List<TriggerReceiver> __result, ref CardTriggerHandler __instance)
		{
			List<TriggerReceiver> receivers = GetReceivers(__instance);
			if (receivers != null)
			{
				__result.AddRange(receivers);
			}
		}

		public static void Register(Harmony harmony)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			ID = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Haunted Past", "Deathcards will sometimes attack you in battle", 15, TextureHelper.GetImageAsTexture("challenge_deathcards.png", typeof(DeathcardHaunt).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("ascensionicon_activated_deathcards.png", typeof(DeathcardHaunt).Assembly, (FilterMode)0), 0, false).Challenge.challengeType;
			harmony.PatchAll(typeof(DeathcardHaunt));
			DialogueHelper.GenerateVeryLargeDialogue("DeathcardArrives", new string[3] { "you feel a chill in the air", "the hair stands up on the back of your neck", "[c:bR][v:0][c:] has arrived" }, new string[3] { "you suddenly feel weak", "your teeth start to chatter", "[c:bR][v:0][c:] is coming" }, new string[2] { "you can't explain how", "but you can feel the presence of [c:bR][v:0][c:]" }, new string[1] { "it finally happened: [c:bR][v:0][c:] is here" });
			DialogueHelper.GenerateVeryLargeDialogue("DeathcardZoom", new string[2] { "[c:O]\"I have been looking for you\"[c:] says the apparition", "[c:O]\"And now you must die!\"[c:]" }, new string[2] { "the apparition has nothing to say", "but you sense that it is here for you" }, new string[2] { "[c:O]\"you made a mistake coming here\"[c:] it growls", "[c:O]\"let me show you the way home\"[c:]" }, new string[2] { "the apparition seems lonely", "it wants you to join it in the afterlife" });
			DialogueHelper.GenerateVeryLargeDialogue("DeathcardDies", new string[2] { "the apparition fades into the wind", "you can't shake the feeling there are [c:O]more[c:] out there waiting" });
			DialogueHelper.GenerateVeryLargeDialogue("DeathcardWins", new string[1] { "[c:bR][v:0][c:] shivers with delight as your candle is extinguished" });
			DialogueHelper.GenerateLargeDialogue("HauntedExplanation", "do you see the [c:O]apparition[c:] encircling you?", "you have become [c:O]haunted[c:] by [c:O]those who have come before[c:]", "the more you [c:O]win in battle[c:] the angrier they become", "and they may [c:O]oppose you in battle[c:] in the future");
		}

		public static bool RollForDeathcard()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if (CursePlugin.Instance.DebugCode.ToLowerInvariant().Contains("deathcard"))
			{
				return true;
			}
			if (HauntLevel <= 1)
			{
				return false;
			}
			float num = SeededRandom.Value(SaveManager.SaveFile.GetCurrentRandomSeed());
			return num < (float)HauntLevel / 11f && AscensionSaveData.Data.ChallengeIsActive(ID);
		}

		[HarmonyPatch(typeof(TurnManager), "CleanupPhase")]
		[HarmonyPrefix]
		public static void ResetPlayerHauntLevelWhenBattleLost(ref TurnManager __instance)
		{
			bool flag = __instance.Opponent.NumLives <= 0 || __instance.Opponent.Surrendered;
			CursePlugin.Log.LogInfo((object)$"Battle over. Player Won = {flag}");
			if (flag)
			{
				if (!_sawDeathcard)
				{
					IncreaseHaunt();
				}
			}
			else
			{
				ResetHaunt();
			}
			if (_oldLoopName != null)
			{
				CursePlugin.Log.LogDebug((object)("DEATHCARDAUDIO: End of battle. Immediately setting old loop " + _oldLoopName + " back in"));
				AudioController.Instance.SetLoopAndPlay(_oldLoopName, 0, true, true);
				AudioController.Instance.SetLoopVolumeImmediate(_oldVolume, 0);
				_oldLoopName = null;
			}
			else
			{
				CursePlugin.Log.LogDebug((object)"DEATHCARDAUDIO: End of battle. No audio to resume.");
			}
			_sawDeathcard = false;
			_deathcardOnBoard = null;
		}

		public static double TurnAverage(IEnumerable<CardInfo> turn)
		{
			int num = 0;
			double num2 = 0.0;
			foreach (CardInfo item in turn)
			{
				num2 += (double)item.PowerLevel;
				num++;
			}
			return (num == 0) ? (-100.0) : (num2 / (double)num);
		}

		[HarmonyPatch(typeof(EncounterBuilder), "Build")]
		[HarmonyPostfix]
		public static void AddDeathcardToEncounter(ref EncounterData __result, CardBattleNodeData nodeData)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (!AscensionSaveData.Data.ChallengeIsActive(ID) || nodeData is BossBattleNodeData)
			{
				return;
			}
			CursePlugin.Log.LogInfo((object)"Checking to see if we should add a deathcard...");
			if (!RollForDeathcard())
			{
				return;
			}
			CursePlugin.Log.LogInfo((object)"Adding a deathcard...");
			List<List<CardInfo>> tp = __result.opponentTurnPlan;
			CardInfo deathcard = GetRandomDeathcard();
			List<double> differences = tp.Select((List<CardInfo> cards) => Math.Abs((double)deathcard.PowerLevel - TurnAverage(cards))).ToList();
			int idealTurn = Enumerable.Range(0, differences.Count).Aggregate((int a, int b) => (differences[a] < differences[b]) ? a : b);
			if (idealTurn > 2)
			{
				if (tp[2].Count > 0)
				{
					idealTurn = 2;
				}
				else if (tp[1].Count > 0)
				{
					idealTurn = 1;
				}
				else
				{
					idealTurn = 0;
				}
			}
			int num = Enumerable.Range(0, tp[idealTurn].Count).Aggregate((int a, int b) => (tp[idealTurn][a].PowerLevel < tp[idealTurn][b].PowerLevel) ? a : b);
			tp[idealTurn][num] = deathcard;
			_deathcardOnBoard = deathcard;
			SetHauntedCardSlot(deathcard, num);
			CursePlugin.Log.LogInfo((object)$"Added a deathcard in turn {idealTurn} in slot {num}");
		}

		[HarmonyPatch(typeof(Opponent), "CanOfferSurrender")]
		[HarmonyPostfix]
		public static void PreventSurrenderIfDeathcardInPlan(ref bool __result)
		{
			if ((Object)(object)_deathcardOnBoard != (Object)null)
			{
				__result = false;
			}
		}

		[HarmonyPatch(typeof(Opponent), "QueueCard")]
		[HarmonyPostfix]
		public static IEnumerator PlayDeathcardIntro(IEnumerator sequenceEvent, CardInfo cardInfo, CardSlot slot)
		{
			CursePlugin.Log.LogInfo((object)"In QueueCard");
			sequenceEvent.MoveNext();
			yield return sequenceEvent.Current;
			sequenceEvent.MoveNext();
			int customSlot = GetHauntedCardSlot(cardInfo);
			if (customSlot >= 0)
			{
				_sawDeathcard = true;
				CursePlugin.Log.LogInfo((object)"Playing animation");
				View oldView = Singleton<ViewManager>.Instance.CurrentView;
				Singleton<ViewManager>.Instance.SwitchToView((View)33, false, false);
				_oldLoopName = ((Object)AudioController.Instance.loopSources[0].clip).name;
				_oldVolume = AudioController.Instance.loopSources[0].volume;
				AudioController.Instance.CrossFadeLoop("wind_blowing_loop", 1f, 1f, 0f);
				CursePlugin.Log.LogDebug((object)"DEATHCARDAUDIO: Cross-faded audio loop");
				ChallengeActivationUI.TryShowActivation(ID);
				yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("DeathcardArrives", (MessageAdvanceMode)1, (EventIntersectMode)0, new string[1] { cardInfo.DisplayedNameLocalized }, (Action<Line>)null);
				yield return (object)new WaitForSeconds(0.25f);
				ViewInfo targetPos = ViewManager.GetViewInfo((View)6);
				Vector3 translationOffset = targetPos.camPosition + SLOT_OFFSETS[slot.Index] - ViewManager.GetViewInfo(Singleton<ViewManager>.Instance.CurrentView).camPosition;
				Vector3 rotationOffset = targetPos.camRotation - ViewManager.GetViewInfo(Singleton<ViewManager>.Instance.CurrentView).camRotation;
				Singleton<ViewManager>.Instance.OffsetPosition(translationOffset, 0.75f);
				Singleton<ViewManager>.Instance.OffsetRotation(rotationOffset, 0.75f);
				yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("DeathcardZoom", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
				yield return (object)new WaitForSeconds(0.5f);
				Singleton<ViewManager>.Instance.SwitchToView(oldView, false, false);
			}
		}

		public static IEnumerator DeathcardOuttroSequence()
		{
			yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("DeathcardDies", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
			if (_oldLoopName != null)
			{
				CursePlugin.Log.LogDebug((object)"DEATHCARDAUDIO: Deathcard died. Resuming background audio");
				AudioController.Instance.CrossFadeLoop(_oldLoopName, 1f, _oldVolume, 0f);
				_oldLoopName = null;
			}
			else
			{
				CursePlugin.Log.LogDebug((object)"DEATHCARDAUDIO: Deathcard died. No audio to resume.");
				CursePlugin.Log.LogInfo((object)"No audio info to resume");
			}
			IncreaseHaunt(-1);
		}

		[HarmonyPatch(typeof(CandleHolder), "BlowOutCandleSequence")]
		[HarmonyPostfix]
		public static IEnumerator DeathcardWonSequence(IEnumerator sequenceResult)
		{
			if ((Object)(object)_deathcardOnBoard == (Object)null || !AscensionSaveData.Data.ChallengeIsActive(ID))
			{
				while (sequenceResult.MoveNext())
				{
					yield return sequenceResult.Current;
				}
				yield break;
			}
			sequenceResult.MoveNext();
			yield return sequenceResult.Current;
			yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("DeathcardWins", (MessageAdvanceMode)1, (EventIntersectMode)0, new string[1] { _deathcardOnBoard.DisplayedNameLocalized }, (Action<Line>)null);
			while (sequenceResult.MoveNext())
			{
				yield return sequenceResult.Current;
			}
		}

		public static void ResetHaunt(int value = 0)
		{
			CursePlugin.Log.LogInfo((object)$"Resetting haunt to {value}");
			ModdedSaveManager.RunState.SetValue("zorro.inscryption.infiniscryption.curses", "Curse.BaseHauntLevel", (object)value);
		}

		public static void IncreaseHaunt(int by = 1)
		{
			int num = Mathf.Clamp(ModdedSaveManager.RunState.GetValueAsInt("zorro.inscryption.infiniscryption.curses", "Curse.BaseHauntLevel") + by, 0, 11);
			CursePlugin.Log.LogInfo((object)$"Updated haunt by {by} to {num}");
			ModdedSaveManager.RunState.SetValue("zorro.inscryption.infiniscryption.curses", "Curse.BaseHauntLevel", (object)num.ToString());
		}

		private static void BuildOrbiters(AnimatedGameMapMarker marker)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_005a: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			CursePlugin.Log.LogInfo((object)"Adding rotating sprite");
			_orbitingFace = new List<GameObject>();
			for (int i = 0; i < 3; i++)
			{
				GameObject val = new GameObject();
				val.transform.SetParent(((Component)marker.Anim).gameObject.transform);
				val.transform.localPosition = new Vector3(0f, 0f, 0f);
				val.transform.rotation = Quaternion.LookRotation(-UP_REF);
				SpriteRenderer val2 = val.AddComponent<SpriteRenderer>();
				Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("orbit_icon.png", typeof(DeathcardHaunt).Assembly, (FilterMode)0);
				val2.sprite = Sprite.Create(imageAsTexture, new Rect(0f, 0f, (float)((Texture)imageAsTexture).width, (float)((Texture)imageAsTexture).height), new Vector2(0.5f, 0.5f));
				Orbiter orbiter = val.AddComponent<Orbiter>();
				orbiter.Cos0Vector = START_REF;
				orbiter.Sin0Vector = Vector3.Cross(START_REF, UP_REF);
				orbiter.OrbitRadius = 0.35f;
				orbiter.OrbitSpeed = 0.25f;
				orbiter.ThetaOffset = i * 120;
				orbiter.StartFromBeginning();
				_orbitingFace.Add(val);
			}
			SyncOrbiters(marker);
		}

		[HarmonyPatch(typeof(PlayerMarker), "Awake")]
		[HarmonyPostfix]
		public static void AttachAnimationToPlayerMarker(ref PlayerMarker __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (AscensionSaveData.Data.ChallengeIsActive(ID) && _orbitingFace == null)
			{
				BuildOrbiters((AnimatedGameMapMarker)(object)__instance);
			}
		}

		private static void SyncOrbiters(AnimatedGameMapMarker marker)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			if (_orbitingFace == null)
			{
				BuildOrbiters(marker);
				return;
			}
			foreach (GameObject item in _orbitingFace)
			{
				if ((Object)(object)item == (Object)null)
				{
					BuildOrbiters(marker);
					return;
				}
			}
			int hauntLevel = HauntLevel;
			CursePlugin.Log.LogInfo((object)$"Setting orbit for haunt level {hauntLevel}");
			if ((!_orbitingFace[2].activeSelf && hauntLevel >= 8) || (!_orbitingFace[1].activeSelf && hauntLevel >= 5) || (!_orbitingFace[0].activeSelf && hauntLevel >= 2))
			{
				ChallengeActivationUI.TryShowActivation(ID);
			}
			_orbitingFace[2].SetActive(hauntLevel >= 8);
			_orbitingFace[1].SetActive(hauntLevel >= 5);
			_orbitingFace[0].SetActive(hauntLevel >= 2);
			if (hauntLevel >= 8)
			{
				AchievementManager.Unlock(CursedAchievements.TRIPLE_HAUNT);
			}
		}

		[HarmonyPatch(typeof(AnimatedGameMapMarker), "Show")]
		[HarmonyPostfix]
		public static void SetActiveOrbiters(ref AnimatedGameMapMarker __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			CursePlugin.Log.LogInfo((object)"Showing map marker");
			if (AscensionSaveData.Data.ChallengeIsActive(ID) && __instance is PlayerMarker)
			{
				CursePlugin.Log.LogInfo((object)"Is player marker");
				if (_orbitingFace != null)
				{
					SyncOrbiters(__instance);
				}
				else
				{
					BuildOrbiters(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(GameMap), "ShowMapSequence")]
		[HarmonyPostfix]
		public static IEnumerator GiveHauntExplanation(IEnumerator sequenceResult)
		{
			while (sequenceResult.MoveNext())
			{
				yield return sequenceResult.Current;
			}
			if (AscensionSaveData.Data.ChallengeIsActive(ID) && !HasExplainedHaunt && HauntLevel >= 2)
			{
				yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("HauntedExplanation", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
				HasExplainedHaunt = true;
			}
		}
	}
	public static class DrawDynamite
	{
		public static AscensionChallenge ID { get; private set; }

		public static void Register(Harmony harmony)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			ID = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Exploding Cards", "Dynamite is added to your deck after every boss battle", 5, TextureHelper.GetImageAsTexture("challenge_dynamite.png", typeof(DrawDynamite).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("activated_challenge_dynamite.png", typeof(DrawDynamite).Assembly, (FilterMode)0), 0, false).Challenge.challengeType;
			harmony.PatchAll(typeof(DrawDynamite));
		}

		[HarmonyPatch(typeof(TurnManager), "CleanupPhase")]
		[HarmonyPrefix]
		public static void AddDynamiteToDeck()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (AscensionSaveData.Data.ChallengeIsActive(ID) && Singleton<TurnManager>.Instance.opponent is Part1BossOpponent && Singleton<TurnManager>.Instance.PlayerIsWinner())
			{
				((CardCollectionInfo)AscensionSaveData.Data.currentRun.playerDeck).AddCard(CardLoader.GetCardByName(ProspectorBossHardOpponent.DYNAMITE));
			}
		}

		[HarmonyPatch(typeof(CardRemoveSequencer), "GetValidCards")]
		[HarmonyPostfix]
		private static void DontAllowSacrificeDynamite(ref List<CardInfo> __result)
		{
			__result.RemoveAll((CardInfo ci) => ci.HasAbility(Dynamite.AbilityID));
		}
	}
	public static class GoldenPeltStart
	{
		public static AscensionChallenge ID { get; private set; }

		public static CardTemple ScreenState
		{
			get
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: 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)
				string value = ModdedSaveManager.SaveData.GetValue("zorro.inscryption.infiniscryption.p03kayceerun", "ScreenState");
				if (string.IsNullOrEmpty(value))
				{
					return (CardTemple)0;
				}
				return (CardTemple)Enum.Parse(typeof(CardTemple), value);
			}
		}

		public static bool IsP03Run
		{
			get
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Invalid comparison between Unknown and I4
				try
				{
					CardLoader.GetCardByName("P03KCM_Draft_Token_Rare");
				}
				catch
				{
					return false;
				}
				if (SceneLoader.ActiveSceneName.ToLowerInvariant().Contains("part3"))
				{
					return true;
				}
				if ((int)ScreenState == 2)
				{
					return true;
				}
				if (SceneLoader.ActiveSceneName.ToLowerInvariant().Contains("part1"))
				{
					return false;
				}
				if (AscensionSaveData.Data != null && AscensionSaveData.Data.currentRun != null && AscensionSaveData.Data.currentRun.playerLives > 0)
				{
					return ModdedSaveManager.SaveData.GetValueAsBoolean("zorro.inscryption.infiniscryption.p03kayceerun", "IsP03Run");
				}
				return false;
			}
		}

		public static void Register(Harmony harmony)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			FullChallenge val = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Golden Beginnings", "Start the game with the ability to draft a rare card", -10, TextureHelper.GetImageAsTexture("assist_golden_pelt.png", typeof(GoldenPeltStart).Assembly, (FilterMode)0), ChallengeManager.HAPPY_ACTIVATED_SPRITE, 0, true);
			val.SetFlags(new object[1] { "P03" });
			ID = val.Challenge.challengeType;
			harmony.PatchAll(typeof(GoldenPeltStart));
		}

		[HarmonyPatch(typeof(AscensionSaveData), "NewRun")]
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "zorro.inscryption.infiniscryption.kayceestarters" })]
		private static void AddGoldenPeltToStart(ref AscensionSaveData __instance)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			string text = (IsP03Run ? "P03KCM_Draft_Token_Rare" : "PeltGolden");
			for (int i = 0; i < AscensionSaveData.Data.GetNumChallengesOfTypeActive(ID); i++)
			{
				((CardCollectionInfo)__instance.currentRun.playerDeck).AddCard(CardLoader.GetCardByName(text));
			}
		}

		[HarmonyPatch(typeof(Part3SaveData), "Initialize")]
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "zorro.inscryption.infiniscryption.p03kayceerun" })]
		private static void AddTokenToStart(ref Part3SaveData __instance)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			string text = (IsP03Run ? "P03KCM_Draft_Token_Rare" : "PeltGolden");
			if (SaveFile.IsAscension)
			{
				for (int i = 0; i < AscensionSaveData.Data.GetNumChallengesOfTypeActive(ID); i++)
				{
					((CardCollectionInfo)__instance.deck).AddCard(CardLoader.GetCardByName(text));
				}
			}
		}

		[HarmonyPatch(typeof(MapGenerator), "ForceFirstNodeTraderForAscension")]
		[HarmonyPrefix]
		private static bool LogicUpdateForPelts(int rowIndex, ref bool __result)
		{
			__result = SaveFile.IsAscension && rowIndex == 1 && RunState.Run.regionTier == 0 && ((CardCollectionInfo)AscensionSaveData.Data.currentRun.playerDeck).Cards.Any((CardInfo ci) => CardLoader.PeltNames.Contains(((Object)ci).name));
			return false;
		}
	}
	public static class HarderBosses
	{
		private static Type[] SUPPORTED_OPPONENTS;

		public static AscensionChallenge ID { get; private set; }

		public static void Register(Harmony harmony)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			ID = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Boss Revenge", "Each boss has an additional phase", 10, TextureHelper.GetImageAsTexture("challenge_boss_revenge.png", typeof(HarderBosses).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("ascensionicon_activated_bossrevenge.png", typeof(HarderBosses).Assembly, (FilterMode)0), 0, false).Challenge.challengeType;
			harmony.PatchAll(typeof(HarderBosses));
			Dynamite.RegisterCardAndAbilities(harmony);
			Digester.RegisterCardAndAbilities(harmony);
			Bitten.RegisterCardAndAbilities(harmony);
			Bow.RegisterCardAndAbilities(harmony);
			DialogueHelper.GenerateDialogue("ProspectorExtraCandle", "Let's play longer this time!", "A lil' more fun never hurt nobody!", "I got a little somethin' special for ya!", "Heeeeeeee-haaw! Let's keep the fun goin'!");
			DialogueHelper.GenerateDialogue("AnglerExtraCandle", "You want more fish?", "We get extra fish.", "Many fish this time.");
			DialogueHelper.GenerateDialogue("TrapperTraderExtraCandle", "I'm afraid our encounter today will take a little more time", "It looks like you and I have extra business to attend to");
			DialogueHelper.GenerateDialogue("CardIsSleep", "He swalled it whole..");
			DialogueHelper.GenerateDialogue("CardAtePoison", "Eating that was a bad idea..");
			DialogueHelper.GenerateDialogue("CardAteSharp", "That's a little uncomfortable..");
			DialogueHelper.GenerateDialogue("DigestedCardDeadForever", "Your [c:bR][v:0][c:] has been fully digested. You will never see it again.");
			DialogueHelper.GenerateDialogue("DigestingCard", "Your [c:bR][v:0][c:] is being slowly digested. It has [c:bR][v:1][c:] health left.");
			DialogueHelper.GenerateLargeDialogue("TrapperTraderPhaseThree", "I have yet another trade to propose", "This time, let us trade our whole decks");
			DialogueHelper.GenerateDialogue("HungryAgain", "He's hungry again", "Time for more morsels", "Back on the hunt");
			DialogueHelper.GenerateDialogue("CatchDynamite", "Think fast!", "Catch!", "Heads up!");
			DialogueHelper.GenerateLargeDialogue("ProspectorPhaseThree", "You're a dad-gum pain in my backside!", "Let's see you get past this!");
			DialogueHelper.GenerateDialogue("AnglerPhaseThree", "Fish not big enough. Get bigger fish.", "Little fish bad. Big fish better.", "Need better fish.");
			DialogueHelper.GenerateDialogue("ProspectorWolfSpawn", "That fella looks mighty curious about that [c:bR]empty lane[c:]");
		}

		internal static IEnumerator ShowExtraBossCandle(Part1BossOpponent opponent, string dialogueEvent)
		{
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
			ChallengeActivationUI.TryShowActivation(ID);
			Singleton<ViewManager>.Instance.SwitchToView((View)19, false, false);
			yield return (object)new WaitForSeconds(0.25f);
			yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent(dialogueEvent, (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
			yield return (object)new WaitForSeconds(0.4f);
			((Component)opponent).gameObject.GetComponentInChildren<BossSkull>().EnterHand();
			yield return (object)new WaitForSeconds(3.5f);
			Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
		}

		private static void AddBossSequencer<T>(TurnManager manager) where T : SpecialBattleSequencer
		{
			Object.Destroy((Object)(object)manager.SpecialSequencer);
			SpecialBattleSequencer value = (SpecialBattleSequencer)(object)((Component)manager).gameObject.AddComponent<T>();
			Traverse val = Traverse.Create((object)manager);
			val.Property("SpecialSequencer", (object[])null).SetValue((object)value);
		}

		[HarmonyPatch(typeof(TurnManager), "UpdateSpecialSequencer")]
		[HarmonyPrefix]
		public static bool ReplaceSequencers(string specialBattleId, ref TurnManager __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (AscensionSaveData.Data.ChallengeIsActive(ID))
			{
				if (specialBattleId == BossBattleSequencer.GetSequencerIdForBoss((Type)3))
				{
					AddBossSequencer<ProspectorBossHardSequencer>(__instance);
					return false;
				}
				if (specialBattleId == BossBattleSequencer.GetSequencerIdForBoss((Type)4))
				{
					AddBossSequencer<AnglerBossHardSequencer>(__instance);
					return false;
				}
				if (specialBattleId == BossBattleSequencer.GetSequencerIdForBoss((Type)6))
				{
					AddBossSequencer<TrapperTraderBossHardSequencer>(__instance);
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(Opponent), "SpawnOpponent")]
		[HarmonyPrefix]
		public static bool ReplaceOpponent(EncounterData encounterData, ref Opponent __result)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected I4, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if (!AscensionSaveData.Data.ChallengeIsActive(ID))
			{
				return true;
			}
			if (!SUPPORTED_OPPONENTS.Contains(encounterData.opponentType))
			{
				return true;
			}
			GameObject val = new GameObject();
			((Object)val).name = "Opponent";
			Type opponentType = encounterData.opponentType;
			Type val2 = opponentType;
			Type val3 = val2;
			Opponent val4 = (Opponent)((val3 - 3) switch
			{
				0 => val.AddComponent<ProspectorBossHardOpponent>(), 
				1 => val.AddComponent<AnglerBossHardOpponent>(), 
				3 => val.AddComponent<TrapperTraderBossHardOpponent>(), 
				_ => throw new InvalidOperationException("Somehow got into a patch for hard opponents with an unsupported opponent"), 
			});
			string text = encounterData.aiId;
			if (string.IsNullOrEmpty(text))
			{
				text = "AI";
			}
			? val5 = val4;
			object? obj = Activator.CreateInstance(CustomType.GetType("DiskCardGame", text));
			((Opponent)val5).AI = (AI)((obj is AI) ? obj : null);
			val4.NumLives = val4.StartingLives;
			val4.OpponentType = opponentType;
			val4.TurnPlan = val4.ModifyTurnPlan(encounterData.opponentTurnPlan);
			val4.Blueprint = encounterData.Blueprint;
			val4.Difficulty = encounterData.Difficulty;
			val4.ExtraTurnsToSurrender = SeededRandom.Range(0, 3, SaveManager.SaveFile.GetCurrentRandomSeed());
			__result = val4;
			return false;
		}

		static HarderBosses()
		{
			Type[] array = new Type[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			SUPPORTED_OPPONENTS = (Type[])(object)array;
		}
	}
	public static class NoOneHitKills
	{
		public static AscensionChallenge ID { get; private set; }

		public static void Register(Harmony harmony)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			ID = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Two Turn Minimum", "You cannot deal lethal damage on the first turn.", 10, TextureHelper.GetImageAsTexture("challenge_no_ohk.png", typeof(NoOneHitKills).Assembly, (FilterMode)0), ChallengeManager.DEFAULT_ACTIVATED_SPRITE, 0, false).Challenge.challengeType;
			harmony.PatchAll(typeof(NoOneHitKills));
		}

		[HarmonyPatch(typeof(LifeManager), "ShowDamageSequence")]
		[HarmonyPrefix]
		public static void StopLethalTurnOneDamage(ref int damage, ref int numWeights, bool toPlayer)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (!(!AscensionSaveData.Data.ChallengeIsActive(ID) || toPlayer) && Singleton<TurnManager>.Instance.TurnNumber <= 1 && damage >= Singleton<LifeManager>.Instance.DamageUntilPlayerWin)
			{
				Singleton<ChallengeActivationUI>.Instance.ShowActivation(ID);
				damage = Singleton<LifeManager>.Instance.DamageUntilPlayerWin - 1;
				numWeights = damage;
			}
		}
	}
	public static class RandomSigils
	{
		private static Ability[] EXCLUDED_SIGILS;

		public static AscensionChallenge ID { get; private set; }

		public static void Register(Harmony harmony)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			FullChallenge val = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Chaotic Enemies", "Opposing creatures gain random abilities", 15, TextureHelper.GetImageAsTexture("challenge_random_sigils.png", typeof(RandomSigils).Assembly, (FilterMode)0), ChallengeManager.DEFAULT_ACTIVATED_SPRITE, 0, true);
			val.SetFlags(new object[1] { "P03" });
			ID = val.Challenge.challengeType;
			harmony.PatchAll(typeof(RandomSigils));
		}

		[HarmonyPatch(typeof(TurnManager), "SetupPhase")]
		[HarmonyPrefix]
		private static void AlwaysInstantiateConduitManager()
		{
			if ((Object)(object)Singleton<ConduitCircuitManager>.Instance == (Object)null)
			{
				((Component)Singleton<BoardManager>.Instance).gameObject.AddComponent<ConduitCircuitManager>();
			}
		}

		[HarmonyPatch(typeof(Part1Opponent), "ShowDifficultyChallengeUIIfTurnIsHarder")]
		[HarmonyPrefix]
		public static void ActivateRandomSigilsAlert(ref Part1Opponent __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (AscensionSaveData.Data.ChallengeIsActive(ID))
			{
				Singleton<ChallengeActivationUI>.Instance.ShowActivation(ID);
			}
		}

		[HarmonyPatch(typeof(EncounterBuilder), "BuildOpponentTurnPlan")]
		[HarmonyPostfix]
		public static void AddSigilsToCards(ref List<List<CardInfo>> __result)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_0236: 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_0203: Unknown result type (might be due to invalid IL or missing references)
			int num = SaveManager.SaveFile.GetCurrentRandomSeed() + 10;
			if (!AscensionSaveData.Data.ChallengeIsActive(ID))
			{
				return;
			}
			foreach (List<CardInfo> item in __result)
			{
				for (int i = 0; i < item.Count; i++)
				{
					if (item[i].SpecialAbilities.Where((SpecialTriggeredAbility tr) => (int)tr == 10).Count() > 0 || item[i].Mods.Where((CardModificationInfo mod) => mod.deathCardInfo != null).Count() > 0 || item[i].HasTrait((Trait)16))
					{
						continue;
					}
					CardModificationInfo val = new CardModificationInfo();
					val.fromCardMerge = SaveManager.SaveFile.IsPart1;
					val.abilities = new List<Ability>();
					CardInfo val3 = (item[i] = (CardInfo)/*isinst with value type is only supported in some contexts*/);
					CardInfo card = val3;
					for (int j = 0; j < AscensionSaveData.Data.GetNumChallengesOfTypeActive(ID); j++)
					{
						List<Ability> list = (from ab in ScriptableObjectLoader<AbilityInfo>.AllData
							where ab.PositiveEffect && ab.opponentUsable && !card.Abilities.Contains(ab.ability) && !EXCLUDED_SIGILS.Contains(ab.ability)
							select ab.ability).ToList();
						if (list.Count == 0)
						{
							CursePlugin.Log.LogDebug((object)("Could not add any ability to " + ((Object)card).name));
							continue;
						}
						val.abilities.Add(list[SeededRandom.Range(0, list.Count, num)]);
						CursePlugin.Log.LogDebug((object)$"Adding {val.abilities.Last()} to {((Object)card).name}");
						num++;
					}
					card.Mods.Add(val);
				}
			}
		}

		static RandomSigils()
		{
			Ability[] array = new Ability[5];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			EXCLUDED_SIGILS = (Ability[])(object)array;
		}
	}
	public static class StartWithTribalTotems
	{
		public static AscensionChallenge ID { get; private set; }

		public static void Register(Harmony harmony)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			ID = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Totem Collector", "You start with all tribal totem tops", -15, Resources.Load<Texture2D>("art/ui/ascension/ascensionicon_totems"), ChallengeManager.HAPPY_ACTIVATED_SPRITE, 0, false).Challenge.challengeType;
			harmony.PatchAll(typeof(StartWithTribalTotems));
		}

		[HarmonyPatch(typeof(AscensionSaveData), "NewRun")]
		[HarmonyPostfix]
		public static void SetNumberOfLives(ref AscensionSaveData __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (AscensionSaveData.Data.ChallengeIsActive(ID))
			{
				__instance.currentRun.totemTops.Clear();
				__instance.currentRun.totemTops.AddRange(from t in GuidManager.GetValues<Tribe>()
					where (int)t != 0 && (int)t < 7
					select t);
			}
		}
	}
	public static class ThreeCandles
	{
		public static AscensionChallenge ID { get; private set; }

		public static void Register(Harmony harmony)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			FullChallenge val = ChallengeManager.Add("zorro.inscryption.infiniscryption.curses", "Extra Candle", "You are given an extra life", -30, TextureHelper.GetImageAsTexture("assist_three_candles.png", typeof(DrawDynamite).Assembly, (FilterMode)0), ChallengeManager.HAPPY_ACTIVATED_SPRITE, 0, false);
			ID = val.Challenge.challengeType;
			harmony.PatchAll(typeof(ThreeCandles));
		}

		[HarmonyPatch(typeof(AscensionSaveData), "NewRun")]
		[HarmonyPostfix]
		public static void SetNumberOfLives(ref AscensionSaveData __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (AscensionSaveData.Data.ChallengeIsActive(ID))
			{
				if (AscensionSaveData.Data.ChallengeIsActive((AscensionChallenge)6))
				{
					__instance.currentRun.playerLives = 2;
					__instance.currentRun.maxPlayerLives = 2;
				}
				else
				{
					__instance.currentRun.playerLives = 3;
					__instance.currentRun.maxPlayerLives = 3;
				}
			}
		}
	}
}
namespace Infiniscryption.Curses.Helpers
{
	[HarmonyPatch]
	internal static class AudioHelper
	{
		[HarmonyPatch(typeof(AudioController), "Awake")]
		[HarmonyPostfix]
		internal static void LoadMyCustomAudio(ref AudioController __instance)
		{
			string[] array = new string[3] { "card_explosion", "gulp", "wind_blowing_loop" };
			foreach (string clipName in array)
			{
				if (!__instance.SFX.Any((AudioClip ac) => ((Object)ac).name.Equals(clipName, StringComparison.InvariantCultureIgnoreCase)))
				{
					AudioClip val = SoundManager.LoadAudioClip("zorro.inscryption.infiniscryption.curses", clipName + ".wav");
					((Object)val).name = clipName;
					if (clipName.Equals("wind_blowing_loop"))
					{
						__instance.Loops.Add(val);
					}
					else
					{
						__instance.SFX.Add(val);
					}
				}
			}
		}
	}
	internal static class DialogueHelper
	{
		private static Tuple<List<CustomLine>, List<List<CustomLine>>> LinesHelper(params string[] lines)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			List<CustomLine> list = new List<CustomLine>();
			CustomLine item = default(CustomLine);
			((CustomLine)(ref item))..ctor();
			item.text = lines[0];
			list.Add(item);
			List<CustomLine> item2 = list;
			List<List<CustomLine>> item3 = lines.Skip(1).Select(delegate(string l)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				List<CustomLine> list2 = new List<CustomLine>();
				CustomLine item4 = default(CustomLine);
				((CustomLine)(ref item4))..ctor();
				item4.text = l;
				list2.Add(item4);
				return list2;
			}).ToList();
			return new Tuple<List<CustomLine>, List<List<CustomLine>>>(item2, item3);
		}

		internal static void GenerateVeryLargeDialogue(string dialogueId, Speaker speaker, params string[][] lines)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			List<CustomLine> list = lines[0].Select(delegate(string l)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				CustomLine result2 = default(CustomLine);
				((CustomLine)(ref result2))..ctor();
				result2.text = l;
				return result2;
			}).ToList();
			List<List<CustomLine>> list2 = (from ls in lines.Skip(1)
				select ls.Select(delegate(string l)
				{
					//IL_000f: Unknown result type (might be due to invalid IL or missing references)
					CustomLine result = default(CustomLine);
					((CustomLine)(ref result))..ctor();
					result.text = l;
					return result;
				}).ToList()).ToList();
			DialogueManager.Add("zorro.inscryption.infiniscryption.curses", DialogueManager.GenerateEvent("zorro.inscryption.infiniscryption.curses", dialogueId, list, list2, (MaxRepeatsBehaviour)0, speaker));
		}

		internal static void GenerateVeryLargeDialogue(string dialogueId, params string[][] lines)
		{
			GenerateVeryLargeDialogue(dialogueId, (Speaker)1, lines);
		}

		internal static void GenerateLargeDialogue(string dialogueId, Speaker speaker, params string[] lines)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			List<CustomLine> list = lines.Select(delegate(string l)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				CustomLine result = default(CustomLine);
				((CustomLine)(ref result))..ctor();
				result.text = l;
				return result;
			}).ToList();
			DialogueManager.Add("zorro.inscryption.infiniscryption.curses", DialogueManager.GenerateEvent("zorro.inscryption.infiniscryption.curses", dialogueId, list, (List<List<CustomLine>>)null, (MaxRepeatsBehaviour)0, speaker));
		}

		internal static void GenerateLargeDialogue(string dialogueId, params string[] lines)
		{
			GenerateLargeDialogue(dialogueId, (Speaker)1, lines);
		}

		internal static void GenerateDialogue(string dialogueId, Speaker speaker, params string[] lines)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Tuple<List<CustomLine>, List<List<CustomLine>>> tuple = LinesHelper(lines);
			DialogueManager.Add("zorro.inscryption.infiniscryption.curses", DialogueManager.GenerateEvent("zorro.inscryption.infiniscryption.curses", dialogueId, tuple.Item1, tuple.Item2, (MaxRepeatsBehaviour)0, speaker));
		}

		internal static void GenerateDialogue(string dialogueId, params string[] lines)
		{
			GenerateDialogue(dialogueId, (Speaker)1, lines);
		}
	}
}
namespace Infiniscryption.Curses.Components
{
	public class Orbiter : ManagedBehaviour
	{
		private const float FULL_ROTATION = 360f;

		private float _orbitRadius = 1f;

		private Vector3 _rotationAxis = Vector3.Cross(Vector3.forward, Vector3.up);

		private Vector3 _cos0vector = Vector3.forward;

		private Vector3 _sin0vector = Vector3.up;

		public bool Reversed { get; set; }

		public float OrbitSpeed { get; set; } = 0.333f;


		public float OrbitRadius
		{
			get
			{
				return _orbitRadius;
			}
			set
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: 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)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				_orbitRadius = value;
				_cos0vector = Vector3.Normalize(_cos0vector) * value;
				_sin0vector = Vector3.Normalize(_sin0vector) * value;
			}
		}

		public float ThetaOffset { get; set; } = 0f;


		public bool RandomThetaOffset { get; set; }

		public Vector3 Cos0Vector
		{
			get
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				return _cos0vector;
			}
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				_cos0vector = Vector3.Normalize(value) * OrbitRadius;
				_rotationAxis = Vector3.Normalize(Vector3.Cross(value, Sin0Vector));
			}
		}

		public Vector3 Sin0Vector
		{
			get
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				return _sin0vector;
			}
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				_sin0vector = Vector3.Normalize(value) * OrbitRadius;
				_rotationAxis = Vector3.Normalize(Vector3.Cross(Cos0Vector, _sin0vector));
			}
		}

		private float Theta { get; set; }

		private void Awake()
		{
			if (RandomThetaOffset)
			{
				Theta = Random.Range(0f, 360f);
			}
			else
			{
				Theta = ThetaOffset;
			}
			SetLocation();
		}

		private void Start()
		{
			((Behaviour)this).enabled = true;
		}

		public void StartFromBeginning()
		{
			((Behaviour)this).enabled = true;
			if (RandomThetaOffset)
			{
				Theta = Random.Range(0f, 360f);
			}
			else
			{
				Theta = ThetaOffset;
			}
		}

		public void Stop()
		{
			((Behaviour)this).enabled = false;
		}

		private void SetLocation()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = Quaternion.AngleAxis(Theta, _rotationAxis) * Cos0Vector;
			((Component)this).transform.localPosition = localPosition;
		}

		public override void ManagedUpdate()
		{
			if (((Behaviour)this).enabled)
			{
				float num = (((ManagedBehaviour)this).UpdateWhenPaused ? Time.unscaledDeltaTime : Time.deltaTime);
				Theta += 360f * OrbitSpeed * num * (Reversed ? (-1f) : 1f);
				while (Theta > 360f)
				{
					Theta -= 360f;
				}
				while (Theta < -360f)
				{
					Theta += 360f;
				}
				SetLocation();
			}
		}
	}
}
namespace Infiniscryption.Curses.Cards
{
	public class Bitten : AbilityBehaviour
	{
		public static Ability AbilityID { get; private set; }

		public override Ability Ability => AbilityID;

		public static void RegisterCardAndAbilities(Harmony harmony)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Bitten By Predator";
			val.rulebookDescription = "This card was bitten by a predator";
			val.canStack = false;
			val.powerLevel = -2;
			val.opponentUsable = false;
			val.passive = false;
			val.metaCategories = new List<AbilityMetaCategory>();
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.curses", val, typeof(Bitten), (Texture)(object)Resources.Load<Texture2D>("art/cards/abilityicons/ability_deathtouch")).Id;
			harmony.PatchAll(typeof(Bitten));
		}

		[HarmonyPatch(typeof(Card), "ApplyAppearanceBehaviours")]
		[HarmonyPostfix]
		public static void SpellBackground(ref Card __instance)
		{
			if (__instance.Info.Abilities.Any((Ability sp) => sp == AbilityID))
			{
				((CardAppearanceBehaviour)((Component)__instance).gameObject.AddComponent<BittenCardAppearance>()).ApplyAppearance();
			}
		}

		[HarmonyPatch(typeof(CardAbilityIcons), "GetDistinctShownAbilities")]
		[HarmonyPostfix]
		public static void DontShowThisIcon(ref List<Ability> __result)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			__result.Remove(AbilityID);
		}
	}
	public class BittenCardAppearance : CardAppearanceBehaviour
	{
		private static Texture2D _sharkBiteDecal = TextureHelper.GetImageAsTexture("shark_bite_decal.png", typeof(BittenCardAppearance).Assembly, (FilterMode)0);

		private static Texture2D _sharkBiteBackground = TextureHelper.GetImageAsTexture("card_empty_sharkbite.png", typeof(BittenCardAppearance).Assembly, (FilterMode)0);

		public static Appearance ID { get; private set; }

		public override void ApplyAppearance()
		{
			((CardAppearanceBehaviour)this).Card.Info.temporaryDecals = new List<Texture>();
			((CardAppearanceBehaviour)this).Card.RenderInfo.baseTextureOverride = (Texture)(object)_sharkBiteBackground;
			if (!((CardAppearanceBehaviour)this).Card.Info.TempDecals.Any((Texture t) => ((Object)t).name == ((Object)_sharkBiteDecal).name))
			{
				((CardAppearanceBehaviour)this).Card.Info.TempDecals.Add((Texture)(object)_sharkBiteDecal);
			}
		}

		public static void Register()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			ID = CardAppearanceBehaviourManager.Add("zorro.inscryption.infiniscryption.curses", "BittenByShark", typeof(BittenCardAppearance)).Id;
		}
	}
	public static class Bow
	{
		public static void RegisterCardAndAbilities(Harmony harmony)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected I4, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected I4, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected I4, but got Unknown
			CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardHelpers.SetTargetedSpell(CardManager.New("CURSES", TrapperTraderBossHardOpponent.BOW_CARD, "Bow and Arrow", 0, 0, (string)null)), TextureHelper.GetImageAsTexture("portrait_bow.png", typeof(Bow).Assembly, (FilterMode)0), (FilterMode?)null), (Ability[])(object)new Ability[2]
			{
				(Ability)(int)DirectDamage.AbilityID,
				(Ability)(int)DirectDamage.AbilityID
			});
			CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardHelpers.SetTargetedSpell(CardManager.New("CURSES", TrapperTraderBossHardOpponent.CAPTURE_CARD, "Capture", 0, 0, (string)null)), TextureHelper.GetImageAsTexture("portrait_capture.png", typeof(Bow).Assembly, (FilterMode)0), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)(int)Fishhook.AbilityID });
			CardExtensions.AddAbilities(CardExtensions.AddAppearances(CardExtensions.AddTraits(CardExtensions.SetPortrait(CardManager.New("CURSES", TrapperTraderBossHardOpponent.SPIKE_TRAP_CARD, "Spike Trap", 0, 2, (string)null), TextureHelper.GetImageAsTexture("portrait_spike_trap.png", typeof(Bow).Assembly, (FilterMode)0), (FilterMode?)null), (Trait[])(object)new Trait[1] { (Trait)12 }), (Appearance[])(object)new Appearance[2]
			{
				(Appearance)2,
				(Appearance)9
			}), (Ability[])(object)new Ability[2]
			{
				(Ability)15,
				(Ability)83
			});
		}
	}
	public class Digester : SpecialCardBehaviour
	{
		public const string GULP_SOUND = "gulp";

		public static SpecialTriggeredAbility ID { get; private set; }

		public override int Priority => int.MinValue;

		private CardInfo StomachContents
		{
			get
			{
				if (((Card)((SpecialCardBehaviour)this).PlayableCard).Info.iceCubeParams == null || ((SpecialCardBehaviour)this).PlayableCard.HasAbility((Ability)26))
				{
					return null;
				}
				return ((Card)((SpecialCardBehaviour)this).PlayableCard).Info.iceCubeParams.creatureWithin;
			}
			set
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Expected O, but got Unknown
				if (!((SpecialCardBehaviour)this).PlayableCard.HasAbility((Ability)26))
				{
					if ((Object)(object)value == (Object)null)
					{
						((Card)((SpecialCardBehaviour)this).PlayableCard).Info.iceCubeParams = null;
						return;
					}
					((Card)((SpecialCardBehaviour)this).PlayableCard).Info.iceCubeParams = new IceCubeParams
					{
						creatureWithin = value
					};
				}
			}
		}

		public static void RegisterCardAndAbilities(Harmony harmony)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected I4, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected I4, but got Unknown
			MegaSharkAppearance.Register();
			ID = SpecialTriggeredAbilityManager.Add("zorro.inscryption.infiniscryption.curses", "Swallow Whole", typeof(Digester)).Id;
			CardExtensions.AddSpecialAbilities(CardExtensions.AddAppearances(CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardExtensions.AddTraits(CardManager.New("CURSES", AnglerBossHardOpponent.MEGA_SHARK, "Mega Shark", 3, 5, (string)null), (Trait[])(object)new Trait[1] { (Trait)14 }), MegaSharkAppearance.SHARK_OPEN_PORTRAIT, MegaSharkAppearance.SHARK_OPEN_EMISSION, (FilterMode?)null), (Ability[])(object)new Ability[2]
			{
				(Ability)23,
				(Ability)8
			}), (Appearance[])(object)new Appearance[1] { (Appearance)(int)MegaSharkAppearance.ID }), (SpecialTriggeredAbility[])(object)new SpecialTriggeredAbility[1] { (SpecialTriggeredAbility)(int)ID });
			RuntimeHelpers.RunClassConstructor(typeof(Digester).TypeHandle);
			RuntimeHelpers.RunClassConstructor(typeof(Bitten).TypeHandle);
			RuntimeHelpers.RunClassConstructor(typeof(BittenCardAppearance).TypeHandle);
			RuntimeHelpers.RunClassConstructor(typeof(MegaSharkAppearance).TypeHandle);
			TextureHelper.RegisterEmissionForSprite(MegaSharkAppearance.SHARK_CLOSED_PORTRAIT_SPRITE, MegaSharkAppearance.SHARK_CLOSED_EMISSION_SPRITE);
			harmony.PatchAll(typeof(Digester));
		}

		[HarmonyPatch(typeof(Card), "ApplyAppearanceBehaviours")]
		[HarmonyPostfix]
		public static void SpellBackground(ref Card __instance)
		{
			if (((Object)__instance.Info).name == "Angler_Shark")
			{
				((CardAppearanceBehaviour)((Component)__instance).gameObject.AddComponent<MegaSharkAppearance>()).ApplyAppearance();
			}
		}

		private void UpdateAppearances()
		{
			CardAppearanceBehaviour[] components = ((Component)((SpecialCardBehaviour)this).PlayableCard).GetComponents<CardAppearanceBehaviour>();
			foreach (CardAppearanceBehaviour val in components)
			{
				val.ApplyAppearance();
			}
		}

		private IEnumerator TransitionAwayFromDigestingState()
		{
			Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
			List<CardModificationInfo> modsToRemove = ((SpecialCardBehaviour)this).PlayableCard.TemporaryMods.Where((CardModificationInfo mod) => mod.attackAdjustment == -1000).ToList();
			foreach (CardModificationInfo mod2 in modsToRemove)
			{
				((SpecialCardBehaviour)this).PlayableCard.TemporaryMods.Remove(mod2);
			}
			UpdateAppearances();
			((Card)((SpecialCardBehaviour)this).PlayableCard).Anim.SetShaking(true);
			yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("HungryAgain", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
			((Card)((SpecialCardBehaviour)this).PlayableCard).Anim.SetShaking(false);
		}

		private IEnumerator EatCard(PlayableCard target, bool attackerWasMeal)
		{
			if (attackerWasMeal)
			{
				((Card)((SpecialCardBehaviour)this).PlayableCard).Anim.PlayTransformAnimation();
				yield return (object)new WaitForSeconds(0.2f);
			}
			AudioController.Instance.PlaySound3D("gulp", (MixerGroup)5, ((Component)((SpecialCardBehaviour)this).Card).transform.position, 1f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
			yield return (object)new WaitForSeconds(0.1f);
			StomachContents = ((Card)target).Info;
			((MonoBehaviour)((Card)target).Anim).StopAllCoroutines();
			target.UnassignFromSlot();
			Object.Destroy((Object)(object)((Component)target).gameObject, 0.1f);
			((SpecialCardBehaviour)this).PlayableCard.TemporaryMods.Add(new CardModificationInfo(-1000, 0));
			UpdateAppearances();
			((Card)((SpecialCardBehaviour)this).PlayableCard).Anim.SetShaking(true);
			yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("CardIsSleep", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
			((Card)((SpecialCardBehaviour)this).PlayableCard).Anim.SetShaking(false);
		}

		private void AddModToCard(CardInfo card, CardModificationInfo mod)
		{
			if (((CardCollectionInfo)RunState.Run.playerDeck).Cards.Contains(card))
			{
				RunState.Run.playerDeck.ModifyCard(card, mod);
			}
			else
			{
				card.Mods.Add(mod);
			}
		}

		private IEnumerator Digest()
		{
			if ((Object)(object)StomachContents == (Object)null)
			{
				yield break;
			}
			Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
			((Card)((SpecialCardBehaviour)this).PlayableCard).Anim.PlayTransformAnimation();
			yield return (object)new WaitForSeconds(0.3f);
			if (StomachContents.traits.Any((Trait tr) => (int)tr == 19))
			{
				yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("CardAtePoison", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
				yield return ExpelCard();
				yield return ((SpecialCardBehaviour)this).PlayableCard.Die(true, (PlayableCard)null, true);
				yield break;
			}
			int internalDamage = StomachContents.Abilities.Where((Ability ab) => (int)ab == 15).Count();
			if (internalDamage > 0)
			{
				yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("CardAteSharp", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
				bool quitAfterTakeDamage = false;
				if (internalDamage > ((SpecialCardBehaviour)this).PlayableCard.Health)
				{
					yield return ExpelCard();
					quitAfterTakeDamage = true;
				}
				yield return ((SpecialCardBehaviour)this).PlayableCard.TakeDamage(internalDamage, (PlayableCard)null);
				if (quitAfterTakeDamage)
				{
					yield break;
				}
			}
			if ((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null || ((SpecialCardBehaviour)this).PlayableCard.Health <= 0 || ((SpecialCardBehaviour)this).PlayableCard.Dead || (Object)(object)StomachContents == (Object)null)
			{
				yield break;
			}
			bool isMainDeckCard = ((CardCollectionInfo)RunState.Run.playerDeck).Cards.Any((CardInfo c) => ((Object)c).name == ((Object)StomachContents).name);
			if (!StomachContents.HasAbility(Bitten.AbilityID) && isMainDeckCard)
			{
				AddModToCard(mod: new CardModificationInfo(Bitten.AbilityID), card: StomachContents);
			}
			else
			{
				AddModToCard(StomachContents, new CardModificationInfo(-1, -1));
			}
			if (StomachContents.Health > 0)
			{
				if (internalDamage == 0)
				{
					yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("DigestingCard", (MessageAdvanceMode)1, (EventIntersectMode)0, new string[2]
					{
						StomachContents.DisplayedNameLocalized,
						StomachContents.Health.ToString()
					}, (Action<Line>)null);
				}
				yield break;
			}
			if (((SpecialCardBehaviour)this).PlayableCard.OpponentCard && ((CardCollectionInfo)SaveManager.SaveFile.CurrentDeck).Cards.Contains(StomachContents))
			{
				((CardCollectionInfo)SaveManager.SaveFile.CurrentDeck).RemoveCard(StomachContents);
				yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("DigestedCardDeadForever", (MessageAdvanceMode)1, (EventIntersectMode)0, new string[1] { StomachContents.DisplayedNameLocalized }, (Action<Line>)null);
			}
			StomachContents = null;
			yield return TransitionAwayFromDigestingState();
		}

		public override bool RespondsToUpkeep(bool playerUpkeep)
		{
			if (((Card)((SpecialCardBehaviour)this).PlayableCard).Info.iceCubeParams == null || (Object)(object)((Card)((SpecialCardBehaviour)this).PlayableCard).Info.iceCubeParams.creatureWithin == (Object)null)
			{
				return false;
			}
			return (((SpecialCardBehaviour)this).PlayableCard.OpponentCard && !playerUpkeep) || (!((SpecialCardBehaviour)this).PlayableCard.OpponentCard && playerUpkeep);
		}

		public override IEnumerator OnUpkeep(bool playerUpkeep)
		{
			yield return Digest();
			CursePlugin.Log.LogInfo((object)"Upkeep complete");
		}

		public override bool RespondsToSlotTargetedForAttack(CardSlot slot, PlayableCard attacker)
		{
			return true;
		}

		public override IEnumerator OnSlotTargetedForAttack(CardSlot slot, PlayableCard attacker)
		{
			if ((Object)(object)slot.Card == (Object)null || (Object)(object)attacker == (Object)null)
			{
				yield break;
			}
			PlayableCard defender = slot.Card;
			if (((Object)(object)attacker != (Object)(object)((SpecialCardBehaviour)this).PlayableCard && (Object)(object)slot.Card != (Object)(object)((SpecialCardBehaviour)this).PlayableCard) || (Object)(object)StomachContents != (Object)null)
			{
				yield break;
			}
			PlayableCard meal = (((Object)(object)attacker == (Object)(object)((SpecialCardBehaviour)this).PlayableCard) ? defender : attacker);
			if (!attacker.HasAbility((Ability)19) || defender.HasAbility((Ability)23) || defender.HasAbility((Ability)19))
			{
				bool hitHappened = false;
				((Card)attacker).Anim.PlayAttackAnimation(false, slot, (Action)delegate
				{
					((Card)attacker).Anim.SetAnimationPaused(true);
					hitHappened = true;
				});
				yield return (object)new WaitUntil((Func<bool>)(() => hitHappened));
				yield return EatCard(meal, (Object)(object)meal == (Object)(object)attacker);
				if ((Object)(object)attacker != (Object)null && attacker.OnBoard)
				{
					((Card)attacker).Anim.SetAnimationPaused(false);
				}
			}
		}

		public override bool RespondsToDie(bool wasSacrifice, PlayableCard killer)
		{
			return (Object)(object)StomachContents != (Object)null;
		}

		private IEnumerator ExpelCard()
		{
			CardInfo digestedCard = StomachContents;
			if ((Object)(object)digestedCard == (Object)null)
			{
				yield break;
			}
			if (((SpecialCardBehaviour)this).PlayableCard.OpponentCard)
			{
				Singleton<ViewManager>.Instance.SwitchToView((View)0, false, false);
				if (digestedCard.HasAbility(Bitten.AbilityID))
				{
					AchievementManager.Unlock(CursedAchievements.SHARK_POP);
				}
				PlayableCard spawnedCard = CardSpawner.SpawnPlayableCard(digestedCard);
				yield return Singleton<PlayerHand>.Instance.AddCardToHand(spawnedCard, Vector3.zero, 0f);
				Singleton<PlayerHand>.Instance.OnCardInspected(spawnedCard);
				Singleton<PlayerHand>.Instance.InspectingLocked = true;
				((Card)spawnedCard).Anim.PlayHitAnimation();
				yield return (object)new WaitForSeconds(0.6f);
				Singleton<PlayerHand>.Instance.InspectingLocked = false;
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
			}
			StomachContents = null;
		}

		public override IEnumerator OnDie(bool wasSacrifice, PlayableCard killer)
		{
			yield return ExpelCard();
		}

		public override void OnCleanUp()
		{
			((SpecialCardBehaviour)this).OnCleanUp();
			StomachContents = null;
		}
	}
	[HarmonyPatch]
	public class Dynamite : AbilityBehaviour
	{
		public const string EXPLOSION_SOUND = "card_explosion";

		private bool _blewUp = false;

		private int _lastKnownDamage = 2;

		public override Ability Ability => AbilityID;

		public static Ability AbilityID { get; private set; }

		public int Damage
		{
			get
			{
				try
				{
					_lastKnownDamage = (((Card)((AbilityBehaviour)this).Card).Info.Mods.Any((CardModificationInfo m) => m.fromDuplicateMerge) ? 4 : 2);
					return _lastKnownDamage;
				}
				catch
				{
					return _lastKnownDamage;
				}
			}
		}

		public static void RegisterCardAndAbilities(Harmony harmony)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected I4, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected I4, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			DynamiteAppearance.Register();
			AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
			val.rulebookName = "Booby Trap";
			val.rulebookDescription = "If this is in your hand at the end of your turn, it explodes. If it is on the board at the end of your opponent's turn, it explodes. Either way, it explodes.";
			val.canStack = true;
			val.powerLevel = -2;
			val.opponentUsable = false;
			val.passive = false;
			val.metaCategories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
			DialogueHelper.GenerateDialogue("MycologistsDynamite", "This is more difficult than anticipated...");
			DialogueHelper.GenerateDialogue("MycologistsDynamiteSuccess", "We - We may have made things worse");
			AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.curses", val, typeof(Dynamite), (Texture)(object)TextureHelper.GetImageAsTexture("ability_dynamite.png", typeof(Dynamite).Assembly, (FilterMode)0)).Id;
			CardExtensions.AddAppearances(CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardExtensions.AddTraits(CardManager.New("CURSES", ProspectorBossHardOpponent.DYNAMITE, "Dynamite", 0, 2, (string)null), (Trait[])(object)new Trait[1] { (Trait)12 }), TextureHelper.GetImageAsTexture("dynamite_portrait.png", typeof(Dynamite).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("dynamite_emission.png", typeof(Dynamite).Assembly, (FilterMode)0), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)(int)AbilityID }), (Appearance[])(object)new Appearance[1] { (Appearance)(int)DynamiteAppearance.ID }).temple = (CardTemple)0;
			RuntimeHelpers.RunClassConstructor(typeof(Dynamite).TypeHandle);
			RuntimeHelpers.RunClassConstructor(typeof(DynamiteAppearance).TypeHandle);
			harmony.PatchAll(typeof(Dynamite));
		}

		[HarmonyPatch(typeof(TurnManager), "PlayerTurn")]
		[HarmonyPostfix]
		public static IEnumerator ExplodeAtEndOfTurn(IEnumerator sequenceEvent)
		{
			yield return sequenceEvent;
			if (!((Object)(object)Singleton<PlayerHand>.Instance != (Object)null))
			{
				yield break;
			}
			List<PlayableCard> cardsToExplode = Singleton<PlayerHand>.Instance.CardsInHand.Where((PlayableCard c) => ((Card)c).Info.Abilities.Any((Ability a) => a == AbilityID)).ToList();
			object[] upkeepVars = new object[1] { true };
			foreach (PlayableCard card in cardsToExplode)
			{
				yield return card.TriggerHandler.OnTrigger((Trigger)13, upkeepVars);
			}
		}

		public override bool RespondsToDie(bool wasSacrifice, PlayableCard killer)
		{
			return true;
		}

		public override IEnumerator OnDie(bool wasSacrifice, PlayableCard killer)
		{
			if (!_blewUp)
			{
				AchievementManager.Unlock(CursedAchievements.HOT_POTATO);
			}
			yield break;
		}

		public override bool RespondsToTurnEnd(bool playerTurnEnd)
		{
			return playerTurnEnd;
		}

		public override IEnumerator OnTurnEnd(bool playerTurnEnd)
		{
			if (!playerTurnEnd)
			{
				yield break;
			}
			_blewUp = true;
			if (((AbilityBehaviour)this).Card.InHand)
			{
				if (Singleton<LifeManager>.Instance.DamageUntilPlayerWin > 0)
				{
					Singleton<ViewManager>.Instance.SwitchToView((View)0, false, false);
					Singleton<PlayerHand>.Instance.OnCardInspected(((AbilityBehaviour)this).Card);
					Singleton<PlayerHand>.Instance.InspectingLocked = true;
					((Card)((AbilityBehaviour)this).Card).Anim.SetShaking(true);
					yield return (object)new WaitForSeconds(0.75f);
					((Card)((AbilityBehaviour)this).Card).Anim.PlaySacrificeParticles();
					yield return (object)new WaitForSeconds(0.2f);
					AudioController.Instance.PlaySound3D("card_explosion", (MixerGroup)5, ((Component)((AbilityBehaviour)this).Card).transform.position, 1f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
					((Card)((AbilityBehaviour)this).Card).Anim.PlayTransformAnimation();
					if (Damage == 4)
					{
						yi