Decompiled source of GoobertExtended v1.4.0

GoobertExtended.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.Saves;
using Pixelplacement;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("GoobertExtended")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A StarCraft inspired mod that brings StarCraftCore into the world of Inscryption")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GoobertExtended")]
[assembly: AssemblyTitle("GoobertExtended")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public static class Configs
{
	public static ConfigEntry<int> MaxRandomizations = Bind("General", "Max randomizations", 2, "Maximum amount of changes that can be made to a card");

	public static ConfigEntry<bool> SuperMode = Bind("General", "Crazy Mode", defaultValue: false, "Increases all values so Goobert will make lots of crazy changes.");

	public static ConfigEntry<int> ChanceOfCardReplacement = Bind("General", "Chance to card replaced", 25, "Chance for Goobert to do a bad job painting and give you a different card", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));

	public static ConfigEntry<string> CardReplacements = Bind("General", "Card replacements", "RingWorm, Opossum", "Cards Goobert gives you if he does a bad job");

	public static ConfigEntry<bool> DisablePaintDecal = Bind("General", "Disable Paint Decal", defaultValue: false, "Stops Goobert from adding the green paint all over the cards");

	public static ConfigEntry<bool> CanShuffleAllSigils = Bind("Sigils", "Shuffle Random Amount of Sigils", defaultValue: true, "All sigils have a chance to be shuffled if set to true. Otherwise only 1 will.");

	public static ConfigEntry<int> ChanceOfSigilChange = Bind("Sigils", "Chance To Change Sigils", 25, "Weight of chance to change sigils. Higher the value the higher the chance for it to happen.");

	public static ConfigEntry<int> ChanceOfSigilAdd = Bind("Sigils", "Chance To Add a Sigil", 10, "Weight of chance to change sigils. Higher the value the higher the chance for it to happen.");

	public static ConfigEntry<int> ChanceOfAttackChange = Bind("Attack", "Chance to Change the Attack", 25, "Weight of chance to change attack. Higher the value the higher the chance for it to happen.");

	public static ConfigEntry<int> ChanceOfHealthChange = Bind("Health", "Chance to Change the Health", 25, "Weight of chance to change health. Higher the value the higher the chance for it to happen.");

	public static ConfigEntry<int> ChanceOfCostChange = Bind("Cost", "Chance to Change the cost", 10, "Weight of chance to change cost. Higher the value the higher the chance for it to happen.");

	public static ConfigEntry<int> ChanceOfTribesChange = Bind("Tribes", "Chance To Change Tribes", 10, "Weight of chance to add or change change a Tribe. Higher the value the higher the chance for it to happen.");

	public static ConfigEntry<int> ChanceOfNameChange = Bind("Cosmetic", "Chance to Misspell name", 50, "Chance for Goobert to mispell the name. 0% is never and 100% is always", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));

	private static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description, AcceptableValueBase values = null)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		return ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, values, Array.Empty<object>()));
	}
}
[BepInPlugin("jamesgames.inscryption.goobertextended", "Goobert Extended", "1.4.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public const string PluginGuid = "jamesgames.inscryption.goobertextended";

	public const string PluginName = "Goobert Extended";

	public const string PluginVersion = "1.4.0";

	public static Plugin Instance;

	public static ManualLogSource Log;

	private void Awake()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading Goobert Extended...");
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		new Harmony("jamesgames.inscryption.goobertextended").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Goobert Extended!");
	}
}
[HarmonyPatch]
internal class CopyCard_Patches
{
	public static int Seed;

	private static Vector3 selectedCardEaselPosition = Vector3.zero;

	private static Vector3 copiedCardEaselPosition = Vector3.zero;

	private static Quaternion selectedCardEaselRotation = Quaternion.identity;

	private static Quaternion copiedCardEaselRotation = Quaternion.identity;

	private static List<string[]> BadPaintingTexts = new List<string[]>
	{
		new string[2] { "Rrrgh!", "What have I done!?" },
		new string[2] { "Arrrgh!", "This was too difficult!" },
		new string[2] { "Master deserves better!", "Don't tell Master!" },
		new string[2] { "My attempt failed!", "I am not ready!" },
		new string[2] { "Too tricky!", "Next attempt MUST work!" }
	};

	[HarmonyPatch(typeof(CopyCardSequencer), "Start")]
	[HarmonyPostfix]
	public static void CopyCardSequence_Start_Patch(CopyCardSequencer __instance)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		selectedCardEaselPosition = ((Component)__instance.selectedCardEasel).transform.position;
		selectedCardEaselRotation = ((Component)__instance.selectedCardEasel).transform.rotation;
		copiedCardEaselPosition = ((Component)__instance.copiedCardEasel).transform.position;
		copiedCardEaselRotation = ((Component)__instance.copiedCardEasel).transform.rotation;
	}

	[HarmonyPatch(typeof(CopyCardSequencer), "CopyCardSequence")]
	[HarmonyPostfix]
	public static IEnumerator CopyCardSequence_Patch(IEnumerator enumerator, CopyCardSequencer __instance)
	{
		((Component)__instance.selectedCardEasel).transform.position = selectedCardEaselPosition;
		((Component)__instance.selectedCardEasel).transform.rotation = selectedCardEaselRotation;
		((Component)__instance.copiedCardEasel).transform.position = copiedCardEaselPosition;
		((Component)__instance.copiedCardEasel).transform.rotation = copiedCardEaselRotation;
		Singleton<ViewManager>.Instance.SwitchToView((View)1, false, true);
		((Component)__instance.bottleAnim).gameObject.SetActive(false);
		((Component)__instance.selectedCardEasel).gameObject.SetActive(false);
		((Component)__instance.copiedCardEasel).gameObject.SetActive(false);
		((Component)__instance.copyCardToInstantiate).gameObject.SetActive(false);
		SelectableCard copyCard = Object.Instantiate<GameObject>(((Component)__instance.copyCardToInstantiate).gameObject, ((Component)__instance.copyCardToInstantiate).transform.parent).GetComponent<SelectableCard>();
		((InteractableBase)copyCard).SetEnabled(false);
		((Component)copyCard).gameObject.SetActive(true);
		CardInfo info = new CardInfo();
		CardRenderInfo renderInfo = ((Card)copyCard).RenderInfo;
		CardRenderInfo renderInfo2 = ((Card)copyCard).RenderInfo;
		bool hiddenAttack = true;
		renderInfo2.hiddenHealth = true;
		renderInfo.hiddenAttack = hiddenAttack;
		((Card)copyCard).SetInfo(info);
		__instance.selectionSlot.Disable();
		((HighlightedInteractable)__instance.selectionSlot).SetShown(false, true);
		((Component)__instance.selectionSlot).gameObject.SetActive(false);
		yield return (object)new WaitForSeconds(0.2f);
		((Component)__instance.selectedCardEasel).gameObject.SetActive(true);
		((Component)__instance.copiedCardEasel).gameObject.SetActive(true);
		((MonoBehaviour)__instance).StartCoroutine(__instance.DropItemAnim(__instance.copiedCardEaselAnim, ""));
		yield return __instance.DropItemAnim(__instance.selectedCardEaselAnim, "wood_object_hit");
		yield return (object)new WaitForSeconds(0.25f);
		yield return __instance.DropItemAnim(__instance.bottleAnim, "glass_object_hit");
		yield return (object)new WaitForSeconds(1f);
		yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("CopyCardIntro1", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
		yield return (object)new WaitForSeconds(0.1f);
		__instance.JumpBottle(0.3f, 0.15f);
		__instance.gooAnim.SetBool("speaking", true);
		yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("CopyCardIntro2", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
		__instance.JumpBottle(0.3f, 0.1f);
		__instance.gooAnim.SetBool("speaking", false);
		yield return __instance.pile.SpawnCards(RunState.DeckList.Count, 0.5f);
		Singleton<TableRuleBook>.Instance.SetOnBoard(true);
		((Component)__instance.selectionSlot).gameObject.SetActive(true);
		__instance.selectionSlot.RevealAndEnable();
		((InteractableBase)__instance.selectionSlot).ClearDelegates();
		SelectCardFromDeckSlot selectCardFromDeckSlot = __instance.selectionSlot;
		((MainInputInteractable)selectCardFromDeckSlot).CursorSelectStarted = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)selectCardFromDeckSlot).CursorSelectStarted, (Action<MainInputInteractable>)delegate(MainInputInteractable i)
		{
			__instance.OnSlotSelected(i);
		});
		yield return __instance.confirmStone.WaitUntilConfirmation();
		__instance.selectionSlot.Disable();
		yield return (object)new WaitForSeconds(0.3f);
		__instance.confirmStone.Exit();
		yield return (object)new WaitForSeconds(0.2f);
		Singleton<ViewManager>.Instance.SwitchToView((View)1, false, true);
		yield return (object)new WaitForSeconds(0.2f);
		Tween.LocalRotation(__instance.copiedCardEasel, new Vector3(0f, -105f, 0f), 0.2f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
		Tween.LocalRotation(__instance.selectedCardEasel, new Vector3(0f, 105f, 0f), 0.2f, 0.02f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
		Tween.Rotate(((Component)__instance.bottleAnim).transform.parent, new Vector3(0f, -40f, 0f), (Space)1, 0.15f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
		__instance.gooEyesController.SetLookTarget(((Component)__instance.selectionSlot.Card).transform);
		yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("CopyCardExamineSelection", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
		yield return (object)new WaitForSeconds(0.2f);
		Tween.Rotate(((Component)__instance.bottleAnim).transform.parent, new Vector3(0f, 80f, 0f), (Space)1, 0.2f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
		__instance.gooEyesController.SetLookTarget(((Component)copyCard).transform);
		__instance.gooAnim.SetTrigger("painting");
		yield return (object)new WaitForSeconds(3.5f);
		bool badPainting = SeededRandom.Range(0, 100, Seed++) < Configs.ChanceOfCardReplacement.Value;
		SelectableCard replacementCard = null;
		if (badPainting)
		{
			SelectableCard selectableCard = ResourceBank.Get<SelectableCard>("prefabs/cards/SelectableCard");
			GameObject parent = GameObject.Find("GooWizard");
			Plugin.Log.LogInfo((object)("GooWizard parent: " + (object)parent));
			replacementCard = Object.Instantiate<SelectableCard>(selectableCard, parent.transform);
			((Component)replacementCard).gameObject.SetActive(false);
			yield return BadPainting(__instance, replacementCard);
		}
		else
		{
			CardInfo cardInfo = __instance.CreateCloneCard(((Card)__instance.selectionSlot.Card).Info);
			((CardCollectionInfo)RunState.Run.playerDeck).AddCard(cardInfo);
			SaveManager.SaveToFile(true);
			CardRenderInfo renderInfo3 = ((Card)copyCard).RenderInfo;
			CardRenderInfo renderInfo4 = ((Card)copyCard).RenderInfo;
			hiddenAttack = false;
			renderInfo4.hiddenHealth = false;
			renderInfo3.hiddenAttack = hiddenAttack;
			((Card)copyCard).SetInfo(cardInfo);
			Tween.LocalRotation(__instance.copiedCardEasel, Vector3.zero, 0.2f, 0.02f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
			Tween.LocalRotation(__instance.selectedCardEasel, Vector3.zero, 0.2f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
			Tween.Rotate(((Component)__instance.bottleAnim).transform.parent, new Vector3(0f, -40f, 0f), (Space)1, 0.15f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
			__instance.gooEyesController.ClearLookTarget();
			__instance.JumpBottle(0.3f, 0.15f);
			__instance.gooAnim.SetBool("speaking", true);
			yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("CopyCardPresentResult", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
		}
		__instance.JumpBottle(0.3f, 0.1f);
		__instance.gooAnim.SetBool("speaking", false);
		yield return (object)new WaitForSeconds(0.1f);
		((HighlightedInteractable)__instance.selectionSlot).SetShown(false, true);
		__instance.pile.AddToPile(((Component)__instance.selectionSlot.Card).transform);
		__instance.pile.MoveCardToPile((Card)(object)__instance.selectionSlot.Card, true, 0.1f, 0.7f);
		Tween.Rotation(((Component)__instance.selectionSlot.Card).transform, new Vector3(90f, CustomRandom.RandomBetween(-3f, 3f), 0f), 0.1f, 0.35f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
		yield return (object)new WaitForSeconds(0.2f);
		if (badPainting)
		{
			__instance.pile.AddToPile(((Component)replacementCard).transform);
			__instance.pile.MoveCardToPile((Card)(object)replacementCard, true, 0.1f, 0.7f);
			Tween.Rotation(((Component)replacementCard).transform, new Vector3(90f, CustomRandom.RandomBetween(-3f, 3f), 0f), 0.1f, 0.35f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
		}
		else
		{
			__instance.pile.AddToPile(((Component)copyCard).transform);
			__instance.pile.MoveCardToPile((Card)(object)copyCard, true, 0.1f, 0.7f);
			Tween.Rotation(((Component)copyCard).transform, new Vector3(90f, CustomRandom.RandomBetween(-3f, 3f), 0f), 0.1f, 0.35f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
		}
		yield return (object)new WaitForSeconds(0.75f);
		((MonoBehaviour)__instance).StartCoroutine(__instance.pile.DestroyCards(0.5f));
		__instance.LiftItemAnim(__instance.bottleAnim, "glass_object_up");
		yield return (object)new WaitForSeconds(0.1f);
		__instance.LiftItemAnim(__instance.selectedCardEaselAnim, "wood_object_up");
		__instance.LiftItemAnim(__instance.copiedCardEaselAnim, "");
		yield return (object)new WaitForSeconds(0.25f);
		__instance.confirmStone.SetStoneInactive();
		((Component)__instance.bottleAnim).gameObject.SetActive(false);
		((Component)__instance.selectedCardEasel).gameObject.SetActive(false);
		((Component)__instance.copiedCardEasel).gameObject.SetActive(false);
		if ((Object)(object)Singleton<GameFlowManager>.Instance != (Object)null)
		{
			Singleton<GameFlowManager>.Instance.TransitionToGameState((GameState)1, (NodeData)null);
		}
	}

	private static IEnumerator BadPainting(CopyCardSequencer __instance, SelectableCard card)
	{
		string[] randomBadPaintingText = GetRandomBadPaintingText();
		foreach (string s in randomBadPaintingText)
		{
			yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(s, -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)7, (string[])null, true);
		}
		Tween.Rotate(((Component)__instance.bottleAnim).transform.parent, new Vector3(0f, -40f, 0f), (Space)1, 0.15f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
		Tween.Position(((Component)__instance.selectedCardEasel).transform, ((Component)__instance.selectedCardEasel).transform.position + Vector3.right * 0.75f, 0.2f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
		Tween.Position(((Component)__instance.copiedCardEasel).transform, ((Component)__instance.copiedCardEasel).transform.position + Vector3.left * 0.75f, 0.2f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
		yield return (object)new WaitForSeconds(0.2f);
		((Component)card).transform.localPosition = new Vector3(0.469f, 3.35f, 5.15f);
		((Component)card).transform.localRotation = Quaternion.Euler(-2.19f, 116f, 7f);
		((Component)card).transform.localScale = new Vector3(3.55f, 3.55f, 3.55f);
		((Component)card).gameObject.SetActive(true);
		CreateBadCard(card);
		__instance.gooEyesController.ClearLookTarget();
		__instance.JumpBottle(0.3f, 0.15f);
		__instance.gooAnim.SetBool("speaking", true);
		yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("I'm sorry!", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)7, (string[])null, true);
		yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("You deserve better!", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)7, (string[])null, true);
	}

	private static string[] GetRandomBadPaintingText()
	{
		int index = SeededRandom.Range(0, BadPaintingTexts.Count, Seed++);
		return BadPaintingTexts[index];
	}

	private static void CreateBadCard(SelectableCard card)
	{
		CardInfo randomCardInfo = GetRandomCardInfo();
		((CardCollectionInfo)RunState.Run.playerDeck).AddCard(randomCardInfo);
		SaveManager.SaveToFile(true);
		((Card)card).RenderInfo.hiddenAttack = (((Card)card).RenderInfo.hiddenHealth = false);
		((Card)card).SetInfo(randomCardInfo);
	}

	private static CardInfo GetRandomCardInfo()
	{
		List<CardInfo> list = new List<CardInfo>();
		string[] array = Configs.CardReplacements.Value.Split(new char[1] { ',' });
		string[] array2 = array;
		foreach (string text in array2)
		{
			CardInfo cardByName = CardLoader.GetCardByName(text.Trim());
			if ((Object)(object)cardByName != (Object)null)
			{
				list.Add(cardByName);
			}
		}
		return ListExtensions.GetSeededRandom<CardInfo>(list, Seed++);
	}

	[HarmonyPatch(typeof(CopyCardSequencer), "CreateCloneCard")]
	[HarmonyPrefix]
	private static bool CopyCardSequencer_CreateCloneCard(CopyCardSequencer __instance, CardInfo cardToCopy, ref CardInfo __result)
	{
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Expected O, but got Unknown
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Expected O, but got Unknown
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		CardInfo temporaryCard = cardToCopy.CloneAsTemporaryCard();
		if (!Configs.DisablePaintDecal.Value)
		{
			foreach (CardModificationInfo item2 in temporaryCard.Mods.FindAll((CardModificationInfo x) => !x.nonCopyable))
			{
				if (item2.singletonId != "paint_decal")
				{
					CardModificationInfo item = (CardModificationInfo)item2.Clone();
					temporaryCard.Mods.Add(item);
				}
			}
			CardModificationInfo val = new CardModificationInfo();
			val.singletonId = "paint_decal";
			CopyCardSequencer.paintDecalIndex++;
			if (CopyCardSequencer.paintDecalIndex > 2)
			{
				CopyCardSequencer.paintDecalIndex = 0;
			}
			val.DecalIds.Add("decal_paint_" + (CopyCardSequencer.paintDecalIndex + 1));
			temporaryCard.Mods.Add(val);
		}
		CardModificationInfo val2 = new CardModificationInfo();
		temporaryCard.Mods.Add(val2);
		Seed = SaveManager.SaveFile.GetCurrentRandomSeed();
		List<RandomOptions.WeightOption> allRandomOptions = RandomOptions.GetAllRandomOptions();
		int num;
		if (Configs.SuperMode.Value)
		{
			allRandomOptions.AddRange(from a in RandomOptions.GetAllRandomOptions()
				where a.AllowMultiple
				select a);
			num = SeededRandom.Range(2, Mathf.Max(2, Configs.MaxRandomizations.Value), Seed++);
		}
		else
		{
			num = SeededRandom.Range(1, Mathf.Max(1, Configs.MaxRandomizations.Value), Seed++);
		}
		for (int i = 0; i < num; i++)
		{
			if (allRandomOptions.Count <= 0)
			{
				break;
			}
			List<RandomOptions.WeightOption> list = allRandomOptions.FindAll((RandomOptions.WeightOption a) => a.Condition(temporaryCard));
			list.Sort((RandomOptions.WeightOption a, RandomOptions.WeightOption b) => a.Weight - b.Weight);
			int num2 = list.Sum((RandomOptions.WeightOption a) => a.Weight);
			int num3 = SeededRandom.Range(0, num2, Seed++);
			int num4 = 0;
			for (int j = 0; j < list.Count; j++)
			{
				num4 += list[j].Weight;
				if (num4 > num3)
				{
					list[j].OnChosen(temporaryCard, val2);
					allRandomOptions.Remove(list[j]);
					break;
				}
			}
		}
		int num5 = Mathf.Clamp(Configs.ChanceOfNameChange.Value, 0, 100);
		if (num5 > 0 && SeededRandom.Range(0, 100, Seed++) < num5)
		{
			RandomOptions.OnNameChange(temporaryCard, val2);
		}
		__result = temporaryCard;
		TemporaryCardInfo.SaveTemporaryCard(temporaryCard);
		return false;
	}
}
[HarmonyPatch]
internal class DuplicateMerge_Patches
{
	[HarmonyPatch(typeof(DuplicateMergeSequencer), "GetValidDuplicateCards")]
	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		MethodInfo methodInfo = AccessTools.Method(typeof(DuplicateMerge_Patches), "GetValidCards", (Type[])null, (Type[])null);
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		int num = list.FindIndex((CodeInstruction a) => a.opcode == OpCodes.Stloc_2);
		list.Insert(num - 2, new CodeInstruction(OpCodes.Ldloc_1, (object)null));
		list.Insert(num - 1, new CodeInstruction(OpCodes.Call, (object)methodInfo));
		return list;
	}

	public static void GetValidCards(Dictionary<string, List<CardInfo>> dictionary)
	{
		foreach (CardInfo deck in RunState.DeckList)
		{
			if (((Object)deck).name.Contains("DEATHCARD"))
			{
				continue;
			}
			string templateID = deck.GetTemporaryCardTemplateName();
			if (RunState.DeckList.Count((CardInfo a) => ((Object)a).name == templateID || a.GetTemporaryCardTemplateName() == templateID) > 1)
			{
				if (!dictionary.ContainsKey(templateID))
				{
					dictionary.Add(templateID, new List<CardInfo>());
				}
				List<CardInfo> list = dictionary[templateID];
				if (!list.Contains(deck))
				{
					list.Add(deck);
				}
			}
		}
	}

	[HarmonyPatch(typeof(DuplicateMergeSequencer), "MergeCards")]
	[HarmonyPrefix]
	internal static bool Prefix(DuplicateMergeSequencer __instance, CardInfo card1, CardInfo card2, ref CardInfo __result)
	{
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		bool flag = card1.IsTemporaryCardInfo();
		bool flag2 = card2.IsTemporaryCardInfo();
		if (!flag && !flag2)
		{
			return true;
		}
		CardInfo val = card1.CloneAsTemporaryCard();
		val.baseAttack += card2.baseAttack;
		val.baseHealth += card2.baseHealth;
		val.cost = Mathf.Max(0, val.cost + card2.cost - val.cost);
		val.bonesCost = Mathf.Max(0, val.bonesCost + card2.bonesCost - val.bonesCost);
		val.energyCost = Mathf.Max(0, val.energyCost + card2.energyCost - val.energyCost);
		val.gemsCost = CombineLists(card1.gemsCost, card2.gemsCost);
		val.tribes = CombineLists(card1.tribes, card2.tribes);
		val.traits = CombineLists(card1.traits, card2.traits);
		val.abilities = CombineLists(card1.abilities, card2.abilities);
		CardModificationInfo duplicateMod = DuplicateMergeSequencer.GetDuplicateMod(0, 0);
		int num = 0;
		foreach (CardModificationInfo mod in card1.Mods)
		{
			if (mod != null && mod.fromCardMerge)
			{
				num += mod.abilities.Count;
			}
		}
		foreach (CardModificationInfo mod2 in card2.Mods)
		{
			if (mod2.fromCardMerge)
			{
				duplicateMod.fromCardMerge = true;
			}
			foreach (Ability ability in mod2.abilities)
			{
				if (!card1.HasAbility(ability) && duplicateMod.abilities.Count + num < 4)
				{
					duplicateMod.abilities.Add(ability);
				}
			}
		}
		val.Mods.Add(duplicateMod);
		((CardCollectionInfo)RunState.Run.playerDeck).AddCard(val);
		((CardCollectionInfo)RunState.Run.playerDeck).RemoveCard(card1);
		((CardCollectionInfo)RunState.Run.playerDeck).RemoveCard(card2);
		TemporaryCardInfo.SaveTemporaryCard(val);
		__result = val;
		return false;
	}

	private static List<T> CombineLists<T>(List<T> card1, List<T> card2)
	{
		List<T> list = new List<T>();
		Dictionary<T, int> dictionary = new Dictionary<T, int>();
		foreach (T item in card1)
		{
			if (!dictionary.ContainsKey(item))
			{
				dictionary.Add(item, 0);
			}
			dictionary[item]++;
		}
		Dictionary<T, int> dictionary2 = new Dictionary<T, int>();
		foreach (T item2 in card2)
		{
			if (!dictionary2.ContainsKey(item2))
			{
				dictionary2.Add(item2, 0);
			}
			dictionary2[item2]++;
		}
		foreach (KeyValuePair<T, int> item3 in dictionary2)
		{
			if (dictionary.TryGetValue(item3.Key, out var value))
			{
				dictionary[item3.Key] = Mathf.Max(value, item3.Value);
			}
			else
			{
				dictionary[item3.Key] = item3.Value;
			}
		}
		foreach (KeyValuePair<T, int> item4 in dictionary)
		{
			for (int i = 0; i < item4.Value; i++)
			{
				list.Add(item4.Key);
			}
		}
		return list;
	}
}
public static class RandomOptions
{
	public class WeightOption
	{
		public int Weight;

		public Action<CardInfo, CardModificationInfo> OnChosen;

		public Func<CardInfo, bool> Condition;

		public bool AllowMultiple = true;
	}

	private static char[] vowels = new char[5] { 'a', 'e', 'i', 'o', 'u' };

	private static Dictionary<char, string[]> replacements = new Dictionary<char, string[]>
	{
		{
			'a',
			new string[1] { "o" }
		},
		{
			'b',
			new string[1] { "d" }
		},
		{
			'c',
			new string[1] { "k" }
		},
		{
			'd',
			new string[1] { "b" }
		},
		{
			'e',
			new string[0]
		},
		{
			'f',
			new string[1] { "t" }
		},
		{
			'g',
			new string[1] { "p" }
		},
		{
			'h',
			new string[1] { "m" }
		},
		{
			'i',
			new string[3] { "l", "j", "1" }
		},
		{
			'j',
			new string[3] { "i", "l", "1" }
		},
		{
			'k',
			new string[1] { "c" }
		},
		{
			'l',
			new string[2] { "i", "1" }
		},
		{
			'm',
			new string[1] { "n" }
		},
		{
			'n',
			new string[1] { "m" }
		},
		{
			'o',
			new string[3] { "0", "a", "oo" }
		},
		{
			'p',
			new string[1] { "q" }
		},
		{
			'q',
			new string[1] { "p" }
		},
		{
			'r',
			new string[0]
		},
		{
			's',
			new string[3] { "z", "sh", "st" }
		},
		{
			't',
			new string[3] { "th", "st", "f" }
		},
		{
			'u',
			new string[0]
		},
		{
			'v',
			new string[1] { "w" }
		},
		{
			'w',
			new string[1] { "v" }
		},
		{
			'x',
			new string[0]
		},
		{
			'y',
			new string[0]
		},
		{
			'z',
			new string[2] { "s", "zz" }
		},
		{
			' ',
			new string[1] { "" }
		},
		{
			'0',
			new string[1] { "a" }
		},
		{
			'1',
			new string[3] { "i", "j", "l" }
		}
	};

	public static List<WeightOption> GetAllRandomOptions()
	{
		List<WeightOption> list = new List<WeightOption>();
		list.Add(new WeightOption
		{
			Weight = Configs.ChanceOfSigilChange.Value,
			Condition = (CardInfo c) => c.Abilities.Count > 0,
			OnChosen = OnChangeSigils
		});
		list.Add(new WeightOption
		{
			Weight = Configs.ChanceOfSigilAdd.Value,
			Condition = (CardInfo c) => true,
			OnChosen = OnAddSigils
		});
		list.Add(new WeightOption
		{
			Weight = Configs.ChanceOfAttackChange.Value,
			Condition = (CardInfo c) => c.Attack > 0,
			OnChosen = OnChangeAttack
		});
		list.Add(new WeightOption
		{
			Weight = Configs.ChanceOfHealthChange.Value,
			Condition = (CardInfo c) => c.Health > 1,
			OnChosen = OnChangeHealth
		});
		list.Add(new WeightOption
		{
			Weight = Configs.ChanceOfTribesChange.Value,
			Condition = (CardInfo c) => true,
			OnChosen = OnChangeTribe
		});
		list.Add(new WeightOption
		{
			Weight = Configs.ChanceOfCostChange.Value,
			Condition = (CardInfo c) => c.BloodCost > 0 || c.BonesCost > 0 || c.EnergyCost > 0 || c.GemsCost.Count > 0,
			OnChosen = OnChangeCost
		});
		return list;
	}

	private static void OnChangeSigils(CardInfo cardByName, CardModificationInfo copyMod)
	{
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		Plugin.Log.LogInfo((object)"Change Sigil");
		List<CardModificationInfo> list = cardByName.Mods.FindAll((CardModificationInfo x) => x.abilities.Count > 0);
		List<Ability> abilities = cardByName.abilities;
		List<int> list2 = Enumerable.Range(0, cardByName.abilities.Count).ToList();
		list.Sort((CardModificationInfo a, CardModificationInfo b) => SeededRandom.Bool(CopyCard_Patches.Seed++) ? 1 : (-1));
		list2.Sort((int a, int b) => SeededRandom.Bool(CopyCard_Patches.Seed++) ? 1 : (-1));
		List<Ability> learnedAbilities = AbilitiesUtil.GetLearnedAbilities(false, 0, 5, (AbilityMetaCategory)1);
		learnedAbilities.Sort((Ability a, Ability b) => AbilitiesUtil.GetInfo(a).powerLevel - AbilitiesUtil.GetInfo(b).powerLevel);
		int num = ((!Configs.CanShuffleAllSigils.Value) ? 1 : SeededRandom.Range(1, list.Count + abilities.Count, CopyCard_Patches.Seed++));
		for (int i = 0; i < num; i++)
		{
			int count = list.Count;
			int count2 = list2.Count;
			bool flag = false;
			if (count > 0 && count2 > 0)
			{
				flag = SeededRandom.Range(0, count + count2, CopyCard_Patches.Seed++) < count;
			}
			else if (count > 0)
			{
				flag = true;
			}
			int num2 = 0;
			Ability val = (Ability)93;
			if (Configs.SuperMode.Value && num > 1)
			{
				int num3 = learnedAbilities.Count / num;
				int num4 = i * num3;
				int num5 = (i + 1) * num3;
				num2 = SeededRandom.Range(num4, num5, CopyCard_Patches.Seed++);
			}
			else
			{
				num2 = SeededRandom.Range(0, learnedAbilities.Count, CopyCard_Patches.Seed++);
			}
			val = learnedAbilities[num2];
			learnedAbilities.RemoveAt(num2);
			if (flag)
			{
				int index = SeededRandom.Range(0, list[0].abilities.Count, CopyCard_Patches.Seed++);
				Plugin.Log.LogInfo((object)$"Changing mod {list[0].abilities[index]} to {val}");
				list[0].abilities[index] = val;
				list.RemoveAt(0);
			}
			else
			{
				int index2 = list2[0];
				Plugin.Log.LogInfo((object)$"Changing vanilla {abilities[index2]} to {val}");
				abilities[index2] = val;
				list2.RemoveAt(0);
			}
		}
	}

	private static void OnAddSigils(CardInfo cardByName, CardModificationInfo copyMod)
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		Plugin.Log.LogInfo((object)"Add Sigil");
		int num = ((!Configs.SuperMode.Value) ? 1 : SeededRandom.Range(1, 2, CopyCard_Patches.Seed++));
		List<Ability> learnedAbilities = AbilitiesUtil.GetLearnedAbilities(false, 0, 5, (AbilityMetaCategory)1);
		learnedAbilities.RemoveAll(delegate(Ability a)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo info = AbilitiesUtil.GetInfo(a);
			return ((Object)(object)info == (Object)null || (!info.canStack && cardByName.HasAbility(a))) ? true : false;
		});
		for (int i = 0; i < num; i++)
		{
			Ability seededRandom = ListExtensions.GetSeededRandom<Ability>(learnedAbilities, CopyCard_Patches.Seed++);
			learnedAbilities.Remove(seededRandom);
			cardByName.abilities.Add(seededRandom);
		}
	}

	private static void OnRemoveSigil(CardInfo cardByName, CardModificationInfo copyMod)
	{
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		Plugin.Log.LogInfo((object)"Remove Sigil");
		int num = ((!Configs.SuperMode.Value) ? 1 : SeededRandom.Range(1, 2, CopyCard_Patches.Seed++));
		for (int i = 0; i < num; i++)
		{
			List<CardModificationInfo> list = cardByName.Mods.FindAll((CardModificationInfo x) => x.abilities.Count > 0);
			CardModificationInfo seededRandom = ListExtensions.GetSeededRandom<CardModificationInfo>(list, CopyCard_Patches.Seed++);
			seededRandom.abilities.Remove(ListExtensions.GetSeededRandom<Ability>(seededRandom.abilities, CopyCard_Patches.Seed++));
		}
	}

	private static void OnChangeAttack(CardInfo cardByName, CardModificationInfo copyMod)
	{
		int num = ((!Configs.SuperMode.Value) ? 1 : 2);
		bool flag = SeededRandom.Bool(CopyCard_Patches.Seed++);
		Plugin.Log.LogInfo((object)(flag ? "Increase Attack" : "Decrease Attack"));
		if (flag)
		{
			copyMod.attackAdjustment = num;
		}
		else
		{
			copyMod.attackAdjustment = -Mathf.Min(cardByName.Attack, num);
		}
	}

	private static void OnChangeHealth(CardInfo cardByName, CardModificationInfo copyMod)
	{
		int num = (Configs.SuperMode.Value ? 4 : 2);
		bool flag = SeededRandom.Bool(CopyCard_Patches.Seed++);
		Plugin.Log.LogInfo((object)(flag ? "Increase Health" : "Decrease Health"));
		if (flag)
		{
			copyMod.healthAdjustment = num;
		}
		else
		{
			copyMod.healthAdjustment = -Mathf.Min(cardByName.Health - 1, num);
		}
	}

	private static void OnChangeTribe(CardInfo cardByName, CardModificationInfo copyMod)
	{
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		bool flag = cardByName.tribes.Count <= 0 || SeededRandom.Bool(CopyCard_Patches.Seed++);
		List<Tribe> list = new List<Tribe>();
		list.AddRange(Enum.GetValues(typeof(Tribe)).Cast<Tribe>());
		list.Remove((Tribe)0);
		list.Remove((Tribe)7);
		list.AddRange(TribeManager.NewTribes.Select((TribeInfo a) => a.tribe));
		list.RemoveAll((Tribe a) => cardByName.tribes.Contains(a));
		if (list.Count != 0)
		{
			Tribe seededRandom = ListExtensions.GetSeededRandom<Tribe>(list, CopyCard_Patches.Seed++);
			if (flag)
			{
				Plugin.Log.LogInfo((object)("Add Tribe" + ((object)(Tribe)(ref seededRandom)).ToString()));
				cardByName.tribes.Add(seededRandom);
			}
			else
			{
				int index = SeededRandom.Range(0, cardByName.tribes.Count, CopyCard_Patches.Seed++);
				Plugin.Log.LogInfo((object)$"Change Tribe {cardByName.tribes[index]} to {seededRandom}");
				cardByName.tribes[index] = seededRandom;
			}
		}
	}

	public static void OnNameChange(CardInfo cardByName, CardModificationInfo copyMod)
	{
		Plugin.Log.LogInfo((object)"Change Name");
		int num = 1;
		for (int i = 0; i < num; i++)
		{
			if (cardByName.displayedName.Length <= 2)
			{
				break;
			}
			int num2 = SeededRandom.Range(1, cardByName.displayedName.Length - 1, CopyCard_Patches.Seed++);
			char c = cardByName.displayedName[num2];
			bool flag = char.IsUpper(c);
			char c2 = (flag ? char.ToLowerInvariant(c) : c);
			string[] value;
			if (c2 == cardByName.displayedName[num2 - 1] && SeededRandom.Bool(CopyCard_Patches.Seed++))
			{
				cardByName.displayedName = cardByName.displayedName.Remove(num2, 1);
			}
			else if (replacements.TryGetValue(c2, out value) && value.Length != 0)
			{
				string text = cardByName.displayedName.Substring(0, num2);
				string text2 = cardByName.displayedName.Substring(num2 + 1, cardByName.displayedName.Length - num2 - 1);
				int num3 = SeededRandom.Range(0, value.Length, CopyCard_Patches.Seed++);
				string text3 = value[num3];
				if (flag)
				{
					text3 = text3.ToUpper();
				}
				cardByName.displayedName = text + text3 + text2;
			}
			else if (SeededRandom.Bool(CopyCard_Patches.Seed++))
			{
				cardByName.displayedName = cardByName.displayedName.Remove(num2, 1);
			}
		}
	}

	private static void OnChangeCost(CardInfo cardByName, CardModificationInfo copyMod)
	{
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		Plugin.Log.LogInfo((object)"Change Cost");
		int num = ((!Configs.SuperMode.Value) ? 1 : 2);
		bool flag = SeededRandom.Bool(CopyCard_Patches.Seed++);
		if (cardByName.BloodCost > 0)
		{
			Plugin.Log.LogInfo((object)(flag ? "Increase Blood Cost" : "Decrease Blood Cost"));
			int num2 = num;
			int num3 = Mathf.Max(1, Mathf.Min(num2, cardByName.BloodCost - num2));
			copyMod.bloodCostAdjustment = (flag ? num3 : (-num3));
		}
		else if (cardByName.BonesCost > 0)
		{
			Plugin.Log.LogInfo((object)(flag ? "Increase Bones Cost" : "Decrease Bones Cost"));
			int num4 = 2 * num;
			int num5 = Mathf.Max(1, Mathf.Min(num4, cardByName.BonesCost - num4));
			copyMod.bonesCostAdjustment = (flag ? num4 : (-num5));
		}
		else if (cardByName.EnergyCost > 0)
		{
			Plugin.Log.LogInfo((object)(flag ? "Increase Energy Cost" : "Decrease Energy Cost"));
			int num6 = 2 * num;
			int num7 = Mathf.Max(1, Mathf.Min(num6, cardByName.EnergyCost - num6));
			copyMod.energyCostAdjustment = (flag ? num7 : (-num7));
		}
		else
		{
			if (cardByName.GemsCost == null || cardByName.GemsCost.Count <= 0)
			{
				return;
			}
			if (flag)
			{
				Plugin.Log.LogInfo((object)"Increase Gem Cost");
				List<GemType> list = new List<GemType>();
				foreach (GemType value in Enum.GetValues(typeof(GemType)))
				{
					if (!cardByName.GemsCost.Contains(value))
					{
						list.Add(value);
					}
				}
				int num8 = num;
				copyMod.addGemCost = new List<GemType>();
				for (int i = 0; i < num8; i++)
				{
					if (list.Count <= 0)
					{
						break;
					}
					int index = SeededRandom.Range(0, list.Count, CopyCard_Patches.Seed++);
					copyMod.addGemCost.Add(list[index]);
					list.RemoveAt(index);
				}
				return;
			}
			Plugin.Log.LogInfo((object)"Decrease Gem Cost");
			List<GemType> gemsCost = cardByName.GemsCost;
			int num9 = num;
			for (int j = 0; j < num9; j++)
			{
				if (gemsCost.Count <= 0)
				{
					break;
				}
				int index2 = SeededRandom.Range(0, gemsCost.Count, CopyCard_Patches.Seed++);
				GemType type = gemsCost[index2];
				CardModificationInfo val = cardByName.Mods.Where((CardModificationInfo x) => x.addGemCost != null && x.addGemCost.Contains(type)).FirstOrDefault();
				if (val != null)
				{
					val.addGemCost.Remove(type);
				}
				else if (cardByName.gemsCost.Contains(type))
				{
					cardByName.gemsCost.Remove(type);
				}
				else
				{
					Plugin.Log.LogError((object)$"Could not find gem type to remove! {((Object)cardByName).name} => {type}");
				}
				gemsCost = cardByName.GemsCost;
			}
		}
	}
}
[HarmonyPatch]
public static class TemporaryCardInfo
{
	public static bool IsTemporaryCardInfo(this CardInfo cardInfo)
	{
		return cardInfo.Mods != null && cardInfo.Mods.Any((CardModificationInfo a) => !string.IsNullOrEmpty(a.singletonId) && a.singletonId.StartsWith("temporary_card"));
	}

	public static bool TryGetTemporaryCardTemplateName(this CardInfo cardInfo, out string id)
	{
		id = cardInfo.GetTemporaryCardTemplateName();
		return id != null;
	}

	public static string GetTemporaryCardTemplateName(this CardInfo cardInfo)
	{
		CardModificationInfo val = cardInfo.Mods.Find((CardModificationInfo a) => !string.IsNullOrEmpty(a.singletonId) && a.singletonId.StartsWith("temporary_card"));
		return (val != null) ? val.singletonId.Substring("temporary_card|".Length) : ((Object)cardInfo).name;
	}

	public static CardInfo CloneAsTemporaryCard(this CardInfo templateCardInfo)
	{
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Expected O, but got Unknown
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Expected O, but got Unknown
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Expected O, but got Unknown
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_0394: Expected O, but got Unknown
		int num = ModdedSaveManager.RunState.GetValueAsInt("jamesgames.inscryption.goobertextended", "TotalTempCards") + 1;
		ModdedSaveManager.RunState.SetValue("jamesgames.inscryption.goobertextended", "TotalTempCards", (object)num);
		CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
		((Object)val).name = $"{((Object)templateCardInfo).name}_temp_{num}";
		val.abilities = new List<Ability>(templateCardInfo.abilities);
		val.specialAbilities = new List<SpecialTriggeredAbility>(templateCardInfo.specialAbilities);
		val.tribes = new List<Tribe>(templateCardInfo.tribes);
		val.gemsCost = new List<GemType>(templateCardInfo.gemsCost);
		val.appearanceBehaviour = new List<Appearance>(templateCardInfo.appearanceBehaviour);
		val.description = templateCardInfo.description;
		val.baseAttack = templateCardInfo.baseAttack;
		val.baseHealth = templateCardInfo.baseHealth;
		val.cost = templateCardInfo.cost;
		val.bonesCost = templateCardInfo.bonesCost;
		val.energyCost = templateCardInfo.energyCost;
		val.boon = templateCardInfo.boon;
		val.onePerDeck = templateCardInfo.onePerDeck;
		val.temple = templateCardInfo.temple;
		val.displayedName = templateCardInfo.displayedName;
		val.displayedNameLocId = templateCardInfo.displayedNameLocId;
		val.hideAttackAndHealth = templateCardInfo.hideAttackAndHealth;
		val.specialStatIcon = templateCardInfo.specialStatIcon;
		val.titleGraphic = templateCardInfo.titleGraphic;
		val.portraitTex = templateCardInfo.portraitTex;
		val.alternatePortrait = templateCardInfo.alternatePortrait;
		val.holoPortraitPrefab = templateCardInfo.holoPortraitPrefab;
		val.animatedPortrait = templateCardInfo.animatedPortrait;
		val.pixelPortrait = templateCardInfo.pixelPortrait;
		val.defaultEvolutionName = templateCardInfo.defaultEvolutionName;
		val.flipPortraitForStrafe = templateCardInfo.flipPortraitForStrafe;
		val.cardComplexity = templateCardInfo.cardComplexity;
		val.decals = new List<Texture>(templateCardInfo.decals);
		val.metaCategories = new List<CardMetaCategory>(templateCardInfo.metaCategories);
		val.traits = new List<Trait>(templateCardInfo.traits);
		val.ascensionAbilities = new List<Ability>(templateCardInfo.ascensionAbilities);
		val.temporaryDecals = new List<Texture>(templateCardInfo.temporaryDecals);
		val.get_decals = new List<Texture>(templateCardInfo.get_decals);
		foreach (KeyValuePair<string, string> item in CardManager.GetCardExtensionTable(templateCardInfo))
		{
			CardExtensions.SetExtendedProperty(val, item.Key, (object)item.Value);
		}
		if (val.evolveParams != null)
		{
			val.evolveParams = new EvolveParams();
			val.evolveParams.turnsToEvolve = templateCardInfo.evolveParams.turnsToEvolve;
			val.evolveParams.evolution = templateCardInfo.evolveParams.evolution;
		}
		if (val.tailParams != null)
		{
			val.tailParams = new TailParams();
			val.tailParams.tail = templateCardInfo.tailParams.tail;
			val.tailParams.tailLostPortrait = templateCardInfo.tailParams.tailLostPortrait;
		}
		if (val.iceCubeParams != null)
		{
			val.iceCubeParams = new IceCubeParams();
			val.iceCubeParams.creatureWithin = templateCardInfo.iceCubeParams.creatureWithin;
		}
		val.Mods = new List<CardModificationInfo>(templateCardInfo.Mods.Select((CardModificationInfo a) => a.Clone()).Cast<CardModificationInfo>());
		if (!templateCardInfo.IsTemporaryCardInfo())
		{
			val.Mods.Add(new CardModificationInfo
			{
				singletonId = "temporary_card|" + ((Object)templateCardInfo).name
			});
		}
		return val;
	}

	public static void SaveTemporaryCard(CardInfo cardInfo)
	{
		string text = JsonUtility.ToJson((object)cardInfo);
		ModdedSaveManager.RunState.SetValue("jamesgames.inscryption.goobertextended", ((Object)cardInfo).name, (object)text);
	}

	public static CardInfo GetTemporaryCard(string cardInfoName)
	{
		string value = ModdedSaveManager.RunState.GetValue("jamesgames.inscryption.goobertextended", cardInfoName);
		if (!string.IsNullOrEmpty(value))
		{
			CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
			JsonUtility.FromJsonOverwrite(value, (object)val);
			((Object)val).name = cardInfoName;
			return val;
		}
		return null;
	}

	[HarmonyPatch(typeof(CardManager), "LogCardInfo", new Type[]
	{
		typeof(CardInfo),
		typeof(string)
	})]
	[HarmonyPrefix]
	public static bool GetTemporaryCard(ref CardInfo info, ref string cardInfoName)
	{
		if ((Object)(object)info == (Object)null)
		{
			info = GetTemporaryCard(cardInfoName);
		}
		return true;
	}
}
public static class Utils
{
	public static Texture2D CopyTexture(Texture2D texture)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		if (!((Texture)texture).isReadable)
		{
			RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1);
			Graphics.Blit((Texture)(object)texture, temporary);
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).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);
			texture = val;
		}
		return texture;
	}
}
namespace StarCraftCore;

public static class PluginInfo
{
	public const string PLUGIN_GUID = "GoobertExtended";

	public const string PLUGIN_NAME = "GoobertExtended";

	public const string PLUGIN_VERSION = "1.0.0";
}