Decompiled source of InGame Card Creator v2.5.2

plugins/IGCCMod.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using IGCCMod;
using IGCCMod.JSON;
using IGCCMod.Util;
using InscryptionAPI.Card;
using InscryptionAPI.Saves;
using JSONLoader.API;
using Microsoft.CodeAnalysis;
using Pixelplacement;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("IGCCMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("IGCCMod")]
[assembly: AssemblyTitle("IGCCMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class CardSelectSequencers
{
	public static IEnumerator CreateRarity(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		IGCC.LookDown();
		SelectableCard selectedCard = null;
		List<CardInfo> list = new List<CardInfo>();
		List<SelectableCard> cards = new List<SelectableCard>();
		Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
		for (int i = 0; i <= 2; i++)
		{
			Vector3 cardIndexLoc = GetCardIndexLoc(obj, i + 6);
			CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
			CardModificationInfo val2 = new CardModificationInfo();
			switch (i)
			{
			case 0:
			{
				val2.nameReplacement = "regular";
				List<CardMetaCategory> metaCategories2 = new List<CardMetaCategory>
				{
					(CardMetaCategory)0,
					(CardMetaCategory)1
				};
				val.metaCategories = metaCategories2;
				break;
			}
			case 1:
			{
				val2.nameReplacement = "rare";
				List<CardMetaCategory> metaCategories = new List<CardMetaCategory> { (CardMetaCategory)3 };
				val.metaCategories = metaCategories;
				val.appearanceBehaviour.Add((Appearance)7);
				break;
			}
			case 2:
				val2.nameReplacement = "hidden";
				break;
			}
			val.Mods.Add(val2);
			list.Add(val);
			SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: true, instantSpawn: false);
			((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				selectedCard = (SelectableCard)c2;
			});
		}
		Singleton<TextDisplayer>.Instance.ShowMessage("Choose the [c:bR]type[c:] of card.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
		foreach (SelectableCard item in cards)
		{
			((Card)item).SetInteractionEnabled(true);
			((InteractableBase)item).SetEnabled(true);
		}
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
		Singleton<TextDisplayer>.Instance.Clear();
		((Card)preview).Info.metaCategories = ((Card)selectedCard).Info.metaCategories;
		((Card)preview).Info.appearanceBehaviour = ((Card)selectedCard).Info.appearanceBehaviour;
		yield return PostCardSelect(cards, selectedCard, 4);
	}

	public static IEnumerator CreateComplexity(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		IGCC.LookDown();
		SelectableCard selectedCard = null;
		List<CardInfo> list = new List<CardInfo>();
		List<SelectableCard> cards = new List<SelectableCard>();
		Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
		for (int i = 0; i <= 3; i++)
		{
			Vector3 cardIndexLoc = GetCardIndexLoc(obj, i + 5);
			CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
			CardModificationInfo val2 = new CardModificationInfo();
			CardComplexity val3 = (CardComplexity)i;
			val2.nameReplacement = ((object)(CardComplexity)(ref val3)).ToString();
			CardModificationInfo item = val2;
			val.cardComplexity = (CardComplexity)i;
			val.Mods.Add(item);
			list.Add(val);
			SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: true, instantSpawn: false);
			((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				selectedCard = (SelectableCard)c2;
			});
		}
		Singleton<TextDisplayer>.Instance.ShowMessage("Choose the [c:bR]complexity[c:] of card. This determines when it is unlocked in the tutorial.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
		foreach (SelectableCard item2 in cards)
		{
			((Card)item2).SetInteractionEnabled(true);
			((InteractableBase)item2).SetEnabled(true);
		}
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
		Singleton<TextDisplayer>.Instance.Clear();
		((Card)preview).Info.cardComplexity = ((Card)selectedCard).Info.cardComplexity;
		yield return PostCardSelect(cards, selectedCard, 5);
	}

	public static IEnumerator CreateCostCard(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		bool valid = false;
		int page = 0;
		SelectableCard selectedCard = null;
		List<SelectableCard> cards = new List<SelectableCard>();
		IGCC.LookDown();
		while (!valid)
		{
			selectedCard = null;
			cards.Clear();
			List<CardInfo> list = new List<CardInfo>();
			Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
			for (int i = 0; i <= 16; i++)
			{
				if (page * 15 + i <= 23 || i == 15)
				{
					if (i <= 14 || (i == 15 && page > 0) || (i == 16 && page < 1))
					{
						Vector3 cardIndexLoc = GetCardIndexLoc(obj, i);
						CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
						CardModificationInfo val2 = new CardModificationInfo();
						if (i <= 14)
						{
							if (page * 15 + i >= 21)
							{
								GemType val3 = (val2.addGemCost = new List<GemType> { (GemType)(page * 15 + i - 21) })[0];
								val2.nameReplacement = ((object)(GemType)(ref val3)).ToString() + " gem";
							}
							else if (page * 15 + i >= 15)
							{
								val2.energyCostAdjustment = page * 15 + i - 14;
								val2.nameReplacement = page * 15 + i - 14 + " energy";
							}
							else if (page * 15 + i >= 5)
							{
								val2.bonesCostAdjustment = page * 15 + i - 4;
								if (page * 15 + i - 4 == 1)
								{
									val2.nameReplacement = "1 bone";
								}
								else
								{
									val2.nameReplacement = page * 15 + i - 4 + " bones";
								}
							}
							else if (page * 15 + i >= 1)
							{
								val2.bloodCostAdjustment = page * 15 + i;
								val2.nameReplacement = page * 15 + i + " blood";
							}
							else
							{
								val2.nameReplacement = "free";
							}
						}
						else
						{
							switch (i)
							{
							case 15:
								val2.nameReplacement = "previous page";
								break;
							case 16:
								val2.nameReplacement = "next page";
								break;
							}
							val.appearanceBehaviour.Add((Appearance)2);
							val.appearanceBehaviour.Add((Appearance)9);
						}
						val.Mods.Add(val2);
						list.Add(val);
						SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: true, instantSpawn: false);
						((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
						{
							//IL_0002: Unknown result type (might be due to invalid IL or missing references)
							//IL_000c: Expected O, but got Unknown
							selectedCard = (SelectableCard)c2;
						});
					}
					else
					{
						list.Add(null);
					}
				}
				else
				{
					list.Add(null);
				}
			}
			Singleton<TextDisplayer>.Instance.ShowMessage("Please, choose a card to draw the [c:bR]cost[c:] from.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
			foreach (SelectableCard item in cards)
			{
				((Card)item).SetInteractionEnabled(true);
				((InteractableBase)item).SetEnabled(true);
			}
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("previous page"))
			{
				if (page > 0)
				{
					page--;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("next page"))
			{
				if (page < 1)
				{
					page++;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else
			{
				valid = true;
			}
		}
		Singleton<TextDisplayer>.Instance.Clear();
		((Card)preview).Info.cost = ((Card)selectedCard).Info.BloodCost;
		((Card)preview).Info.bonesCost = ((Card)selectedCard).Info.BonesCost;
		((Card)preview).Info.energyCost = ((Card)selectedCard).Info.EnergyCost;
		((Card)preview).Info.gemsCost = ((Card)selectedCard).Info.GemsCost;
		yield return PostCardSelect(cards, selectedCard, 0);
	}

	public static IEnumerator CreateCostCardAdditive(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		bool valid = false;
		int page = 0;
		SelectableCard selectedCard = null;
		List<SelectableCard> cards = new List<SelectableCard>();
		IGCC.LookDown();
		while (!valid)
		{
			selectedCard = null;
			cards.Clear();
			List<CardInfo> list = new List<CardInfo>();
			Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
			for (int i = 0; i <= 16; i++)
			{
				if (page * 15 + i <= 23 || i == 15)
				{
					if (i <= 14 || (i == 15 && page > 0) || (i == 16 && page < 1))
					{
						Vector3 cardIndexLoc = GetCardIndexLoc(obj, i);
						CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
						CardModificationInfo val2 = new CardModificationInfo();
						if (i <= 14)
						{
							if (page * 15 + i >= 21)
							{
								GemType val3 = (val2.addGemCost = new List<GemType> { (GemType)(page * 15 + i - 21) })[0];
								val2.nameReplacement = ((object)(GemType)(ref val3)).ToString() + " gem";
							}
							else if (page * 15 + i >= 15)
							{
								val2.energyCostAdjustment = page * 15 + i - 14;
								val2.nameReplacement = page * 15 + i - 14 + " energy";
							}
							else if (page * 15 + i >= 5)
							{
								val2.bonesCostAdjustment = page * 15 + i - 4;
								if (page * 15 + i - 4 == 1)
								{
									val2.nameReplacement = "1 bone";
								}
								else
								{
									val2.nameReplacement = page * 15 + i - 4 + " bones";
								}
							}
							else if (page * 15 + i >= 1)
							{
								val2.bloodCostAdjustment = page * 15 + i;
								val2.nameReplacement = page * 15 + i + " blood";
							}
							else
							{
								val2.nameReplacement = "free";
							}
						}
						else
						{
							switch (i)
							{
							case 15:
								val2.nameReplacement = "previous page";
								break;
							case 16:
								val2.nameReplacement = "next page";
								break;
							}
							val.appearanceBehaviour.Add((Appearance)2);
							val.appearanceBehaviour.Add((Appearance)9);
						}
						val.Mods.Add(val2);
						list.Add(val);
						SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: true, instantSpawn: false);
						((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
						{
							//IL_0002: Unknown result type (might be due to invalid IL or missing references)
							//IL_000c: Expected O, but got Unknown
							selectedCard = (SelectableCard)c2;
						});
					}
					else
					{
						list.Add(null);
					}
				}
				else
				{
					list.Add(null);
				}
			}
			Singleton<TextDisplayer>.Instance.ShowMessage("Do you want to add another [c:bR]cost[c:]?", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
			foreach (SelectableCard item in cards)
			{
				((Card)item).SetInteractionEnabled(true);
				((InteractableBase)item).SetEnabled(true);
			}
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("previous page"))
			{
				if (page > 0)
				{
					page--;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("next page"))
			{
				if (page < 1)
				{
					page++;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else
			{
				valid = true;
			}
		}
		Singleton<TextDisplayer>.Instance.Clear();
		if (((Card)selectedCard).Info.BloodCost > 0)
		{
			CardInfo info = ((Card)preview).Info;
			info.cost += ((Card)selectedCard).Info.BloodCost;
		}
		else if (((Card)selectedCard).Info.BonesCost > 0)
		{
			CardInfo info2 = ((Card)preview).Info;
			info2.bonesCost += ((Card)selectedCard).Info.BonesCost;
		}
		else if (((Card)selectedCard).Info.EnergyCost > 0)
		{
			CardInfo info3 = ((Card)preview).Info;
			info3.energyCost += ((Card)selectedCard).Info.EnergyCost;
		}
		else if (((Card)selectedCard).Info.GemsCost.Count > 0 && ((Card)preview).Info.gemsCost == null)
		{
			((Card)preview).Info.gemsCost = new List<GemType>();
		}
		((Card)preview).Info.gemsCost.AddRange(((Card)selectedCard).Info.GemsCost);
		yield return PostCardSelect(cards, selectedCard, 0);
	}

	public static IEnumerator CreatePortrait(DeathCardCreationSequencer __instance, SelectableCard preview, List<Texture2D> portraits, int type)
	{
		bool valid = false;
		int page = 0;
		SelectableCard selectedCard = null;
		List<SelectableCard> cards = new List<SelectableCard>();
		IGCC.LookDown();
		while (!valid)
		{
			selectedCard = null;
			cards.Clear();
			List<CardInfo> list = new List<CardInfo>();
			Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
			for (int i = 0; i <= 16; i++)
			{
				if (page * 15 + i < portraits.Count || i == 15)
				{
					if (i <= 14 || (i == 15 && page > 0) || (i == 16 && (double)page < Math.Ceiling((float)portraits.Count / 15f)))
					{
						Vector3 cardIndexLoc = GetCardIndexLoc(obj, i);
						CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
						CardModificationInfo val2 = new CardModificationInfo();
						if (i <= 14)
						{
							val.portraitTex = Sprite.Create(portraits[page * 15 + i], new Rect(0f, 0f, 114f, 94f), new Vector2(0.5f, 0.5f));
							string text = ((!((Object)portraits[page * 15 + i]).name.StartsWith("portrait_")) ? ((Object)portraits[page * 15 + i]).name.Replace("_", " ") : ((Object)portraits[page * 15 + i]).name.Substring(9).Replace("_", " "));
							char directorySeparatorChar = Path.DirectorySeparatorChar;
							if (text.Contains(directorySeparatorChar.ToString()))
							{
								val2.nameReplacement = text.Substring(text.LastIndexOf(Path.DirectorySeparatorChar) + 1);
							}
							else
							{
								val2.nameReplacement = text;
							}
						}
						else
						{
							switch (i)
							{
							case 15:
								val2.nameReplacement = "previous page";
								break;
							case 16:
								val2.nameReplacement = "next page";
								break;
							}
							val.appearanceBehaviour.Add((Appearance)2);
							val.appearanceBehaviour.Add((Appearance)9);
						}
						val.Mods.Add(val2);
						list.Add(val);
						SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: true, instantSpawn: false);
						((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
						{
							//IL_0002: Unknown result type (might be due to invalid IL or missing references)
							//IL_000c: Expected O, but got Unknown
							selectedCard = (SelectableCard)c2;
						});
					}
					else
					{
						list.Add(null);
					}
				}
				else
				{
					list.Add(null);
				}
			}
			Singleton<TextDisplayer>.Instance.ShowMessage("Choose one.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
			foreach (SelectableCard item in cards)
			{
				((Card)item).SetInteractionEnabled(true);
				((InteractableBase)item).SetEnabled(true);
			}
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("previous page"))
			{
				if (page > 0)
				{
					page--;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("next page"))
			{
				if ((double)page < Math.Ceiling((float)portraits.Count / 15f))
				{
					page++;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else
			{
				valid = true;
			}
		}
		Singleton<TextDisplayer>.Instance.Clear();
		if (type == 0)
		{
			((Card)preview).Info.portraitTex = Sprite.Create(((Card)selectedCard).Info.portraitTex.texture, new Rect(0f, 0f, 114f, 94f), new Vector2(0.5f, 0.5f));
		}
		else
		{
			((Card)preview).Info.alternatePortrait = Sprite.Create(((Card)selectedCard).Info.portraitTex.texture, new Rect(0f, 0f, 114f, 94f), new Vector2(0.5f, 0.5f));
		}
		yield return PostCardSelect(cards, selectedCard, 3);
	}

	public static IEnumerator CreateEvolution(DeathCardCreationSequencer __instance, SelectableCard preview, int type)
	{
		bool valid = false;
		int page = 0;
		SelectableCard selectedCard = null;
		List<SelectableCard> cards = new List<SelectableCard>();
		List<CardInfo> allData = ScriptableObjectLoader<CardInfo>.AllData;
		List<CardInfo> validCards = new List<CardInfo>();
		foreach (CardInfo item in allData)
		{
			if ((int)item.temple == 0 && !validCards.Contains(item))
			{
				validCards.Add(item);
			}
		}
		IGCC.LookDown();
		while (!valid)
		{
			selectedCard = null;
			cards.Clear();
			List<CardInfo> list = new List<CardInfo>();
			Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
			for (int i = 0; i <= 16; i++)
			{
				if (page * 15 + i < validCards.Count + 1 || i == 15)
				{
					if (i <= 14 || (i == 15 && page > 0) || (i == 16 && (double)page < Math.Ceiling((float)validCards.Count + 1f / 15f)))
					{
						Vector3 cardIndexLoc = GetCardIndexLoc(obj, i);
						CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
						CardModificationInfo val2 = new CardModificationInfo();
						if (i <= 14)
						{
							if (page * 15 + i == 0)
							{
								switch (type)
								{
								case 0:
									val2.nameReplacement = "default (+1/2)";
									break;
								case 1:
									val2.nameReplacement = "default (opposum)";
									break;
								}
							}
							else
							{
								val = validCards[page * 15 + i - 1];
							}
							val.specialAbilities = new List<SpecialTriggeredAbility>();
						}
						else
						{
							switch (i)
							{
							case 15:
								val2.nameReplacement = "previous page";
								break;
							case 16:
								val2.nameReplacement = "next page";
								break;
							}
							val.appearanceBehaviour.Add((Appearance)2);
							val.appearanceBehaviour.Add((Appearance)9);
						}
						val.Mods.Add(val2);
						list.Add(val);
						SelectableCard val3 = ((page * 15 + i != 0) ? CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: false, hiddenHealth: false, instantSpawn: false) : CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: true, instantSpawn: false));
						((MainInputInteractable)val3).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)val3).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
						{
							//IL_0002: Unknown result type (might be due to invalid IL or missing references)
							//IL_000c: Expected O, but got Unknown
							selectedCard = (SelectableCard)c2;
						});
					}
					else
					{
						list.Add(null);
					}
				}
				else
				{
					list.Add(null);
				}
			}
			switch (type)
			{
			case 0:
				Singleton<TextDisplayer>.Instance.ShowMessage("Choose which card it will evolve into.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
				break;
			case 1:
				Singleton<TextDisplayer>.Instance.ShowMessage("Choose which card it will create upon death.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
				break;
			}
			foreach (SelectableCard item2 in cards)
			{
				((Card)item2).SetInteractionEnabled(true);
				((InteractableBase)item2).SetEnabled(true);
			}
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("previous page"))
			{
				if (page > 0)
				{
					page--;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("next page"))
			{
				if ((double)page < Math.Ceiling((float)(validCards.Count + 1) / 15f))
				{
					page++;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else
			{
				valid = true;
			}
		}
		Singleton<TextDisplayer>.Instance.Clear();
		if (!((Card)selectedCard).Info.DisplayedNameEnglish.Equals("default (+1/2)") && !((Card)selectedCard).Info.DisplayedNameEnglish.Equals("default (opposum)"))
		{
			switch (type)
			{
			case 0:
				((Card)preview).Info.evolveParams = new EvolveParams
				{
					evolution = ((Card)selectedCard).Info,
					turnsToEvolve = 1
				};
				break;
			case 1:
				((Card)preview).Info.iceCubeParams = new IceCubeParams
				{
					creatureWithin = ((Card)selectedCard).Info
				};
				break;
			}
		}
		yield return PostCardSelect(cards, selectedCard, 6);
	}

	public static IEnumerator CreateEvolutionTurnCount(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		IGCC.LookDown();
		SelectableCard selectedCard = null;
		List<CardInfo> list = new List<CardInfo>();
		List<SelectableCard> cards = new List<SelectableCard>();
		Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
		for (int i = 0; i <= 9; i++)
		{
			Vector3 cardIndexLoc = GetCardIndexLoc(obj, i);
			CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
			CardModificationInfo val2 = new CardModificationInfo();
			if (i == 0)
			{
				val2.nameReplacement = "1 turn";
			}
			else
			{
				val2.nameReplacement = i + 1 + " turns";
			}
			val2.abilities.Add((Ability)5);
			val.Mods.Add(val2);
			val.evolveParams = new EvolveParams
			{
				turnsToEvolve = i + 1
			};
			list.Add(val);
			SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: true, instantSpawn: false);
			((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				selectedCard = (SelectableCard)c2;
			});
		}
		Singleton<TextDisplayer>.Instance.ShowMessage("[c:bR]How many turns[c:] should it take for this card to evolve?", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
		foreach (SelectableCard item in cards)
		{
			((Card)item).SetInteractionEnabled(true);
			((InteractableBase)item).SetEnabled(true);
		}
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
		Singleton<TextDisplayer>.Instance.Clear();
		((Card)preview).Info.evolveParams.turnsToEvolve = ((Card)selectedCard).Info.evolveParams.turnsToEvolve;
		yield return PostCardSelect(cards, selectedCard, 7);
	}

	public static IEnumerator CreateAttackCard(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		bool valid = false;
		int page = 0;
		SelectableCard selectedCard = null;
		List<SelectableCard> cards = new List<SelectableCard>();
		int specialStatIcons = 7;
		IGCC.LookDown();
		while (!valid)
		{
			selectedCard = null;
			cards.Clear();
			List<CardInfo> list = new List<CardInfo>();
			Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
			for (int i = 0; i <= 16; i++)
			{
				if (page * 15 + i <= 9999 + specialStatIcons || i == 15)
				{
					if (i <= 14 || (i == 15 && page > 0) || (i == 16 && (double)page < Math.Ceiling((float)(9999 + specialStatIcons) / 15f)))
					{
						Vector3 cardIndexLoc = GetCardIndexLoc(obj, i);
						CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
						CardModificationInfo val2 = new CardModificationInfo();
						if (page * 15 + i < specialStatIcons)
						{
							SpecialStatIcon val3 = (SpecialStatIcon)(i + 1);
							val2.nameReplacement = ((object)(SpecialStatIcon)(ref val3)).ToString();
							val2.statIcon = (SpecialStatIcon)(i + 1);
							val3 = val2.statIcon;
							switch (val3 - 1)
							{
							case 0:
								val2.specialAbilities.Add((SpecialTriggeredAbility)6);
								break;
							case 3:
								val2.specialAbilities.Add((SpecialTriggeredAbility)12);
								break;
							case 1:
								val2.specialAbilities.Add((SpecialTriggeredAbility)8);
								break;
							case 5:
								val2.specialAbilities.Add((SpecialTriggeredAbility)23);
								break;
							case 4:
								val2.specialAbilities.Add((SpecialTriggeredAbility)17);
								break;
							case 2:
								val2.specialAbilities.Add((SpecialTriggeredAbility)11);
								break;
							}
						}
						else if (i <= 14)
						{
							val2.attackAdjustment = page * 15 + i - specialStatIcons;
							val2.nameReplacement = page * 15 + i - specialStatIcons + " power";
						}
						else
						{
							switch (i)
							{
							case 15:
								val2.nameReplacement = "previous page";
								break;
							case 16:
								val2.nameReplacement = "next page";
								break;
							}
							val.appearanceBehaviour.Add((Appearance)2);
							val.appearanceBehaviour.Add((Appearance)9);
						}
						val.Mods.Add(val2);
						list.Add(val);
						SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: false, hiddenHealth: true, instantSpawn: false);
						((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
						{
							//IL_0002: Unknown result type (might be due to invalid IL or missing references)
							//IL_000c: Expected O, but got Unknown
							selectedCard = (SelectableCard)c2;
						});
					}
					else
					{
						list.Add(null);
					}
				}
				else
				{
					list.Add(null);
				}
			}
			Singleton<TextDisplayer>.Instance.ShowMessage("And another. This time I will use its [c:bR]power[c:].", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
			foreach (SelectableCard item in cards)
			{
				((Card)item).SetInteractionEnabled(true);
				((InteractableBase)item).SetEnabled(true);
			}
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("previous page"))
			{
				if (page > 0)
				{
					page--;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("next page"))
			{
				if ((double)page < Math.Ceiling((float)(9999 + specialStatIcons) / 15f))
				{
					page++;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else
			{
				valid = true;
			}
		}
		Singleton<TextDisplayer>.Instance.Clear();
		((Card)preview).Info.baseAttack = ((Card)selectedCard).Info.Attack;
		((Card)preview).Info.specialStatIcon = ((Card)selectedCard).Info.SpecialStatIcon;
		if (((Card)preview).Info.specialAbilities == null)
		{
			((Card)preview).Info.specialAbilities = new List<SpecialTriggeredAbility>();
		}
		else
		{
			_ = ((Card)preview).Info.SpecialStatIcon;
			ResetAttackAbility(((Card)preview).Info.SpecialStatIcon, ((Card)preview).Info);
		}
		((Card)preview).Info.specialAbilities.AddRange(((Card)selectedCard).Info.SpecialAbilities);
		yield return PostCardSelect(cards, selectedCard, 1);
	}

	private static void ResetAttackAbility(SpecialStatIcon icon, CardInfo card)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected I4, but got Unknown
		switch (icon - 1)
		{
		case 0:
			card.specialAbilities.Remove((SpecialTriggeredAbility)6);
			break;
		case 3:
			card.specialAbilities.Remove((SpecialTriggeredAbility)12);
			break;
		case 1:
			card.specialAbilities.Remove((SpecialTriggeredAbility)8);
			break;
		case 5:
			card.specialAbilities.Remove((SpecialTriggeredAbility)23);
			break;
		case 4:
			card.specialAbilities.Remove((SpecialTriggeredAbility)17);
			break;
		case 2:
			card.specialAbilities.Remove((SpecialTriggeredAbility)11);
			break;
		}
	}

	public static IEnumerator CreateHealthCard(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		bool valid = false;
		int page = 0;
		SelectableCard selectedCard = null;
		List<SelectableCard> cards = new List<SelectableCard>();
		IGCC.LookDown();
		while (!valid)
		{
			selectedCard = null;
			cards.Clear();
			List<CardInfo> list = new List<CardInfo>();
			Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
			for (int i = 0; i <= 16; i++)
			{
				if (page * 15 + i <= 9998 || i == 15)
				{
					if (i <= 14 || (i == 15 && page > 0) || (i == 16 && page < 667))
					{
						Vector3 cardIndexLoc = GetCardIndexLoc(obj, i);
						CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
						CardModificationInfo val2 = new CardModificationInfo();
						if (i <= 14)
						{
							val2.healthAdjustment = 1 + page * 15 + i;
							val2.nameReplacement = 1 + page * 15 + i + " health";
						}
						else
						{
							switch (i)
							{
							case 15:
								val2.nameReplacement = "previous page";
								break;
							case 16:
								val2.nameReplacement = "next page";
								break;
							}
							val.appearanceBehaviour.Add((Appearance)2);
							val.appearanceBehaviour.Add((Appearance)9);
						}
						val.Mods.Add(val2);
						list.Add(val);
						SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: false, instantSpawn: false);
						((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
						{
							//IL_0002: Unknown result type (might be due to invalid IL or missing references)
							//IL_000c: Expected O, but got Unknown
							selectedCard = (SelectableCard)c2;
						});
					}
					else
					{
						list.Add(null);
					}
				}
				else
				{
					list.Add(null);
				}
			}
			Singleton<TextDisplayer>.Instance.ShowMessage("And another. This time I will use its [c:bR]health[c:].", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
			foreach (SelectableCard item in cards)
			{
				((Card)item).SetInteractionEnabled(true);
				((InteractableBase)item).SetEnabled(true);
			}
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("previous page"))
			{
				if (page > 0)
				{
					page--;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("next page"))
			{
				if (page < 667)
				{
					page++;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else
			{
				valid = true;
			}
		}
		Singleton<TextDisplayer>.Instance.Clear();
		((Card)preview).Info.baseHealth = ((Card)selectedCard).Info.Health;
		yield return PostCardSelect(cards, selectedCard, 2);
	}

	public static IEnumerator CreateSigilCard(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		bool valid = false;
		bool skipRegenerate = false;
		bool instantSpawn = false;
		int page = 0;
		SelectableCard selectedCard = null;
		List<Ability> selectedSigils = new List<Ability>();
		List<SelectableCard> cards = new List<SelectableCard>();
		List<Ability> allAbilities = (from a in Enumerable.Range(0, 107)
			select (Ability)a).ToList();
		List<Ability> abilities = allAbilities.Where((Ability a) => (Object)(object)AbilitiesUtil.GetInfo(a) != (Object)null && (AbilitiesUtil.GetInfo(a).metaCategories.Contains((AbilityMetaCategory)0) || AbilitiesUtil.GetInfo(a).metaCategories.Contains((AbilityMetaCategory)2) || AbilitiesUtil.GetInfo(a).metaCategories.Contains((AbilityMetaCategory)1) || AbilitiesUtil.GetInfo(a).metaCategories.Contains((AbilityMetaCategory)3))).ToList();
		List<FullAbility> allAbilities2 = AbilityManager.AllAbilities;
		abilities.AddRange(from na in allAbilities2
			where (Object)(object)na.Info != (Object)null && !allAbilities.Contains(na.Id) && (na.Info.metaCategories.Contains((AbilityMetaCategory)0) || na.Info.metaCategories.Contains((AbilityMetaCategory)2) || na.Info.metaCategories.Contains((AbilityMetaCategory)1) || na.Info.metaCategories.Contains((AbilityMetaCategory)3))
			select na.Id);
		Vector3 cardIndexLoc = GetCardIndexLoc(((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0], 18);
		CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
		CardModificationInfo item = new CardModificationInfo
		{
			nameReplacement = "confirm"
		};
		val.Mods.Add(item);
		val.appearanceBehaviour.Add((Appearance)7);
		SelectableCard confirm = CreateConfirmCard(__instance, cardIndexLoc, val);
		((MainInputInteractable)confirm).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)confirm).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			selectedCard = (SelectableCard)c2;
		});
		IGCC.LookDown();
		while (!valid)
		{
			selectedCard = null;
			if (!skipRegenerate)
			{
				cards.Clear();
				List<CardInfo> list = new List<CardInfo>();
				Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
				for (int i = 0; i <= 16; i++)
				{
					if (page * 15 + i < abilities.Count || i == 15)
					{
						if (i <= 14 || (i == 15 && page > 0) || (i == 16 && (double)page < Math.Ceiling((float)abilities.Count / 15f)))
						{
							Vector3 cardIndexLoc2 = GetCardIndexLoc(obj, i);
							CardInfo val2 = ScriptableObject.CreateInstance<CardInfo>();
							CardModificationInfo val3 = new CardModificationInfo();
							if (i <= 14)
							{
								List<Ability> list2 = new List<Ability> { abilities[page * 15 + i] };
								if (AbilitiesUtil.GetInfo(list2[0]).rulebookName != null && AbilitiesUtil.GetInfo(list2[0]).rulebookName != "")
								{
									val3.nameReplacement = "sigil of " + AbilitiesUtil.GetInfo(list2[0]).rulebookName;
								}
								else
								{
									val3.nameReplacement = "sigil of " + ((Object)AbilitiesUtil.GetInfo(list2[0])).name;
								}
								val3.abilities = list2;
							}
							else
							{
								switch (i)
								{
								case 15:
									val3.nameReplacement = "previous page";
									break;
								case 16:
									val3.nameReplacement = "next page";
									break;
								}
								val2.appearanceBehaviour.Add((Appearance)2);
								val2.appearanceBehaviour.Add((Appearance)9);
							}
							val2.Mods.Add(val3);
							list.Add(val2);
							if (i <= 14)
							{
								val2.appearanceBehaviour = new List<Appearance>();
								if (val2.Abilities.Count > 0 && selectedSigils.Contains(val2.Abilities[0]))
								{
									val2.appearanceBehaviour.Add((Appearance)6);
								}
							}
							SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc2, hiddenAttack: true, hiddenHealth: true, instantSpawn);
							((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
							{
								//IL_0002: Unknown result type (might be due to invalid IL or missing references)
								//IL_000c: Expected O, but got Unknown
								selectedCard = (SelectableCard)c2;
							});
						}
						else
						{
							list.Add(null);
						}
					}
					else
					{
						list.Add(null);
					}
				}
				Singleton<TextDisplayer>.Instance.ShowMessage("Now choose some cards from which we will extract the [c:bR]sigils[c:]. Note that some may not work correctly.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
				foreach (SelectableCard item2 in cards)
				{
					((Card)item2).SetInteractionEnabled(true);
					((InteractableBase)item2).SetEnabled(true);
				}
			}
			((Card)confirm).SetInteractionEnabled(true);
			((InteractableBase)confirm).SetEnabled(true);
			skipRegenerate = false;
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("previous page"))
			{
				if (page > 0)
				{
					page--;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("next page"))
			{
				if ((double)page < Math.Ceiling((float)abilities.Count / 15f))
				{
					page++;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("confirm"))
			{
				valid = true;
			}
			else if (selectedSigils.Contains(((Card)selectedCard).Info.Abilities[0]))
			{
				selectedSigils.Remove(((Card)selectedCard).Info.Abilities[0]);
				((Card)selectedCard).Anim.PlayDeathAnimation(true);
				DestroyAllCards(cards, playDeathAnim: false);
				instantSpawn = true;
			}
			else
			{
				selectedSigils.Add(((Card)selectedCard).Info.Abilities[0]);
				((Card)selectedCard).Info.appearanceBehaviour.Add((Appearance)6);
				((Card)selectedCard).Anim.PlayTransformAnimation();
				yield return (object)new WaitForSeconds(0.15f);
				((Card)selectedCard).SetInfo(((Card)selectedCard).Info);
				yield return (object)new WaitForSeconds(0.15f);
				skipRegenerate = true;
			}
		}
		((Card)preview).Info.abilities = selectedSigils;
		((Card)confirm).Anim.PlayDeathAnimation(true);
		Object.Destroy((Object)(object)((Component)confirm).gameObject, 2f);
		yield return PostMultiSigilCardSelect(cards, selectedSigils);
	}

	public static IEnumerator CreateSpecialAbilities(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		bool valid = false;
		bool skipRegenerate = false;
		bool instantSpawn = false;
		int page = 0;
		SelectableCard selectedCard = null;
		List<SpecialTriggeredAbility> selectedSAs = new List<SpecialTriggeredAbility>();
		List<Trait> selectedTraits = new List<Trait>();
		List<SelectableCard> cards = new List<SelectableCard>();
		int num = 29;
		int traitCount = 22;
		List<SpecialTriggeredAbility> validAbilities = new List<SpecialTriggeredAbility>();
		for (int i = 1; i < num; i++)
		{
			if (i != 6 && i != 12 && i != 23 && i != 11 && i != 8 && i != 17 && i != 2 && i != 3 && i != 4 && i != 5)
			{
				validAbilities.Add((SpecialTriggeredAbility)i);
			}
		}
		Vector3 cardIndexLoc = GetCardIndexLoc(((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0], 18);
		CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
		CardModificationInfo item = new CardModificationInfo
		{
			nameReplacement = "confirm"
		};
		val.Mods.Add(item);
		val.appearanceBehaviour.Add((Appearance)7);
		SelectableCard confirm = CreateConfirmCard(__instance, cardIndexLoc, val);
		((MainInputInteractable)confirm).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)confirm).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			selectedCard = (SelectableCard)c2;
		});
		IGCC.LookDown();
		while (!valid)
		{
			selectedCard = null;
			if (!skipRegenerate)
			{
				cards.Clear();
				List<CardInfo> list = new List<CardInfo>();
				Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
				for (int j = 0; j <= 16; j++)
				{
					if (page * 15 + j < validAbilities.Count + traitCount || j == 15)
					{
						if (j <= 14 || (j == 15 && page > 0) || (j == 16 && (double)page < Math.Ceiling((float)(validAbilities.Count + traitCount) / 15f)))
						{
							Vector3 cardIndexLoc2 = GetCardIndexLoc(obj, j);
							CardInfo val2 = ScriptableObject.CreateInstance<CardInfo>();
							CardModificationInfo val3 = new CardModificationInfo();
							if (j <= 14)
							{
								if (page * 15 + j >= validAbilities.Count)
								{
									val2.traits.Add((Trait)(page * 15 + j - validAbilities.Count + 1));
									Trait val4 = (Trait)(page * 15 + j - validAbilities.Count + 1);
									val3.nameReplacement = ((object)(Trait)(ref val4)).ToString();
								}
								else
								{
									List<SpecialTriggeredAbility> list2 = new List<SpecialTriggeredAbility> { validAbilities[page * 15 + j] };
									SpecialTriggeredAbility val5 = list2[0];
									val3.nameReplacement = ((object)(SpecialTriggeredAbility)(ref val5)).ToString();
									val3.specialAbilities = list2;
								}
							}
							else
							{
								switch (j)
								{
								case 15:
									val3.nameReplacement = "previous page";
									break;
								case 16:
									val3.nameReplacement = "next page";
									break;
								}
								val2.appearanceBehaviour.Add((Appearance)2);
								val2.appearanceBehaviour.Add((Appearance)9);
							}
							val2.Mods.Add(val3);
							list.Add(val2);
							if (j <= 14)
							{
								val2.appearanceBehaviour = new List<Appearance>();
								if (val2.SpecialAbilities.Count > 0 && selectedSAs.Contains(val2.SpecialAbilities[0]))
								{
									val2.appearanceBehaviour.Add((Appearance)6);
								}
								else if (val2.traits.Count > 0 && selectedTraits.Contains(val2.traits[0]))
								{
									val2.appearanceBehaviour.Add((Appearance)6);
								}
							}
							SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc2, hiddenAttack: true, hiddenHealth: true, instantSpawn);
							((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
							{
								//IL_0002: Unknown result type (might be due to invalid IL or missing references)
								//IL_000c: Expected O, but got Unknown
								selectedCard = (SelectableCard)c2;
							});
						}
						else
						{
							list.Add(null);
						}
					}
					else
					{
						list.Add(null);
					}
				}
				Singleton<TextDisplayer>.Instance.ShowMessage("Finally, choose the hidden [c:bR]special abilities[c:] and [c:bR]traits[c:]. Again, some may not function properly.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
				foreach (SelectableCard item2 in cards)
				{
					((Card)item2).SetInteractionEnabled(true);
					((InteractableBase)item2).SetEnabled(true);
				}
			}
			((Card)confirm).SetInteractionEnabled(true);
			((InteractableBase)confirm).SetEnabled(true);
			skipRegenerate = false;
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("previous page"))
			{
				if (page > 0)
				{
					page--;
				}
				DestroyAllCards(cards, playDeathAnim: true);
				continue;
			}
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("next page"))
			{
				if ((double)page < Math.Ceiling((float)(validAbilities.Count + traitCount) / 15f))
				{
					page++;
				}
				DestroyAllCards(cards, playDeathAnim: true);
				continue;
			}
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("confirm"))
			{
				valid = true;
				continue;
			}
			if ((((Card)selectedCard).Info.SpecialAbilities.Count > 0 && selectedSAs.Contains(((Card)selectedCard).Info.SpecialAbilities[0])) || (((Card)selectedCard).Info.traits.Count > 0 && selectedTraits.Contains(((Card)selectedCard).Info.traits[0])))
			{
				if (((Card)selectedCard).Info.SpecialAbilities.Count > 0)
				{
					selectedSAs.Remove(((Card)selectedCard).Info.SpecialAbilities[0]);
				}
				else
				{
					selectedTraits.Remove(((Card)selectedCard).Info.traits[0]);
				}
				((Card)selectedCard).Anim.PlayDeathAnimation(true);
				DestroyAllCards(cards, playDeathAnim: false);
				instantSpawn = true;
				continue;
			}
			if (((Card)selectedCard).Info.SpecialAbilities.Count > 0)
			{
				selectedSAs.Add(((Card)selectedCard).Info.SpecialAbilities[0]);
			}
			else
			{
				selectedTraits.Add(((Card)selectedCard).Info.traits[0]);
			}
			((Card)selectedCard).Info.appearanceBehaviour.Add((Appearance)6);
			((Card)selectedCard).Anim.PlayTransformAnimation();
			yield return (object)new WaitForSeconds(0.15f);
			((Card)selectedCard).SetInfo(((Card)selectedCard).Info);
			yield return (object)new WaitForSeconds(0.15f);
			skipRegenerate = true;
		}
		Singleton<TextDisplayer>.Instance.Clear();
		if (((Card)preview).Info.specialAbilities == null)
		{
			((Card)preview).Info.specialAbilities = new List<SpecialTriggeredAbility>();
		}
		if ((int)((Card)preview).Info.specialStatIcon != 0)
		{
			SetAttackAbility(((Card)preview).Info.specialStatIcon, ((Card)preview).Info);
		}
		((Card)preview).Info.specialAbilities.AddRange(selectedSAs);
		((Card)preview).Info.traits = selectedTraits;
		((Card)confirm).Anim.PlayDeathAnimation(true);
		Object.Destroy((Object)(object)((Component)confirm).gameObject, 2f);
		yield return PostMultiSACardSelect(cards, selectedSAs, selectedTraits);
	}

	private static void SetAttackAbility(SpecialStatIcon icon, CardInfo card)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected I4, but got Unknown
		switch (icon - 1)
		{
		case 0:
			card.specialAbilities.Add((SpecialTriggeredAbility)6);
			break;
		case 3:
			card.specialAbilities.Add((SpecialTriggeredAbility)12);
			break;
		case 1:
			card.specialAbilities.Add((SpecialTriggeredAbility)8);
			break;
		case 5:
			card.specialAbilities.Add((SpecialTriggeredAbility)23);
			break;
		case 4:
			card.specialAbilities.Add((SpecialTriggeredAbility)17);
			break;
		case 2:
			card.specialAbilities.Add((SpecialTriggeredAbility)11);
			break;
		}
	}

	public static IEnumerator CreateTribeCard(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		bool valid = false;
		bool skipRegenerate = false;
		bool instantSpawn = false;
		int page = 0;
		SelectableCard selectedCard = null;
		List<Tribe> selectedTribes = new List<Tribe>();
		List<SelectableCard> cards = new List<SelectableCard>();
		int tribeCount = 7 + TribeManager.tribes.Count;
		Vector3 cardIndexLoc = GetCardIndexLoc(((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0], 18);
		CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
		CardModificationInfo item = new CardModificationInfo
		{
			nameReplacement = "confirm"
		};
		val.Mods.Add(item);
		val.appearanceBehaviour.Add((Appearance)7);
		SelectableCard confirm = CreateConfirmCard(__instance, cardIndexLoc, val);
		((MainInputInteractable)confirm).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)confirm).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			selectedCard = (SelectableCard)c2;
		});
		IGCC.LookDown();
		while (!valid)
		{
			selectedCard = null;
			if (!skipRegenerate)
			{
				cards.Clear();
				List<CardInfo> list = new List<CardInfo>();
				Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
				for (int i = 0; i <= 16; i++)
				{
					if (page * 15 + i < tribeCount - 1 || i == 15)
					{
						if (i <= 14 || (i == 15 && page > 0) || (i == 16 && (double)page < Math.Ceiling((float)tribeCount / 15f)))
						{
							Vector3 cardIndexLoc2 = GetCardIndexLoc(obj, i);
							CardInfo val2 = ScriptableObject.CreateInstance<CardInfo>();
							CardModificationInfo val3 = new CardModificationInfo();
							if (i <= 14)
							{
								if (page * 15 + i + 1 < 7)
								{
									List<Tribe> tribes = new List<Tribe> { (Tribe)(page * 15 + i + 1) };
									Tribe val4 = (Tribe)(page * 15 + i + 1);
									val3.nameReplacement = ((object)(Tribe)(ref val4)).ToString() + " tribe";
									val2.tribes = tribes;
								}
								else
								{
									Tribe tribe = TribeManager.tribes[page * 15 + i + 1 - 7].tribe;
									List<Tribe> tribes2 = new List<Tribe> { tribe };
									string moddedGuid = JsonParser.GetModdedGuid(tribe);
									moddedGuid = moddedGuid.Substring(moddedGuid.IndexOf('.') + 1);
									val3.nameReplacement = moddedGuid + " tribe";
									val2.tribes = tribes2;
								}
							}
							else
							{
								switch (i)
								{
								case 15:
									val3.nameReplacement = "previous page";
									break;
								case 16:
									val3.nameReplacement = "next page";
									break;
								}
								val2.appearanceBehaviour.Add((Appearance)2);
								val2.appearanceBehaviour.Add((Appearance)9);
							}
							val2.Mods.Add(val3);
							list.Add(val2);
							if (i <= 14)
							{
								val2.appearanceBehaviour = new List<Appearance>();
								if (val2.tribes.Count > 0 && selectedTribes.Contains(val2.tribes[0]))
								{
									val2.appearanceBehaviour.Add((Appearance)6);
								}
							}
							SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc2, hiddenAttack: true, hiddenHealth: true, instantSpawn);
							((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
							{
								//IL_0002: Unknown result type (might be due to invalid IL or missing references)
								//IL_000c: Expected O, but got Unknown
								selectedCard = (SelectableCard)c2;
							});
						}
						else
						{
							list.Add(null);
						}
					}
					else
					{
						list.Add(null);
					}
				}
				Singleton<TextDisplayer>.Instance.ShowMessage("Now choose the [c:bR]tribes[c:].", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
				foreach (SelectableCard item2 in cards)
				{
					((Card)item2).SetInteractionEnabled(true);
					((InteractableBase)item2).SetEnabled(true);
				}
			}
			((Card)confirm).SetInteractionEnabled(true);
			((InteractableBase)confirm).SetEnabled(true);
			skipRegenerate = false;
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
			if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("previous page"))
			{
				if (page > 0)
				{
					page--;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("next page"))
			{
				if ((double)page < Math.Ceiling((float)tribeCount / 15f))
				{
					page++;
				}
				DestroyAllCards(cards, playDeathAnim: true);
			}
			else if (((Card)selectedCard).Info.DisplayedNameEnglish.Equals("confirm"))
			{
				valid = true;
			}
			else if (selectedTribes.Contains(((Card)selectedCard).Info.tribes[0]))
			{
				selectedTribes.Remove(((Card)selectedCard).Info.tribes[0]);
				((Card)selectedCard).Anim.PlayDeathAnimation(true);
				DestroyAllCards(cards, playDeathAnim: false);
				instantSpawn = true;
			}
			else
			{
				selectedTribes.Add(((Card)selectedCard).Info.tribes[0]);
				((Card)selectedCard).Info.appearanceBehaviour.Add((Appearance)6);
				((Card)selectedCard).Anim.PlayTransformAnimation();
				yield return (object)new WaitForSeconds(0.15f);
				((Card)selectedCard).SetInfo(((Card)selectedCard).Info);
				yield return (object)new WaitForSeconds(0.15f);
				skipRegenerate = true;
			}
		}
		Singleton<TextDisplayer>.Instance.Clear();
		((Card)preview).Info.tribes = selectedTribes;
		((Card)confirm).Anim.PlayDeathAnimation(true);
		Object.Destroy((Object)(object)((Component)confirm).gameObject, 2f);
		yield return PostMultiTribeCardSelect(cards, selectedTribes);
	}

	public static IEnumerator PostCardSelect(List<SelectableCard> cards, SelectableCard selectedCard, int mode)
	{
		foreach (SelectableCard card in cards)
		{
			((Card)card).SetInteractionEnabled(false);
			((InteractableBase)card).SetEnabled(false);
			if ((Object)(object)card != (Object)(object)selectedCard)
			{
				((Card)card).Anim.PlayDeathAnimation(true);
				Object.Destroy((Object)(object)((Component)card).gameObject, 2f);
			}
		}
		string examineDialogue = "...";
		switch (mode)
		{
		case 0:
			if (((Card)selectedCard).Info.GemsCost.Count > 0)
			{
				GemType val = ((Card)selectedCard).Info.GemsCost[0];
				examineDialogue = $"A cost of a [c:bR]{((object)(GemType)(ref val)).ToString()} gem[c:].";
			}
			else
			{
				examineDialogue = ((((Card)selectedCard).Info.EnergyCost <= 0) ? ((((Card)selectedCard).Info.BonesCost <= 1) ? ((((Card)selectedCard).Info.BonesCost <= 0) ? ((((Card)selectedCard).Info.BloodCost <= 0) ? "A cost of... [c:bR]free[c:]." : $"A cost of [c:bR]{((Card)selectedCard).Info.BloodCost} blood[c:].") : "A cost of [c:bR]1 bone[c:].") : $"A cost of [c:bR]{((Card)selectedCard).Info.BonesCost} bones[c:].") : $"A cost of [c:bR]{((Card)selectedCard).Info.EnergyCost} energy[c:].");
			}
			break;
		case 1:
			examineDialogue = (((int)((Card)selectedCard).Info.SpecialStatIcon == 0) ? $"[c:bR]{((Card)selectedCard).Info.Attack} Power[c:]." : $"A special [c:bR]Power of {((Card)selectedCard).Info.DisplayedNameEnglish}[c:].");
			break;
		case 2:
			examineDialogue = $"[c:bR]{((Card)selectedCard).Info.Health} Health[c:].";
			break;
		case 3:
			examineDialogue = $"A portrait of [c:bR]{((Card)selectedCard).Info.DisplayedNameEnglish}[c:].";
			break;
		case 4:
			examineDialogue = $"A [c:bR]{((Card)selectedCard).Info.DisplayedNameEnglish}[c:] card.";
			break;
		case 5:
			examineDialogue = $"A complexity of [c:bR]{((Card)selectedCard).Info.DisplayedNameEnglish}[c:].";
			break;
		case 6:
			examineDialogue = $"An evolution to [c:bR]{((Card)selectedCard).Info.DisplayedNameEnglish}[c:].";
			break;
		case 7:
			examineDialogue = ((((Card)selectedCard).Info.evolveParams.turnsToEvolve != 1) ? $"[c:bR]{((Card)selectedCard).Info.evolveParams.turnsToEvolve} turns[c:]." : $"[c:bR]{((Card)selectedCard).Info.evolveParams.turnsToEvolve} turn[c:].");
			break;
		}
		IGCC.LookUp();
		yield return (object)new WaitForSeconds(0.25f);
		yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(examineDialogue, -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
		IGCC.LookDown();
		((Card)selectedCard).Anim.PlayDeathAnimation(true);
		Object.Destroy((Object)(object)((Component)selectedCard).gameObject, 2f);
		yield return (object)new WaitForSeconds(0.4f);
	}

	public static IEnumerator PostMultiSACardSelect(List<SelectableCard> cards, List<SpecialTriggeredAbility> selectedSAs, List<Trait> selectedTraits)
	{
		foreach (SelectableCard card in cards)
		{
			((Card)card).SetInteractionEnabled(false);
			((InteractableBase)card).SetEnabled(false);
			if ((((Card)card).Info.SpecialAbilities.Count <= 0 || !selectedSAs.Contains(((Card)card).Info.SpecialAbilities[0])) && (((Card)card).Info.traits.Count <= 0 || !selectedTraits.Contains(((Card)card).Info.traits[0])))
			{
				((Card)card).Anim.PlayDeathAnimation(true);
				Object.Destroy((Object)(object)((Component)card).gameObject, 2f);
			}
		}
		string examineDialogue = "";
		if (selectedSAs.Count > 0)
		{
			string text = "";
			int count = selectedSAs.Count;
			for (int i = 0; i < count; i++)
			{
				string text2 = text;
				SpecialTriggeredAbility val = selectedSAs[i];
				text = text2 + ((object)(SpecialTriggeredAbility)(ref val)).ToString();
				if (i < count - 1)
				{
					text = ((i != count - 2) ? (text + "[c:], [c:bR]") : ((count != 2) ? (text + "[c:], and [c:bR]") : (text + "[c:] and [c:bR]")));
				}
			}
			examineDialogue = string.Format(Localization.Translate("A [c:bR]Special Ability of {0}[c:]."), text);
		}
		if (selectedTraits.Count > 0)
		{
			string text3 = "";
			int count2 = selectedTraits.Count;
			for (int j = 0; j < count2; j++)
			{
				string text4 = text3;
				Trait val2 = selectedTraits[j];
				text3 = text4 + ((object)(Trait)(ref val2)).ToString();
				if (j < count2 - 1)
				{
					text3 = ((j != count2 - 2) ? (text3 + "[c:], [c:bR]") : ((count2 != 2) ? (text3 + "[c:], and [c:bR]") : (text3 + "[c:] and [c:bR]")));
				}
			}
			if (examineDialogue != "")
			{
				examineDialogue += " ";
			}
			examineDialogue += string.Format(Localization.Translate("A [c:bR]Trait of {0}[c:]."), text3);
		}
		if (selectedSAs.Count == 0 && selectedTraits.Count == 0)
		{
			examineDialogue = string.Format(Localization.Translate("[c:bR]No Special Abilities. No Traits[c:]."));
		}
		IGCC.LookUp();
		yield return (object)new WaitForSeconds(0.25f);
		yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(examineDialogue, -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
		IGCC.LookDown();
		foreach (SelectableCard card2 in cards)
		{
			if ((Object)(object)card2 != (Object)null && ((((Card)card2).Info.SpecialAbilities.Count > 0 && selectedSAs.Contains(((Card)card2).Info.SpecialAbilities[0])) || (((Card)card2).Info.traits.Count > 0 && selectedTraits.Contains(((Card)card2).Info.traits[0]))))
			{
				((Card)card2).Anim.PlayDeathAnimation(true);
				Object.Destroy((Object)(object)((Component)card2).gameObject, 2f);
			}
		}
		yield return (object)new WaitForSeconds(0.4f);
	}

	public static IEnumerator PostMultiSigilCardSelect(List<SelectableCard> cards, List<Ability> selectedSigils)
	{
		foreach (SelectableCard card in cards)
		{
			((Card)card).SetInteractionEnabled(false);
			((InteractableBase)card).SetEnabled(false);
			if (((Card)card).Info.Abilities.Count == 0 || !selectedSigils.Contains(((Card)card).Info.Abilities[0]))
			{
				((Card)card).Anim.PlayDeathAnimation(true);
				Object.Destroy((Object)(object)((Component)card).gameObject, 2f);
			}
		}
		string examineDialogue;
		if (selectedSigils.Count > 0)
		{
			string text = "";
			int count = selectedSigils.Count;
			for (int i = 0; i < count; i++)
			{
				text = ((AbilitiesUtil.GetInfo(selectedSigils[i]).rulebookName == null || !(AbilitiesUtil.GetInfo(selectedSigils[i]).rulebookName != "")) ? (text + "sigil of " + ((Object)AbilitiesUtil.GetInfo(selectedSigils[i])).name) : (text + AbilitiesUtil.GetInfo(selectedSigils[i]).rulebookName));
				if (i < count - 1)
				{
					text = ((i != count - 2) ? (text + "[c:], [c:bR]") : ((count != 2) ? (text + "[c:], and [c:bR]") : (text + "[c:] and [c:bR]")));
				}
			}
			examineDialogue = string.Format(Localization.Translate("A [c:bR]Sigil of {0}[c:]."), text);
		}
		else
		{
			examineDialogue = string.Format(Localization.Translate("[c:bR]No Sigils[c:]."));
		}
		IGCC.LookUp();
		yield return (object)new WaitForSeconds(0.25f);
		yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(examineDialogue, -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
		IGCC.LookDown();
		foreach (SelectableCard card2 in cards)
		{
			if ((Object)(object)card2 != (Object)null && ((Card)card2).Info.Abilities.Count > 0 && selectedSigils.Contains(((Card)card2).Info.Abilities[0]))
			{
				((Card)card2).Anim.PlayDeathAnimation(true);
				Object.Destroy((Object)(object)((Component)card2).gameObject, 2f);
			}
		}
		yield return (object)new WaitForSeconds(0.4f);
	}

	public static IEnumerator PostMultiTribeCardSelect(List<SelectableCard> cards, List<Tribe> selectedTribes)
	{
		foreach (SelectableCard card in cards)
		{
			((Card)card).SetInteractionEnabled(false);
			((InteractableBase)card).SetEnabled(false);
			if (((Card)card).Info.tribes.Count == 0 || !selectedTribes.Contains(((Card)card).Info.tribes[0]))
			{
				((Card)card).Anim.PlayDeathAnimation(true);
				Object.Destroy((Object)(object)((Component)card).gameObject, 2f);
			}
		}
		string examineDialogue;
		if (selectedTribes.Count > 0)
		{
			string text = "";
			int count = selectedTribes.Count;
			for (int i = 0; i < count; i++)
			{
				string text2;
				if ((int)selectedTribes[i] < 7)
				{
					Tribe val = selectedTribes[i];
					text2 = Localization.Translate(((object)(Tribe)(ref val)).ToString());
				}
				else
				{
					text2 = JsonParser.GetModdedGuid(selectedTribes[i]);
					text2 = text2.Substring(text2.IndexOf('.') + 1);
				}
				text += Localization.Translate(text2);
				if (i < count - 1)
				{
					text = ((i != count - 2) ? (text + "[c:], [c:bR]") : ((count != 2) ? (text + "[c:], and [c:bR]") : (text + "[c:] and [c:bR]")));
				}
			}
			examineDialogue = string.Format(Localization.Translate("[c:bR]{0} Tribe[c:]."), text);
		}
		else
		{
			examineDialogue = string.Format(Localization.Translate("[c:bR]No Tribes[c:]."));
		}
		IGCC.LookUp();
		yield return (object)new WaitForSeconds(0.25f);
		yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(examineDialogue, -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
		IGCC.LookDown();
		foreach (SelectableCard card2 in cards)
		{
			if ((Object)(object)card2 != (Object)null && ((Card)card2).Info.tribes.Count > 0 && selectedTribes.Contains(((Card)card2).Info.tribes[0]))
			{
				((Card)card2).Anim.PlayDeathAnimation(true);
				Object.Destroy((Object)(object)((Component)card2).gameObject, 2f);
			}
		}
		yield return (object)new WaitForSeconds(0.4f);
	}

	public static void DestroyAllCards(List<SelectableCard> cards, bool playDeathAnim)
	{
		foreach (SelectableCard card in cards)
		{
			((Card)card).SetInteractionEnabled(false);
			((InteractableBase)card).SetEnabled(false);
			if (playDeathAnim)
			{
				((Card)card).Anim.PlayDeathAnimation(true);
				Object.Destroy((Object)(object)((Component)card).gameObject, 2f);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)card).gameObject, 0f);
			}
		}
	}

	public static Vector3 GetCardIndexLoc(Transform obj, int i)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		switch (i)
		{
		case 15:
			return obj.position + new Vector3(Random.value * 0.05f - 2.075f, 0f, Random.value * 0.05f + 3f);
		case 16:
			return obj.position + new Vector3(Random.value * 0.05f + 6.925f, 0f, Random.value * 0.05f + 3f);
		case 17:
			return obj.position + new Vector3(Random.value * 0.05f - 2.075f, 0f, Random.value * 0.05f + 5f);
		case 18:
			return obj.position + new Vector3(Random.value * 0.05f + 6.925f, 0f, Random.value * 0.05f + 5f);
		case 19:
			return obj.position + new Vector3(Random.value * 0.05f - 2.075f, 0f, Random.value * 0.05f + 1f);
		case 20:
			return obj.position + new Vector3(Random.value * 0.05f + 6.925f, 0f, Random.value * 0.05f + 1f);
		default:
		{
			int num = i / 5;
			int num2 = i % 5;
			return obj.position + new Vector3(Random.value * 0.05f + (float)num2 * 1.5f - 0.575f, 0f, Random.value * 0.05f + 5f - (float)num * 2f);
		}
		}
	}

	public static SelectableCard CreateCard(DeathCardCreationSequencer __instance, List<CardInfo> choices, List<SelectableCard> cards, Vector3 vector, bool hiddenAttack, bool hiddenHealth, bool instantSpawn)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		SelectableCard val = (SelectableCard)((object)__instance).GetType().GetMethod("SpawnCard", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { ((Component)__instance).transform });
		if (hiddenAttack || choices.Count > 15)
		{
			((Card)val).RenderInfo.hiddenAttack = true;
		}
		if (hiddenHealth || choices.Count > 15)
		{
			((Card)val).RenderInfo.hiddenHealth = true;
		}
		((Component)val).gameObject.SetActive(true);
		((Card)val).SetInfo(choices[choices.Count - 1]);
		((Card)val).SetInteractionEnabled(false);
		((InteractableBase)val).SetEnabled(false);
		cards.Add(val);
		((Component)val).transform.position = vector + Vector3.up * 2f + (Vector3)((object)__instance).GetType().GetField("THROW_CARDS_FROM", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) * 2f;
		((Component)val).transform.eulerAngles = new Vector3(90f, 0f, 0f);
		if (instantSpawn)
		{
			Tween.Position(((Component)val).transform, vector, 0f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
		}
		else
		{
			Tween.Position(((Component)val).transform, vector, 0.1f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
		}
		return val;
	}

	public static SelectableCard CreateConfirmCard(DeathCardCreationSequencer __instance, Vector3 vector, CardInfo info)
	{
		//IL_0027: 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_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_0065: 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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: 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_00ed: Expected O, but got Unknown
		SelectableCard val = (SelectableCard)((object)__instance).GetType().GetMethod("SpawnCard", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { ((Component)__instance).transform });
		((Card)val).RenderInfo.hiddenAttack = true;
		((Card)val).RenderInfo.hiddenHealth = true;
		((Component)val).gameObject.SetActive(true);
		((Card)val).SetInfo(info);
		((Card)val).SetInteractionEnabled(false);
		((InteractableBase)val).SetEnabled(false);
		((Component)val).transform.position = vector + Vector3.up * 2f + (Vector3)((object)__instance).GetType().GetField("THROW_CARDS_FROM", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) * 2f;
		((Component)val).transform.eulerAngles = new Vector3(90f, 0f, 0f);
		Tween.Position(((Component)val).transform, vector, 0.1f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
		return val;
	}

	public static SelectableCard CreatePreviewCard(DeathCardCreationSequencer __instance, Vector3 vector, CardInfo info)
	{
		//IL_0027: 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_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_0065: 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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: 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_00ed: Expected O, but got Unknown
		SelectableCard val = (SelectableCard)((object)__instance).GetType().GetMethod("SpawnCard", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { ((Component)__instance).transform });
		((Card)val).RenderInfo.hiddenAttack = true;
		((Card)val).RenderInfo.hiddenHealth = true;
		((Component)val).gameObject.SetActive(true);
		((Card)val).SetInfo(info);
		((Card)val).SetInteractionEnabled(false);
		((InteractableBase)val).SetEnabled(false);
		((Component)val).transform.position = vector + Vector3.up * 2f + (Vector3)((object)__instance).GetType().GetField("THROW_CARDS_FROM", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) * 2f;
		((Component)val).transform.eulerAngles = new Vector3(90f, 0f, 0f);
		Tween.Position(((Component)val).transform, vector, 0.1f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
		return val;
	}

	public static IEnumerator FinalizeCard(DeathCardCreationSequencer __instance, SelectableCard preview)
	{
		IGCC.LookDown();
		SelectableCard selectedCard = null;
		List<CardInfo> list = new List<CardInfo>();
		List<SelectableCard> cards = new List<SelectableCard>();
		Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
		for (int i = 0; i <= 3; i++)
		{
			Vector3 cardIndexLoc = GetCardIndexLoc(obj, i + 10);
			CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
			CardModificationInfo val2 = new CardModificationInfo();
			switch (i)
			{
			case 0:
				val2.nameReplacement = "export and quit";
				break;
			case 1:
				val2.nameReplacement = "export and create another";
				break;
			case 2:
				val2.nameReplacement = "quit without exporting";
				break;
			case 3:
				val2.nameReplacement = "create another without exporting";
				break;
			}
			val.Mods.Add(val2);
			list.Add(val);
			SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: true, instantSpawn: false);
			((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				selectedCard = (SelectableCard)c2;
			});
		}
		Singleton<TextDisplayer>.Instance.ShowMessage("What should I do with this card?", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
		foreach (SelectableCard item in cards)
		{
			((Card)item).SetInteractionEnabled(true);
			((InteractableBase)item).SetEnabled(true);
		}
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
		Singleton<TextDisplayer>.Instance.Clear();
		if (((Card)selectedCard).Info.DisplayedNameEnglish.Contains("export "))
		{
			yield return Singleton<TextDisplayer>.Instance.ShowMessage("Exporting card...", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
			string text = "IGCC_" + Regex.Replace(((Card)preview).Info.DisplayedNameEnglish.Replace(" ", "_"), "\\W", "_");
			string text2 = JsonParser.ParseCard(text, preview);
			Directory.CreateDirectory(Paths.PluginPath + "/IGCCExports/Cards");
			File.WriteAllText(Paths.PluginPath + "/IGCCExports/Cards/" + text + "_card.jldr2", text2);
			Directory.CreateDirectory(Paths.PluginPath + "/IGCCExports/Artwork");
			File.WriteAllBytes(Paths.PluginPath + "/IGCCExports/Artwork/" + text + ".png", ImageConversion.EncodeToPNG(CloneTextureReadable(((Card)preview).Info.portraitTex.texture)));
			Texture2D emissionForPortrait = PortraitLoader.Instance.GetEmissionForPortrait(((Card)preview).Info.portraitTex.texture);
			if ((Object)(object)emissionForPortrait != (Object)null)
			{
				File.WriteAllBytes(Paths.PluginPath + "/IGCCExports/Artwork/" + text + "_emission.png", ImageConversion.EncodeToPNG(CloneTextureReadable(emissionForPortrait)));
			}
			if ((Object)(object)((Card)preview).Info.alternatePortrait != (Object)null)
			{
				File.WriteAllBytes(Paths.PluginPath + "/IGCCExports/Artwork/" + text + "_alt.png", ImageConversion.EncodeToPNG(CloneTextureReadable(((Card)preview).Info.alternatePortrait.texture)));
				Texture2D emissionForPortrait2 = PortraitLoader.Instance.GetEmissionForPortrait(((Card)preview).Info.alternatePortrait.texture);
				if ((Object)(object)emissionForPortrait2 != (Object)null)
				{
					File.WriteAllBytes(Paths.PluginPath + "/IGCCExports/Artwork/" + text + "_alt_emission.png", ImageConversion.EncodeToPNG(CloneTextureReadable(emissionForPortrait2)));
				}
			}
			IGCC.Log.LogDebug((object)("Card:\n" + text2));
			JSONLoaderAPI.AddCards(new string[1] { text2 });
			yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("The card has been created, loaded, and exported to IGCCExports inside the BepInEx plugins folder.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
		}
		if (((Card)selectedCard).Info.DisplayedNameEnglish.Contains("quit"))
		{
			((Card)preview).Anim.PlayDeathAnimation(true);
			Object.Destroy((Object)(object)((Component)preview).gameObject, 0.5f);
			DestroyAllCards(cards, playDeathAnim: true);
			yield return (object)new WaitForSeconds(0.55f);
		}
		else
		{
			DestroyAllCards(cards, playDeathAnim: true);
		}
	}

	public static IEnumerator CreateStepCard(DeathCardCreationSequencer __instance, IntRef ir)
	{
		IGCC.LookDown();
		SelectableCard selectedCard = null;
		List<CardInfo> list = new List<CardInfo>();
		List<SelectableCard> cards = new List<SelectableCard>();
		Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
		for (int i = 0; i <= 11; i++)
		{
			Vector3 cardIndexLoc = GetCardIndexLoc(obj, (i < 11) ? i : 14);
			CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
			CardModificationInfo val2 = new CardModificationInfo();
			switch (i)
			{
			case 0:
				val2.nameReplacement = "cost (set)";
				break;
			case 1:
				val2.nameReplacement = "cost (add)";
				break;
			case 2:
				val2.nameReplacement = "power";
				break;
			case 3:
				val2.nameReplacement = "health";
				break;
			case 4:
				val2.nameReplacement = "sigils";
				break;
			case 5:
				val2.nameReplacement = "tribes";
				break;
			case 6:
				val2.nameReplacement = "sp. abilities";
				break;
			case 7:
				val2.nameReplacement = "portrait";
				break;
			case 8:
				val2.nameReplacement = "rarity";
				break;
			case 9:
				val2.nameReplacement = "complexity";
				break;
			case 10:
				val2.nameReplacement = "alternate portrait";
				break;
			case 11:
				val2.nameReplacement = "finish";
				val.appearanceBehaviour.Add((Appearance)7);
				break;
			}
			val.Mods.Add(val2);
			list.Add(val);
			SelectableCard obj2 = CreateCard(__instance, list, cards, cardIndexLoc, hiddenAttack: true, hiddenHealth: true, instantSpawn: false);
			((MainInputInteractable)obj2).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectEnded, (Action<MainInputInteractable>)delegate(MainInputInteractable c2)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				selectedCard = (SelectableCard)c2;
			});
		}
		Singleton<TextDisplayer>.Instance.ShowMessage("Choose a property.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
		foreach (SelectableCard item in cards)
		{
			((Card)item).SetInteractionEnabled(true);
			((InteractableBase)item).SetEnabled(true);
		}
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null));
		Singleton<TextDisplayer>.Instance.Clear();
		ir.Value = cards.IndexOf(selectedCard) + 1;
		if (ir.Value == 12)
		{
			ir.Value = -1;
		}
		DestroyAllCards(cards, playDeathAnim: true);
		yield return (object)new WaitForSeconds(0.55f);
	}

	public static Texture2D CloneTextureReadable(Texture2D source)
	{
		//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_0052: 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_0071: Expected O, but got Unknown
		RenderTexture temporary = RenderTexture.GetTemporary(((Texture)source).width, ((Texture)source).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1);
		Graphics.Blit((Texture)(object)source, temporary);
		RenderTexture active = RenderTexture.active;
		RenderTexture.active = temporary;
		Texture2D val = new Texture2D(((Texture)source).width, ((Texture)source).height);
		val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
		val.Apply();
		RenderTexture.active = active;
		RenderTexture.ReleaseTemporary(temporary);
		return val;
	}
}
namespace IGCCMod
{
	[BepInPlugin("IngoH.inscryption.IGCCMod", "IGCCMod", "2.5.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class IGCC : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(DoorKnobInteractable), "OnCursorSelectStart")]
		public class DoorPatch : DoorKnobInteractable
		{
			public static bool Prefix(DoorKnobInteractable __instance)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Expected O, but got Unknown
				SaveManager.SaveFile.currentRun.causeOfDeath = new CauseOfDeath((Type)16);
				SaveManager.SaveToFile(false);
				SceneLoader.Load("Part1_Sanctum");
				return true;
			}
		}

		[HarmonyPatch(typeof(SanctumSceneSequencer), "IntroSequence")]
		public class SanctumIntroPatch : SanctumSceneSequencer
		{
			public static bool Prefix(SanctumSceneSequencer __instance)
			{
				return false;
			}
		}

		[HarmonyPatch(typeof(SanctumSceneSequencer), "IntroSequence")]
		public class PostSanctumIntroPatch : SanctumSceneSequencer
		{
			public static IEnumerator Postfix(IEnumerator __result, SanctumSceneSequencer __instance)
			{
				((object)__instance).GetType().GetMethod("StartHumLoop", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, null);
				((object)__instance).GetType().GetMethod("InitializeLeshy", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, null);
				Singleton<ViewManager>.Instance.SwitchToView((View)25, true, true);
				yield return (object)new WaitForSeconds(0.5f);
				LookUp();
				Singleton<InteractionCursor>.Instance.SetHidden(false);
				yield return (object)new WaitForSeconds(0.5f);
				yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("You entered the [c:bR]card creation[c:] mode.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
				yield return ((object)__instance).GetType().GetMethod("DeathCardSequence", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, null);
			}
		}

		[HarmonyPatch(typeof(ViewManager), "OffsetPosition", new Type[]
		{
			typeof(Vector3),
			typeof(float)
		})]
		public class RuleBookCameraPatch : ViewManager
		{
			public static bool Prefix(ViewManager __instance, Vector3 cameraOffset)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Invalid comparison between Unknown and I4
				//IL_001b: 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_0080: 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)
				if ((int)Singleton<ViewManager>.Instance.CurrentView == 25)
				{
					_ = Singleton<ViewManager>.Instance.CameraParent.localPosition;
					if (cameraOffset.z >= 0f)
					{
						Tween.LocalRotation(Singleton<ViewManager>.Instance.CameraParent, new Vector3(90f, 0f, 0f), 0.25f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
					}
					else
					{
						Tween.LocalRotation(Singleton<ViewManager>.Instance.CameraParent, new Vector3(105f, 0f, 0f), 0.25f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(SanctumSceneSequencer), "DeathCardSequence", null)]
		public class DeathCardStartPatch : SanctumSceneSequencer
		{
			public static bool Prefix(SanctumSceneSequencer __instance)
			{
				return false;
			}
		}

		[HarmonyPatch(typeof(SanctumSceneSequencer), "DeathCardSequence", null)]
		public class PostDeathCardStartPatch : SanctumSceneSequencer
		{
			public static IEnumerator Postfix(IEnumerator __result, SanctumSceneSequencer __instance, DeathCardCreationSequencer ___deathCardSequencer)
			{
				yield return (object)new WaitForSeconds(0.25f);
				yield return ___deathCardSequencer.CreateCardSequence(true);
			}
		}

		[HarmonyPatch(typeof(DeathCardCreationSequencer), "CreateCardSequence", new Type[] { typeof(bool) })]
		public class DeathCardPatch : DeathCardCreationSequencer
		{
			public static bool Prefix(DeathCardCreationSequencer __instance)
			{
				return false;
			}
		}

		[HarmonyPatch(typeof(DeathCardCreationSequencer), "CreateCardSequence", new Type[] { typeof(bool) })]
		public class PostDeathCardPatch : DeathCardCreationSequencer
		{
			public static IEnumerator Postfix(IEnumerator __result, DeathCardCreationSequencer __instance, KeyboardInputHandler ___keyboardInput)
			{
				bool done = false;
				if ((int)SaveManager.SaveFile.currentRun.causeOfDeath.opponentType != 16)
				{
					LookUp();
					yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("It appears that you lost normally.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
					yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("Only worthy challengers may access the Card Creator.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
					yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("Try again, but this time open the backroom door normally.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
					yield return Singleton<TextDisplayer>.Instance.ShowMessage("Goodbye.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
					yield return (object)new WaitForSeconds(0.5f);
					LeshyAnimationController.Instance.LeftArm.PlayAnimation("takephoto_left");
					yield return (object)new WaitForSeconds(1.5f);
					if (Random.value > 0.8f)
					{
						Singleton<VideoCameraRig>.Instance.PlayCameraAnim("refocus_medium");
					}
					LeshyAnimationController.Instance.LeftArm.SetTrigger("photo_flare");
					yield return (object)new WaitForSeconds(1f);
					Singleton<TextDisplayer>.Instance.Clear();
					AudioSource obj2 = AudioController.Instance.PlaySound2D("camera_flash_gameover", (MixerGroup)0, 0.85f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
					((Object)((Component)obj2).gameObject).name = "flashSound";
					Object.DontDestroyOnLoad((Object)(object)((Component)obj2).gameObject);
					AudioController.Instance.StopAllLoops();
					Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>().SetColor(GameColors.Instance.nearWhite);
					((ScreenEffect)Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>()).SetIntensity(1f, 100f);
					SaveManager.SaveFile.NewPart1Run();
					yield return (object)new WaitForSeconds(1f);
					SceneLoader.CompleteAsyncLoad(SceneLoader.StartAsyncLoad("Part1_Cabin"));
					SaveManager.SaveToFile(false);
					yield break;
				}
				while (!done)
				{
					Transform obj = ((List<Transform>)((object)__instance).GetType().GetField("cardPositionMarkers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))[0];
					Vector3 cardIndexLoc = CardSelectSequencers.GetCardIndexLoc(obj, 17);
					CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
					CardModificationInfo item = new CardModificationInfo
					{
						nameReplacement = "current card"
					};
					val.Mods.Add(item);
					SelectableCard preview = CardSelectSequencers.CreatePreviewCard(__instance, cardIndexLoc, val);
					List<int> prevSelects = new List<int>();
					int i = 1;
					int j = 0;
					while (i != -1)
					{
						yield return CardCreationStep(i, prevSelects, __instance, preview);
						if (j < 7)
						{
							i++;
							j++;
							if (i == 2)
							{
								i++;
							}
						}
						else
						{
							IntRef ir = new IntRef();
							yield return StepSelect(__instance, ir);
							i = ir.Value;
						}
					}
					Vector3 cardIndexLoc2 = CardSelectSequencers.GetCardIndexLoc(obj, 7);
					Tween.Position(((Component)preview).transform, cardIndexLoc2, 0.25f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
					___keyboardInput.maxInputLength = 127;
					yield return (object)new WaitForSeconds(0.25f);
					ZoomIn();
					Singleton<TextDisplayer>.Instance.ShowMessage("You should give it a name.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
					CardModificationInfo nameMod = new CardModificationInfo();
					((Card)preview).Info.Mods.Add(nameMod);
					yield return ((object)__instance).GetType().GetMethod("EnterNameForCard", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[2] { preview, nameMod });
					yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("[c:bR]" + nameMod.nameReplacement.Trim() + "[c:]?", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
					yield return (object)new WaitForSeconds(0.25f);
					___keyboardInput.maxInputLength = 1027;
					Singleton<TextDisplayer>.Instance.ShowMessage("Please type the description.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
					yield return EnterDescription(___keyboardInput, preview);
					yield return (object)new WaitForSeconds(0.25f);
					MoveDown();
					yield return CardSelectSequencers.FinalizeCard(__instance, preview);
					if ((Object)(object)preview == (Object)null)
					{
						done = true;
					}
					else
					{
						((Card)preview).Anim.PlayDeathAnimation(true);
						Object.Destroy((Object)(object)((Component)preview).gameObject, 2f);
						yield return (object)new WaitForSeconds(0.25f);
					}
					ResetCamera();
				}
				yield return (object)new WaitForSeconds(0.5f);
				yield return Singleton<TextDisplayer>.Instance.ShowMessage("It is time for you to return.", (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
				LookUp();
				yield return (object)new WaitForSeconds(0.5f);
				LeshyAnimationController.Instance.LeftArm.PlayAnimation("takephoto_left");
				yield return (object)new WaitForSeconds(1.5f);
				if (Random.value > 0.8f)
				{
					Singleton<VideoCameraRig>.Instance.PlayCameraAnim("refocus_medium");
				}
				LeshyAnimationController.Instance.LeftArm.SetTrigger("photo_flare");
				yield return (object)new WaitForSeconds(1f);
				Singleton<TextDisplayer>.Instance.Clear();
				AudioSource obj3 = AudioController.Instance.PlaySound2D("camera_flash_gameover", (MixerGroup)0, 0.85f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
				((Object)((Component)obj3).gameObject).name = "flashSound";
				Object.DontDestroyOnLoad((Object)(object)((Component)obj3).gameObject);
				AudioController.Instance.StopAllLoops();
				Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>().SetColor(GameColors.Instance.nearWhite);
				((ScreenEffect)Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>()).SetIntensity(1f, 100f);
				yield return (object)new WaitForSeconds(1f);
				SceneLoader.CompleteAsyncLoad(SceneLoader.StartAsyncLoad("Part1_Cabin"));
				SaveManager.SaveToFile(false);
			}

			private static IEnumerator StepSelect(DeathCardCreationSequencer __instance, IntRef i)
			{
				yield return CardSelectSequencers.CreateStepCard(__instance, i);
			}

			private static IEnumerator CardCreationStep(int i, List<int> prevSelects, DeathCardCreationSequencer __instance, SelectableCard preview)
			{
				CardInfo info = ((Card)preview).Info;
				switch (i)
				{
				case 1:
					yield return CardSelectSequencers.CreateCostCard(__instance, preview);
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				case 2:
					yield return CardSelectSequencers.CreateCostCardAdditive(__instance, preview);
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				case 3:
					yield return CardSelectSequencers.CreateAttackCard(__instance, preview);
					((Card)preview).RenderInfo.hiddenAttack = false;
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				case 4:
					yield return CardSelectSequencers.CreateHealthCard(__instance, preview);
					((Card)preview).RenderInfo.hiddenHealth = false;
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				case 5:
					if (prevSelects.Contains(5))
					{
						info.abilities = new List<Ability>();
						info.evolveParams = null;
						info.iceCubeParams = null;
					}
					yield return CardSelectSequencers.CreateSigilCard(__instance, preview);
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					if (((Card)preview).Info.Abilities.Contains((Ability)5) || ((Card)preview).Info.Abilities.Contains((Ability)61))
					{
						yield return CardSelectSequencers.CreateEvolution(__instance, preview, 0);
						((Card)preview).Anim.PlayTransformAnimation();
						yield return (object)new WaitForSeconds(0.15f);
						((Card)preview).SetInfo(((Card)preview).Info);
						yield return (object)new WaitForSeconds(0.25f);
						if (((Card)preview).Info.evolveParams != null)
						{
							yield return CardSelectSequencers.CreateEvolutionTurnCount(__instance, preview);
							((Card)preview).Anim.PlayTransformAnimation();
							yield return (object)new WaitForSeconds(0.15f);
							((Card)preview).SetInfo(((Card)preview).Info);
							yield return (object)new WaitForSeconds(0.25f);
						}
					}
					if (((Card)preview).Info.Abilities.Contains((Ability)26))
					{
						yield return CardSelectSequencers.CreateEvolution(__instance, preview, 1);
						((Card)preview).Anim.PlayTransformAnimation();
						yield return (object)new WaitForSeconds(0.15f);
						((Card)preview).SetInfo(((Card)preview).Info);
						yield return (object)new WaitForSeconds(0.25f);
					}
					break;
				case 6:
					if (prevSelects.Contains(6))
					{
						info.tribes = new List<Tribe>();
					}
					yield return CardSelectSequencers.CreateTribeCard(__instance, preview);
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				case 7:
					yield return CardSelectSequencers.CreateSpecialAbilities(__instance, preview);
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				case 8:
				{
					List<Texture2D> portraits2 = PortraitLoader.Instance.GetPortraits();
					yield return CardSelectSequencers.CreatePortrait(__instance, preview, portraits2, 0);
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				}
				case 9:
					if (prevSelects.Contains(9))
					{
						info.appearanceBehaviour = new List<Appearance>();
						info.metaCategories = new List<CardMetaCategory>();
						((Card)preview).Anim.PlayTransformAnimation();
						yield return (object)new WaitForSeconds(0.15f);
						((Card)preview).SetInfo(((Card)preview).Info);
						((Card)preview).UpdateAppearanceBehaviours();
						yield return (object)new WaitForSeconds(0.25f);
					}
					yield return CardSelectSequencers.CreateRarity(__instance, preview);
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				case 10:
					yield return CardSelectSequencers.CreateComplexity(__instance, preview);
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				default:
					yield return (object)new WaitForSeconds(0.25f);
					break;
				case 11:
				{
					List<Texture2D> portraits = PortraitLoader.Instance.GetPortraits();
					yield return CardSelectSequencers.CreatePortrait(__instance, preview, portraits, 1);
					((Card)preview).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)preview).SetInfo(((Card)preview).Info);
					yield return (object)new WaitForSeconds(0.25f);
					break;
				}
				case 12:
					break;
				}
				if (!prevSelects.Contains(i))
				{
					prevSelects.Add(i);
				}
			}

			private static IEnumerator EnterDescription(KeyboardInputHandler ___keyboardInput, SelectableCard preview)
			{
				___keyboardInput.Reset();
				while (!___keyboardInput.EnteredInput)
				{
					string text = ___keyboardInput.KeyboardInput;
					if (text != "")
					{
						yield return Singleton<TextDisplayer>.Instance.ShowMessage(text, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null);
					}
					else
					{
						yield return Singleton<TextDisplayer>.Instance.ShowMessage("Please type the description."