Decompiled source of My Little Pony FIM Card Pack v3.0.0

PonyLib.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Logging;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionAPI.Dialogue;
using InscryptionAPI.Helpers;
using InscryptionAPI.Sound;
using JetBrains.Annotations;
using PonyLib.CardsHelpers;
using Sirenix.Utilities;
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("Arina Orlova (StillRinny)")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Arina Orlova (StillRinny)")]
[assembly: AssemblyDescription("A Library for Inscryption MLP mods")]
[assembly: AssemblyFileVersion("0.0.1")]
[assembly: AssemblyInformationalVersion("0.0.12+7e191d5749733e751d43d6991ac677f8dd69ed44")]
[assembly: AssemblyProduct("PonyLib")]
[assembly: AssemblyTitle("PonyLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.12.0")]
[module: UnverifiableCode]
namespace PonyLib
{
	[BepInPlugin("PonyLib-S", "Pony Library", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Pony Library");

		internal static ManualLogSource Log { get; set; }

		public void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "PonyLib-S";

		public const string PLUGIN_NAME = "Pony Library";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace PonyLib.Patches
{
	[HarmonyPatch]
	public static class CardMergeSequencerPatch
	{
		[HarmonyTranspiler]
		[HarmonyPatch(typeof(CardMergeSequencer), "GetValidCardsForSacrifice")]
		public static IEnumerable<CodeInstruction> CardMergeSequencer_GetValidCardsForSacrifice(IEnumerable<CodeInstruction> instructions)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int i;
			for (i = 24; !(list[i - 1].opcode == OpCodes.Ldloc_1) || !(list[i].operand.ToString() == "System.Predicate`1[DiskCardGame.CardInfo] <>9__11_1"); i++)
			{
			}
			MethodInfo methodInfo = AccessTools.Method(typeof(CardMergeSequencerPatch), "RemoveNoneMergeable", new Type[1] { typeof(List<CardInfo>) }, (Type[])null);
			list.Insert(i, new CodeInstruction(OpCodes.Call, (object)methodInfo));
			i++;
			do
			{
				list.RemoveAt(i);
			}
			while (list[i + 1].opcode != OpCodes.Ldloc_0);
			return list;
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(CardMergeSequencer), "SacrificeOffersNewAbility")]
		public static IEnumerable<CodeInstruction> CardMergeSequencer_SacrificeOffersNewAbility(IEnumerable<CodeInstruction> instructions)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			MethodInfo methodInfo = AccessTools.Method(typeof(CardMergeSequencerPatch), "ExtSacrificeOffersNewAbility", new Type[2]
			{
				typeof(CardInfo),
				typeof(CardInfo)
			}, (Type[])null);
			list.Clear();
			list.Add(new CodeInstruction(OpCodes.Ldarg_1, (object)null));
			list.Add(new CodeInstruction(OpCodes.Ldarg_2, (object)null));
			list.Add(new CodeInstruction(OpCodes.Call, (object)methodInfo));
			list.Add(new CodeInstruction(OpCodes.Ret, (object)null));
			return list;
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(CardMergeSequencer), "ModifyHostCard")]
		public static IEnumerable<CodeInstruction> CardMergeSequencer_ModifyHostCard(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int i;
			for (i = 1; !(list[i].opcode == OpCodes.Newobj) || !(list[i].operand.ToString() == "Void .ctor(CardInfo)"); i++)
			{
			}
			MethodInfo methodInfo = AccessTools.Method(typeof(CardMergeSequencerPatch), "RemoveNonMergeable", new Type[1] { typeof(CardModificationInfo) }, (Type[])null);
			list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)methodInfo));
			return list;
		}

		private static List<CardInfo> RemoveNoneMergeable(this List<CardInfo> sac)
		{
			sac.RemoveAll((CardInfo c) => !c.Abilities.Exists((Ability a) => a.IsMergeable()));
			return sac;
		}

		private static bool ExtSacrificeOffersNewAbility(CardInfo host, CardInfo sac)
		{
			return sac.Abilities.Exists((Ability a) => !host.HasAbility(a) && a.IsMergeable());
		}

		private static CardModificationInfo RemoveNonMergeable(CardModificationInfo mod)
		{
			mod.abilities.RemoveAll((Ability a) => !a.IsMergeable());
			return mod;
		}
	}
}
namespace PonyLib.GameHelpers
{
	public abstract class AudioTools
	{
		private static readonly Dictionary<string, Dictionary<string, AudioClip>> PreloadedAudio = new Dictionary<string, Dictionary<string, AudioClip>>();

		public static void StoreAudioClip(string GUID, string name, AudioClip clip)
		{
			if (PreloadedAudio.TryGetValue(GUID, out var value))
			{
				value[name] = clip;
				return;
			}
			PreloadedAudio.Add(GUID, value = new Dictionary<string, AudioClip>());
			value.Add(name, clip);
		}

		public static AudioClip GetAudioClip(string GUID, string name)
		{
			AudioClip value2;
			if (PreloadedAudio.TryGetValue(GUID, out var value))
			{
				return value.TryGetValue(name, out value2) ? value2 : null;
			}
			Plugin.Log.LogError((object)("[GetAudioClip] Could not find Audio Clip for GUID: " + GUID + ")]"));
			return null;
		}

		public static void PlayAudioSingle(AudioClip clip, float volume = 0.5f)
		{
			PlayAudio(clip, volume, loop: false);
		}

		public static void PlayAudioSingle(string filePath, float volume = 0.5f)
		{
			AudioClip clip = SoundManager.LoadAudioClip("PonyLib-S", filePath);
			PlayAudio(clip, volume, loop: false);
		}

		public static AudioSource PlayAudioLooped(AudioClip clip, float volume = 0.5f)
		{
			return PlayAudio(clip, volume, loop: true);
		}

		public static AudioSource PlayAudioLooped(string filePath, float volume = 0.5f)
		{
			AudioClip clip = SoundManager.LoadAudioClip("PonyLib-S", filePath);
			return PlayAudio(clip, volume, loop: true);
		}

		private static AudioSource PlayAudio(AudioClip clip, float volume, bool loop)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			AudioSource val = InstantiateAudioObject(clip, Vector3.zero, volume, loop);
			val.spatialBlend = 0f;
			return val;
		}

		public static AudioSource InstantiateAudioObject(AudioClip clip, Vector3 pos, float volume, bool looping, bool autoplay = true)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Audio_" + ((Object)clip).name);
			val.transform.position = pos;
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.clip = clip;
			val2.outputAudioMixerGroup = AudioController.Instance.GetMixerGroup((MixerGroup)0, true);
			val2.volume = volume;
			val2.spatialBlend = 0.75f;
			if (autoplay)
			{
				val2.Play();
			}
			if (looping)
			{
				val2.loop = true;
			}
			else
			{
				Object.Destroy((Object)(object)val, clip.length * 3f);
			}
			return val2;
		}
	}
	public static class ERTools
	{
		internal static Texture2D LoadTexture(string path, byte[] receivedBytes = null)
		{
			return LoadTexture(path, null, receivedBytes);
		}

		public static Texture2D LoadTexture(string path, Assembly baseAssembly, byte[] receivedBytes = null)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			if (receivedBytes == null)
			{
				receivedBytes = ExtractEmbeddedResource(path, baseAssembly);
			}
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, receivedBytes);
			((Texture)val).filterMode = (FilterMode)0;
			return val;
		}

		internal static byte[] ExtractEmbeddedResource(string filePath)
		{
			return ExtractEmbeddedResource(filePath, null);
		}

		public static byte[] ExtractEmbeddedResource(string filePath, Assembly baseAssembly)
		{
			filePath = filePath.Replace("/", ".");
			filePath = filePath.Replace("\\", ".");
			if (baseAssembly == null)
			{
				baseAssembly = Assembly.GetExecutingAssembly();
			}
			using Stream stream = baseAssembly.GetManifestResourceStream(filePath);
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			return array;
		}
	}
	public class PonyDialogueData
	{
		public string Name { get; set; }

		public List<CustomLine> MainLines { get; set; }

		public List<List<CustomLine>> RepeatLines { get; set; } = null;

		public MaxRepeatsBehaviour AfterMaxRepeats { get; set; } = (MaxRepeatsBehaviour)0;

		public Speaker DefaultSpeaker { get; set; } = (Speaker)0;
	}
	public static class DialogueHelpers
	{
		public static void CreateDialogueEvent(this PonyDialogueData p, string GUID = "PonyLib-S")
		{
			//IL_006e: 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)
			try
			{
				if (StringExtensions.IsNullOrWhitespace(GUID))
				{
					throw new ArgumentException("GUID cannot be null or whitespace!", "GUID");
				}
				if (StringExtensions.IsNullOrWhitespace(p.Name))
				{
					throw new ArgumentException("Name field cannot be null or whitespace!", "PonyDialogueData");
				}
				if (LinqExtensions.IsNullOrEmpty<CustomLine>((IList<CustomLine>)p.MainLines))
				{
					throw new ArgumentException("MainLines field cannot be null or empty list!", "PonyDialogueData");
				}
				DialogueEvent val = DialogueManager.GenerateEvent(GUID, p.Name, p.MainLines, p.RepeatLines, p.AfterMaxRepeats, p.DefaultSpeaker);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)string.Format("[{0}] Failed to register \"{1}\" Dialogue Event! Exception message:\n{2}", "CreateDialogueEvent", "p", arg));
			}
		}
	}
}
namespace PonyLib.CardsHelpers
{
	public static class CardDuplicator
	{
		public static CardInfo MakeChangedCopy(this CardInfo sourceInfo, PonyCardData args)
		{
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Invalid comparison between Unknown and I4
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Expected O, but got Unknown
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Invalid comparison between Unknown and I4
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			CardInfo val = ScriptableObject.CreateInstance<CardInfo>();
			CardExtensions.SetName(val, (!string.IsNullOrEmpty(args.CardName)) ? args.CardName : ((Object)sourceInfo).name, (string)null);
			CardExtensions.SetBasic(val, (!string.IsNullOrEmpty(args.DisplayedName)) ? args.DisplayedName : sourceInfo.DisplayedNameLocalized, (args.Attack != -1) ? args.Attack : sourceInfo.Attack, (args.Health != -1) ? args.Health : sourceInfo.Health, (!string.IsNullOrEmpty(args.Description)) ? args.Description : sourceInfo.description);
			CardExtensions.SetCost(val, (int?)(args.BloodCost ?? sourceInfo.BloodCost), (int?)(args.BonesCost ?? sourceInfo.BonesCost), (int?)(args.EnergyCost ?? sourceInfo.EnergyCost), (List<GemType>)null);
			CardExtensions.SetCardComplexity(val, ((int)args.CardComplexity != 1) ? args.CardComplexity : sourceInfo.cardComplexity);
			CardExtensions.SetPortraitAndEmission(val, (args.PathToPortrait != null) ? GetSprite(args.PathToPortrait) : sourceInfo.portraitTex, (args.PathToEmission != null) ? GetSprite(args.PathToEmission) : CardExtensions.GetEmissivePortrait(sourceInfo));
			val.onePerDeck = ((!args.OnePerDeck) ? args.OnePerDeck : sourceInfo.onePerDeck);
			if (!string.IsNullOrEmpty(args.PathToAltPortrait))
			{
				CardExtensions.SetAltPortrait(val, args.PathToAltPortrait);
			}
			else if ((Object)(object)sourceInfo.alternatePortrait != (Object)null)
			{
				val.alternatePortrait = sourceInfo.alternatePortrait;
			}
			if (!string.IsNullOrEmpty(args.PathToAltEmission))
			{
				CardExtensions.SetEmissiveAltPortrait(val, args.PathToAltEmission);
			}
			else if ((Object)(object)CardExtensions.GetEmissiveAltPortrait(sourceInfo) != (Object)null)
			{
				CardExtensions.SetEmissiveAltPortrait(val, CardExtensions.GetEmissiveAltPortrait(sourceInfo));
			}
			if (!string.IsNullOrEmpty(args.BrokenShieldPortrait))
			{
				CardExtensions.SetBrokenShieldPortrait(val, args.BrokenShieldPortrait);
			}
			else if ((Object)(object)CardManager.BrokenShieldPortrait(sourceInfo) != (Object)null)
			{
				CardExtensions.SetBrokenShieldPortrait(val, CardManager.BrokenShieldPortrait(sourceInfo));
			}
			if (!string.IsNullOrEmpty(args.PathToPixelPortrait))
			{
				CardExtensions.SetPixelPortrait(val, args.PathToPixelPortrait);
			}
			else if ((Object)(object)sourceInfo.pixelPortrait != (Object)null)
			{
				val.pixelPortrait = sourceInfo.pixelPortrait;
			}
			CardExtensions.AddMetaCategories(val, args.MetaCategories ?? sourceInfo.metaCategories.ToArray());
			CardExtensions.AddAbilities(val, args.Abilities ?? sourceInfo.DefaultAbilities.ToArray());
			CardExtensions.AddSpecialAbilities(val, args.SpecialAbilities ?? sourceInfo.SpecialAbilities.ToArray());
			val.Mods = new List<CardModificationInfo>(args.Mods ?? sourceInfo.Mods.ToArray());
			val.tribes = new List<Tribe>(args.Tribes ?? sourceInfo.tribes.ToArray());
			val.traits = new List<Trait>(args.Traits ?? sourceInfo.traits.ToArray());
			val.defaultEvolutionName = args.DefaultEvolutionName ?? sourceInfo.defaultEvolutionName;
			if (!string.IsNullOrEmpty(args.EvolveToName))
			{
				CardExtensions.SetEvolve(val, args.EvolveToName, args.TurnsToEvolve ?? 1, (IEnumerable<CardModificationInfo>)null);
			}
			else if ((Object)(object)args.EvolveCardInfo != (Object)null)
			{
				CardExtensions.SetEvolve(val, args.EvolveCardInfo, args.TurnsToEvolve ?? 1, (IEnumerable<CardModificationInfo>)null);
			}
			else if ((Object)(object)sourceInfo.evolveParams?.evolution != (Object)null)
			{
				CardExtensions.SetEvolve(val, sourceInfo.evolveParams.evolution, args.TurnsToEvolve ?? 1, (IEnumerable<CardModificationInfo>)null);
			}
			if (!string.IsNullOrEmpty(args.TailLostPortrait))
			{
				CardExtensions.SetLostTailPortrait(val, args.TailLostPortrait);
			}
			else if ((Object)(object)sourceInfo.tailParams?.tailLostPortrait != (Object)null)
			{
				val.tailParams.tailLostPortrait = sourceInfo.tailParams.tailLostPortrait;
			}
			if (!string.IsNullOrEmpty(args.IceCubeName))
			{
				CardExtensions.SetIceCube(val, args.IceCubeName, (IEnumerable<CardModificationInfo>)args.IceCubeMods);
			}
			else if ((Object)(object)args.IceCubeCreatureWithin != (Object)null)
			{
				CardExtensions.SetIceCube(val, args.IceCubeCreatureWithin, (IEnumerable<CardModificationInfo>)args.IceCubeMods);
			}
			else if ((Object)(object)sourceInfo.iceCubeParams?.creatureWithin != (Object)null)
			{
				CardExtensions.SetIceCube(val, sourceInfo.iceCubeParams.creatureWithin, (IEnumerable<CardModificationInfo>)args.IceCubeMods);
			}
			else
			{
				val.iceCubeParams = new IceCubeParams();
			}
			val.appearanceBehaviour = new List<Appearance>((args.Appearances != null) ? args.Appearances.ToList() : sourceInfo.appearanceBehaviour);
			if (args.SpecialStatIcon != sourceInfo.SpecialStatIcon && (int)args.SpecialStatIcon > 0)
			{
				CardExtensions.SetStatIcon(val, args.SpecialStatIcon);
			}
			CardExtensions.SetHideStats(val, args.IsHiddenStats);
			if (args.ExtendedProperties != null)
			{
				foreach (KeyValuePair<string, object> extendedProperty in args.ExtendedProperties)
				{
					CardExtensions.SetExtendedProperty(val, extendedProperty.Key, extendedProperty.Value);
				}
			}
			else
			{
				foreach (KeyValuePair<string, string> item in CardManager.GetCardExtensionTable(sourceInfo))
				{
					CardExtensions.SetExtendedProperty(val, item.Key, (object)item.Value);
				}
			}
			return val;
		}

		public static Sprite GetSprite(string pathToArt)
		{
			return TextureHelper.ConvertTexture(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0), (SpriteType)0, (FilterMode)0);
		}
	}
	public static class CardTools
	{
		public static void UpdateAbilities(this PlayableCard card)
		{
			card.TriggerHandler.UpdateAbilities(CardExtensions.AllAbilities(card, true));
		}

		public static void UpdateAbilities(this PlayableCard card, List<Ability> triggeredAbilities)
		{
			card.TriggerHandler.UpdateAbilities(triggeredAbilities);
		}

		public static void UpdateAbilities(this CardTriggerHandler handler, List<Ability> triggeredAbilities)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			handler.RemoveEntriesAbsentFromList<Ability, AbilityBehaviour>(handler.triggeredAbilities, triggeredAbilities);
			foreach (Ability triggeredAbility in triggeredAbilities)
			{
				handler.AddAbility(triggeredAbility);
			}
		}

		public static void RemoveAbility(this CardTriggerHandler handler, SpecialTriggeredAbility ability)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			List<Tuple<SpecialTriggeredAbility, SpecialCardBehaviour>> specialAbilities = handler.specialAbilities;
			Tuple<SpecialTriggeredAbility, SpecialCardBehaviour> tuple = specialAbilities.Find((Tuple<SpecialTriggeredAbility, SpecialCardBehaviour> x) => x.Item1 == ability);
			if (tuple != null)
			{
				Object.Destroy((Object)(object)tuple.Item2);
				specialAbilities.Remove(tuple);
			}
		}

		public unsafe static void ReloadAbility(this CardTriggerHandler handler, Ability ability)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			List<Tuple<Ability, AbilityBehaviour>> triggeredAbilities = handler.triggeredAbilities;
			Tuple<Ability, AbilityBehaviour> tuple = triggeredAbilities.Find((Tuple<Ability, AbilityBehaviour> x) => x.Item1 == ability);
			if (tuple != null)
			{
				Object.Destroy((Object)(object)tuple.Item2);
				triggeredAbilities.Remove(tuple);
			}
			AbilityBehaviour item = CardTriggerHandler.AddReceiverToGameObject<AbilityBehaviour>(((object)(*(Ability*)(&ability))/*cast due to .constrained prefix*/).ToString(), ((Component)handler).gameObject);
			triggeredAbilities.Add(new Tuple<Ability, AbilityBehaviour>(ability, item));
		}

		public unsafe static void ReloadAbility(this CardTriggerHandler handler, SpecialTriggeredAbility ability)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			List<Tuple<SpecialTriggeredAbility, SpecialCardBehaviour>> specialAbilities = handler.specialAbilities;
			Tuple<SpecialTriggeredAbility, SpecialCardBehaviour> tuple = specialAbilities.Find((Tuple<SpecialTriggeredAbility, SpecialCardBehaviour> x) => x.Item1 == ability);
			if (tuple != null)
			{
				Object.Destroy((Object)(object)tuple.Item2);
				specialAbilities.Remove(tuple);
			}
			SpecialCardBehaviour item = CardTriggerHandler.AddReceiverToGameObject<SpecialCardBehaviour>(((object)(*(SpecialTriggeredAbility*)(&ability))/*cast due to .constrained prefix*/).ToString(), ((Component)handler).gameObject);
			specialAbilities.Add(new Tuple<SpecialTriggeredAbility, SpecialCardBehaviour>(ability, item));
		}

		public static void ChangeAbilityBehaviour(this CardTriggerHandler handler, Ability ability, Type behaviour)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			List<Tuple<Ability, AbilityBehaviour>> triggeredAbilities = handler.triggeredAbilities;
			Tuple<Ability, AbilityBehaviour> tuple = triggeredAbilities.Find((Tuple<Ability, AbilityBehaviour> x) => x.Item1 == ability);
			if (tuple != null)
			{
				Object.Destroy((Object)(object)tuple.Item2);
				triggeredAbilities.Remove(tuple);
			}
			GameObject gameObject = ((Component)handler).gameObject;
			Component component = gameObject.GetComponent(behaviour);
			TriggerReceiver val = (TriggerReceiver)(object)((component is TriggerReceiver) ? component : null);
			if ((Object)(object)val == (Object)null)
			{
				Component obj = gameObject.AddComponent(behaviour);
				val = (TriggerReceiver)(object)((obj is TriggerReceiver) ? obj : null);
			}
			AbilityBehaviour item = (AbilityBehaviour)(object)((val is AbilityBehaviour) ? val : null);
			triggeredAbilities.Add(new Tuple<Ability, AbilityBehaviour>(ability, item));
		}

		public static void RemoveTemporaryMod(this PlayableCard card, string singletonID, bool updateDisplay = true)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			if (Utility.IsNullOrWhiteSpace(singletonID))
			{
				return;
			}
			CardModificationInfo val = card.TemporaryMods.Find((CardModificationInfo m) => m.singletonId != null && m.singletonId == singletonID);
			if (val == null)
			{
				return;
			}
			card.temporaryMods.Remove(val);
			foreach (Ability ability in val.abilities)
			{
				card.TriggerHandler.RemoveAbility(ability);
			}
			foreach (SpecialTriggeredAbility specialAbility in val.specialAbilities)
			{
				card.TriggerHandler.RemoveAbility((Ability)specialAbility);
			}
			if (updateDisplay)
			{
				card.OnStatsChanged();
			}
		}
	}
	public static class ExtSeededRandom
	{
		public static float Range(float min, float max, int seed)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			State state = Random.state;
			Random.InitState(seed);
			float result = Random.Range(min, max);
			Random.state = state;
			return result;
		}
	}
	public static class AbilityExtensions
	{
		public static void SetNotMergeable(this AbilityInfo abilityInfo, bool isNotMergeable = true)
		{
			AbilityExtensions.SetExtendedProperty(abilityInfo, "NotAllowedForMerging", (object)isNotMergeable);
		}

		public static bool GetNotMergeable(this AbilityInfo abilityInfo)
		{
			return AbilityExtensions.GetExtendedPropertyAsBool(abilityInfo, "NotAllowedForMerging") == true;
		}

		public static bool IsMergeable(this Ability ability)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return !AbilityExtensions.AbilityByID((IEnumerable<AbilityInfo>)AbilityManager.AllAbilityInfos, ability).GetNotMergeable();
		}
	}
	public class PonyCardData
	{
		[CanBeNull]
		public int? TurnsToEvolve = null;

		public string CardName { get; set; }

		public string DisplayedName { get; set; } = null;

		public string Description { get; set; }

		public int Health { get; set; } = -1;

		public int Attack { get; set; } = -1;

		public int? BloodCost { get; set; } = null;

		public int? BonesCost { get; set; } = null;

		public int? EnergyCost { get; set; } = null;

		public CardComplexity CardComplexity { get; set; } = (CardComplexity)1;

		public Sprite PortraitSprite { get; set; } = null;

		public string PathToPortrait { get; set; } = null;

		public Sprite EmissionSprite { get; set; } = null;

		public string PathToEmission { get; set; } = null;

		public string PathToAltPortrait { get; set; } = null;

		public string PathToAltEmission { get; set; } = null;

		public string BrokenShieldPortrait { get; set; } = null;

		public string PathToPixelPortrait { get; set; } = null;

		[CanBeNull]
		public CardMetaCategory[] MetaCategories { get; set; } = null;

		public bool OnePerDeck { get; set; } = false;

		[CanBeNull]
		public Ability[] Abilities { get; set; } = null;

		[CanBeNull]
		public SpecialTriggeredAbility[] SpecialAbilities { get; set; } = null;

		[CanBeNull]
		public Ability[] AscensionAbilities { get; set; } = null;

		[CanBeNull]
		public CardModificationInfo[] Mods { get; set; } = null;

		[CanBeNull]
		public Tribe[] Tribes { get; set; } = null;

		[CanBeNull]
		public Trait[] Traits { get; set; } = null;

		[CanBeNull]
		public string EvolveToName { get; set; } = null;

		[CanBeNull]
		public CardInfo EvolveCardInfo { get; set; } = null;

		[CanBeNull]
		public PonyCardData EvolvePonyData { get; set; } = null;

		public string DefaultEvolutionName { get; set; } = null;

		[CanBeNull]
		public string TailName { get; set; } = null;

		[CanBeNull]
		public CardInfo TailCardInfo { get; set; } = null;

		[CanBeNull]
		public PonyCardData TailPonyData { get; set; } = null;

		[CanBeNull]
		public List<CardModificationInfo> TailMods { get; set; } = null;

		[CanBeNull]
		public string TailLostPortrait { get; set; } = null;

		[CanBeNull]
		public string IceCubeName { get; set; } = null;

		[CanBeNull]
		public CardInfo IceCubeCreatureWithin { get; set; } = null;

		[CanBeNull]
		public List<CardModificationInfo> IceCubeMods { get; set; } = null;

		[CanBeNull]
		public Appearance[] Appearances { get; set; } = null;

		public SpecialStatIcon SpecialStatIcon { get; set; } = (SpecialStatIcon)0;

		public bool IsHiddenStats { get; set; } = false;

		[CanBeNull]
		public Dictionary<string, object> ExtendedProperties { get; set; } = null;
	}
}

MLPCPCK.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionAPI.Dialogue;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
using InscryptionAPI.RuleBook;
using InscryptionAPI.Sound;
using InscryptionAPI.Triggers;
using MLPCPCK.Abilities;
using MLPCPCK.Helpers;
using MLPCPCK.Resources;
using MLPCPCK.SpecialAbilities;
using PonyLib.CardsHelpers;
using PonyLib.GameHelpers;
using Sirenix.Utilities;
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("MLPCPCK")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+284e1ffbc2e18bb5b863e7fe58a321795fb6f4c7")]
[assembly: AssemblyProduct("MLPCPCK")]
[assembly: AssemblyTitle("MLPCPCK")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MLPCPCK
{
	[BepInPlugin("MLPCPCK-U", "MLP:FIM CardPack", "0.6.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("MLP:FIM CardPack");

		internal static ManualLogSource Log { get; set; }

		public void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			Log.LogInfo((object)$"{AddDialogs()} Event Dialogues registered");
			PreloadAudio();
			AssetBundleHelper.TryGet<GameObject>(ERTools.ExtractEmbeddedResource("MLPCPCK.Resources.Models.HardReset_Button", Assembly.GetExecutingAssembly()), "HardResetButton", ref HardReset.ResetItemPrefab);
			Log.LogInfo((object)$"{RegisterAbilities()} Abilities registered");
		}

		private static int AddDialogs()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Type type = (from t in executingAssembly.GetTypes()
				where t.Namespace == "MLPCPCK.Resources"
				select t).ToList().Find((Type t) => t.Name == "DialogueSamples");
			FieldInfo[] fields = type.GetFields();
			int num = 0;
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				PonyDialogueData val = (PonyDialogueData)fieldInfo.GetValue(null);
				if (val != null)
				{
					num++;
					DialogueHelpers.CreateDialogueEvent(val, "MLPCPCK-U");
				}
			}
			return num;
		}

		private static void PreloadAudio()
		{
			AudioTools.StoreAudioClip("MLPCPCK-U", "HardReset.Clock", SoundManager.LoadAudioClip("HardReset_Clock.ogg"));
			AudioTools.StoreAudioClip("MLPCPCK-U", "HardReset.ClockLoop", SoundManager.LoadAudioClip("HardReset_ClockLoop.ogg"));
		}

		private static int RegisterAbilities()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			IEnumerable<Type> enumerable = from t in executingAssembly.GetTypes()
				where t.Namespace == "MLPCPCK.Abilities" || t.Namespace == "MLPCPCK.SpecialAbilities"
				select t;
			int num = 0;
			foreach (Type item in enumerable)
			{
				try
				{
					MethodInfo method = item.GetMethod("AddAbility", BindingFlags.Static | BindingFlags.Public);
					if (!(method == null))
					{
						num++;
						method.Invoke(null, null);
					}
				}
				catch (Exception arg)
				{
					Log.LogError((object)string.Format("[{0}] Failed to register \"{1}\" ability! Exception message:\n{2}\n", "RegisterAbilities", item.Name, arg));
				}
			}
			return num;
		}
	}
	public abstract class MLPAbility
	{
		public static Ability Swarm = MLPCPCK.Abilities.Swarm.ability;

		public static Ability CandyCurse => MLPCPCK.Abilities.CandyCurse.ability;

		public static Ability ChaosAgent => MLPCPCK.Abilities.ChaosAgent.ability;

		public static Ability Forgettable => MLPCPCK.Abilities.Forgettable.ability;

		public static Ability HardReset => MLPCPCK.Abilities.HardReset.ability;
	}
	public abstract class MLPSpecial
	{
		public static SpecialTriggeredAbility BlackFlank => BlankSpecialBehaviour.ability;

		public static SpecialTriggeredAbility Infiltrator => NictisSpecialBehaviour.ability;

		public static SpecialTriggeredAbility Surprise => SurpriseSpecialBehaviour.ability;
	}
	public abstract class MLPTrait
	{
		public static readonly Trait Changeling = GuidManager.GetEnumValue<Trait>("MLPTrait", "Changeling");
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MLPCPCK-U";

		public const string PLUGIN_NAME = "MLP:FIM CardPack";

		public const string PLUGIN_VERSION = "0.6.5";
	}
}
namespace MLPCPCK.SpecialAbilities
{
	public class BlankSpecialBehaviour : SpecialCardBehaviour
	{
		internal static SpecialTriggeredAbility ability;

		private static readonly CardInfo CardToDraw = CardDuplicator.MakeChangedCopy(CardLoader.GetCardByName("MLPCPCK_Blank_Flank"), CardSamples.BlankFlankDebuffed);

		public static void AddAbility()
		{
			//IL_001a: 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)
			ability = SpecialTriggeredAbilityManager.Add("MLPSpecial", "BlankFlank", typeof(BlankSpecialBehaviour)).Id;
		}

		public override bool RespondsToOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer)
		{
			return (Object)(object)killer == (Object)(object)((SpecialCardBehaviour)this).PlayableCard && !CardExtensions.HasTrait(card, (Trait)12);
		}

		public override IEnumerator OnOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer)
		{
			yield return CreateDrawnCard();
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
		}

		private IEnumerator CreateDrawnCard()
		{
			View oldView = Singleton<ViewManager>.Instance.CurrentView;
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
			if (!CardExtensions.IsPlayerCard(((SpecialCardBehaviour)this).PlayableCard))
			{
				Opponent self = Singleton<TurnManager>.Instance.Opponent;
				if (!((Object)(object)self != (Object)null))
				{
					yield break;
				}
				CardSlot mainQueued = null;
				CardSlot secondaryQueued = null;
				List<CardSlot> opposingSlots = Singleton<BoardManager>.Instance.GetSlots(false);
				foreach (CardSlot opposingSlot in opposingSlots)
				{
					if ((Object)(object)Singleton<BoardManager>.Instance.GetCardQueuedForSlot(opposingSlot) == (Object)null)
					{
						if ((Object)(object)opposingSlot.Card == (Object)null)
						{
							mainQueued = opposingSlot;
							break;
						}
						secondaryQueued = opposingSlot;
					}
				}
				if ((Object)(object)mainQueued == (Object)null && (Object)(object)secondaryQueued != (Object)null)
				{
					mainQueued = secondaryQueued;
				}
				else if ((Object)(object)mainQueued == (Object)null && (Object)(object)secondaryQueued == (Object)null)
				{
					yield break;
				}
				Singleton<ViewManager>.Instance.SwitchToView((View)6, false, false);
				PlayableCard card = self.CreateCard(CardToDraw);
				Singleton<BoardManager>.Instance.QueueCardForSlot(card, mainQueued, 0.25f, true, true);
				self.Queue.Add(card);
				yield return (object)new WaitForSeconds(0.8f);
				Singleton<ViewManager>.Instance.SwitchToView(oldView, false, false);
			}
			else
			{
				yield return (object)new WaitForSeconds(0.2f);
				Singleton<ViewManager>.Instance.SwitchToView((View)0, false, false);
				yield return (object)new WaitForSeconds(0.2f);
				yield return Singleton<CardSpawner>.Instance.SpawnCardToHand(CardToDraw, 0.25f);
				yield return (object)new WaitForSeconds(0.8f);
				Singleton<ViewManager>.Instance.SwitchToView(oldView, false, false);
				yield return (object)new WaitForSeconds(0.2f);
			}
		}
	}
	public class NictisSpecialBehaviour : SpecialCardBehaviour
	{
		internal static SpecialTriggeredAbility ability;

		private const string ID = "-ci.bh";

		private const string BaseForm = "MLPCPCK_Nictis";

		private const string DefaultForm = "MLPCPCK_Mare";

		private static readonly Color SunnyYellowColor = new Color(0.96f, 0.84f, 0.22f);

		public static void AddAbility()
		{
			//IL_001a: 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)
			ability = SpecialTriggeredAbilityManager.Add("MLPSpecial", "Infiltrator", typeof(NictisSpecialBehaviour)).Id;
		}

		public override bool RespondsToDrawn()
		{
			return true;
		}

		public override IEnumerator OnDrawn()
		{
			DisguiseInBattle();
			yield break;
		}

		public override bool RespondsToResolveOnBoard()
		{
			return true;
		}

		public override IEnumerator OnResolveOnBoard()
		{
			yield return RevealInBattle();
		}

		public override IEnumerator OnShownForCardSelect(bool forPositiveEffect)
		{
			DisguiseOutOfBattle();
			yield break;
		}

		public override IEnumerator OnSelectedForDeckTrial()
		{
			DisguiseOutOfBattle();
			yield break;
		}

		public override void OnShownInDeckReview()
		{
			DisguiseOutOfBattle();
			ShowBlueEyes();
		}

		public override void OnShownForCardChoiceNode()
		{
			DisguiseAsCardChoice();
		}

		private IEnumerator RevealInBattle()
		{
			yield return (object)new WaitForSeconds(0.25f);
			AudioController.Instance.PlaySound3D("trial_cave_outro#1", (MixerGroup)4, ((Component)this).transform.position, 1f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
			yield return ((SpecialCardBehaviour)this).PlayableCard.TransformIntoCard(CardLoader.GetCardByName("MLPCPCK_Nictis"), (Action)null, (Action)null);
		}

		private void DisguiseInBattle()
		{
			List<CardInfo> list = new List<CardInfo>(Singleton<CardDrawPiles>.Instance.Deck.Cards);
			list.RemoveAll((CardInfo x) => ((Object)x).name == "!STATIC!GLITCH");
			DisguiseAsCard((list.Count <= 0) ? CardLoader.GetCardByName("MLPCPCK_Mare") : list[SeededRandom.Range(0, list.Count, SaveManager.SaveFile.GetCurrentRandomSeed())]);
			((Card)((SpecialCardBehaviour)this).PlayableCard).AddPermanentBehaviour<NictisSpecialBehaviour>();
		}

		private void DisguiseOutOfBattle()
		{
			List<CardInfo> list = new List<CardInfo>(((CardCollectionInfo)RunState.Run.playerDeck).Cards);
			list.RemoveAll((CardInfo x) => ((Object)x).name == "MLPCPCK_Nictis" || ((Object)x).name == "!STATIC!GLITCH");
			DisguiseAsCard((list.Count <= 0) ? CardLoader.GetCardByName("MLPCPCK_Mare") : list[Random.Range(0, list.Count)]);
		}

		private void DisguiseAsCardChoice()
		{
			//IL_0033: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			CardInfo randomUnlockedRareCard = CardLoader.GetRandomUnlockedRareCard(Environment.TickCount);
			while (((Object)randomUnlockedRareCard).name == "MLPCPCK_Nictis")
			{
				randomUnlockedRareCard = CardLoader.GetRandomUnlockedRareCard(Environment.TickCount);
			}
			randomUnlockedRareCard.Mods.Add(new CardModificationInfo
			{
				singletonId = "-ci.bh",
				specialAbilities = new List<SpecialTriggeredAbility> { MLPSpecial.Infiltrator },
				nameReplacement = string.Format(Localization.Translate("{0}?"), randomUnlockedRareCard.DisplayedNameLocalized)
			});
			DisguiseAsCard(randomUnlockedRareCard);
			ShowBlueEyes();
		}

		private void ShowBlueEyes()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			((SpecialCardBehaviour)this).Card.RenderInfo.forceEmissivePortrait = true;
			((SpecialCardBehaviour)this).Card.StatsLayer.SetEmissionColor(SunnyYellowColor);
			((SpecialCardBehaviour)this).Card.RenderCard();
		}

		private void DisguiseAsCard(CardInfo disguise)
		{
			((SpecialCardBehaviour)this).Card.ClearAppearanceBehaviours();
			((SpecialCardBehaviour)this).Card.SetInfo(disguise);
		}
	}
	public class SurpriseSpecialBehaviour : SpecialCardBehaviour
	{
		internal static SpecialTriggeredAbility ability;

		private static bool IsSurpriseExist = false;

		private static Dictionary<PlayableCard, int> SurpriseCards = new Dictionary<PlayableCard, int>();

		private static List<string> SurpriseLines = new List<string> { "[e:1]Miss me?!?", "[e:4]Suuurprise!!!!", "I like this game!", "Don't forget about me!" };

		private int turnsInPlay = 0;

		private int turnsUntilDisappearance;

		public static void AddAbility()
		{
			//IL_001a: 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)
			ability = SpecialTriggeredAbilityManager.Add("MLPSpecial", "Surprise", typeof(SurpriseSpecialBehaviour)).Id;
		}

		public void Start()
		{
			try
			{
				turnsUntilDisappearance = SeededRandom.Range(2, 6, ((TriggerReceiver)this).GetRandomSeed());
			}
			catch (Exception)
			{
			}
		}

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

		public override IEnumerator OnUpkeep(bool playerUpkeep)
		{
			turnsInPlay++;
			if (turnsInPlay == turnsUntilDisappearance)
			{
				MakeDisappeared();
			}
			yield break;
		}

		private void MakeDisappeared()
		{
			IsSurpriseExist = true;
			SurpriseCards.Add(((SpecialCardBehaviour)this).PlayableCard, Singleton<TurnManager>.Instance.TurnNumber);
			((SpecialCardBehaviour)this).PlayableCard.UnassignFromSlot();
			((SpecialCardBehaviour)this).PlayableCard.Slot = null;
			((Component)((SpecialCardBehaviour)this).PlayableCard).gameObject.SetActive(false);
		}

		internal static IEnumerator TryToReturnOld(TurnManager turnManager)
		{
			if (!IsSurpriseExist)
			{
				yield break;
			}
			Dictionary<PlayableCard, int> surpriseDictionary = SurpriseCards;
			if (surpriseDictionary.Count == 0)
			{
				IsSurpriseExist = false;
				yield break;
			}
			if (turnManager.TurnNumber < 3)
			{
				ClearSurprises();
			}
			bool isPlayerTurn = turnManager.IsPlayerTurn;
			List<PlayableCard> surpriseCards = surpriseDictionary.Keys.ToList();
			List<PlayableCard> cards = surpriseCards.FindAll((PlayableCard c) => CardExtensions.IsPlayerCard(c) == isPlayerTurn && surpriseDictionary[c] != turnManager.TurnNumber);
			if (LinqExtensions.IsNullOrEmpty<PlayableCard>((IList<PlayableCard>)cards))
			{
				yield break;
			}
			int seed = SaveManager.SaveFile.GetCurrentRandomSeed() + Singleton<GlobalTriggerHandler>.Instance.NumTriggersThisBattle + Singleton<TurnManager>.Instance.TurnNumber;
			int seedModifier = 0;
			PropertyInfo propertyInfo = AccessTools.Property(typeof(CombatPhaseManager), "DamageDealtThisPhase");
			CombatPhaseManager combatPhaseManager = turnManager.CombatPhaseManager;
			propertyInfo.SetValue((combatPhaseManager is CombatPhaseManager3D) ? combatPhaseManager : null, 0);
			CombatPhaseManager combatPhaseManager2 = turnManager.CombatPhaseManager;
			((CombatPhaseManager3D)((combatPhaseManager2 is CombatPhaseManager3D) ? combatPhaseManager2 : null)).damageWeights.Clear();
			foreach (PlayableCard card in cards)
			{
				seed += seedModifier;
				if (SeededRandom.Range(0, 2, seed) == 0)
				{
					List<CardSlot> emptySlots = (from s in Singleton<BoardManager>.Instance.GetSlots(isPlayerTurn)
						where (Object)(object)s.Card == (Object)null
						select s).ToList();
					if (!LinqExtensions.IsNullOrEmpty<CardSlot>((IList<CardSlot>)emptySlots))
					{
						CardSlot slot = emptySlots[SeededRandom.Range(0, emptySlots.Count - 1, seed)];
						yield return Singleton<BoardManager>.Instance.AssignCardToSlot(card, slot, 0.1f, (Action)null, true);
						((Component)card).gameObject.SetActive(true);
						int attackCount = turnManager.TurnNumber - surpriseDictionary[card];
						surpriseDictionary.Remove(card);
						if ((Object)(object)slot.Card == (Object)null)
						{
							TalkingCard talkingCard = ((Component)card).GetComponent<TalkingCard>();
							if ((Object)(object)talkingCard != (Object)null)
							{
								yield return (object)new WaitForSeconds(0.1f);
								Singleton<ViewManager>.Instance.SwitchToView((View)4, true, true);
								yield return (object)new WaitForSeconds(0.1f);
								Line line = new Line
								{
									text = SurpriseLines[SeededRandom.Range(0, SurpriseLines.Count - 1, seed)]
								};
								yield return talkingCard.PlayLine(line);
							}
							for (int i = 0; i < attackCount; i++)
							{
								if (!((Object)(object)slot.Card == (Object)null))
								{
									yield return turnManager.CombatPhaseManager.SlotAttackSequence(slot);
									yield return (object)new WaitForSeconds(0.1f);
								}
							}
						}
					}
				}
				seedModifier++;
			}
			if (turnManager.CombatPhaseManager.DamageDealtThisPhase > 0)
			{
				CombatPhaseManager combatPhaseManager3 = turnManager.CombatPhaseManager;
				bool playerIsAttacker = turnManager.IsPlayerTurn;
				SpecialBattleSequencer specialSequencer = turnManager.SpecialSequencer;
				yield return (object)new WaitForSeconds(0.4f);
				yield return combatPhaseManager3.VisualizeDamageMovingToScales(playerIsAttacker);
				int excessDamage = 0;
				if (playerIsAttacker)
				{
					excessDamage = Singleton<LifeManager>.Instance.Balance + combatPhaseManager3.DamageDealtThisPhase - 5;
					excessDamage = Mathf.Max(0, excessDamage);
				}
				int damage = combatPhaseManager3.DamageDealtThisPhase - excessDamage;
				AscensionStatsData.TryIncreaseStat((Type)4, combatPhaseManager3.DamageDealtThisPhase);
				if (!((Object)(object)specialSequencer != (Object)null) || !specialSequencer.PreventDamageAddedToScales)
				{
					yield return Singleton<LifeManager>.Instance.ShowDamageSequence(damage, damage, !playerIsAttacker, 0f, (GameObject)null, 0f, true);
				}
				if ((Object)(object)specialSequencer != (Object)null)
				{
					yield return specialSequencer.DamageAddedToScale(damage + excessDamage, playerIsAttacker);
				}
				if ((!((Object)(object)specialSequencer != (Object)null) || !specialSequencer.PreventDamageAddedToScales) && excessDamage > 0 && Singleton<TurnManager>.Instance.Opponent.NumLives == 1 && Singleton<TurnManager>.Instance.Opponent.GiveCurrencyOnDefeat)
				{
					yield return Singleton<TurnManager>.Instance.Opponent.TryRevokeSurrender();
					RunState run = RunState.Run;
					run.currency += excessDamage;
					yield return combatPhaseManager3.VisualizeExcessLethalDamage(excessDamage, specialSequencer);
				}
			}
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
		}

		internal static void ClearSurprises()
		{
			foreach (PlayableCard key in SurpriseCards.Keys)
			{
				Object.Destroy((Object)(object)key);
			}
			SurpriseCards.Clear();
			IsSurpriseExist = false;
		}
	}
}
namespace MLPCPCK.Resources
{
	internal static class CardSamples
	{
		internal static PonyCardData BlankFlankDebuffed = new PonyCardData
		{
			Attack = 4,
			BloodCost = 1
		};
	}
	internal static class DialogueSamples
	{
		private static string _eventPrefix = "MLPCPCK-U.Twilight.HardReset.";

		public static PonyDialogueData LethalDamageTaken = new PonyDialogueData
		{
			Name = _eventPrefix + "LethalDamageTaken",
			MainLines = new List<CustomLine>
			{
				CustomLine.op_Implicit("[e:5][w:1][e:1][w:0.6]Shouldn't..[w:0.7]"),
				CustomLine.op_Implicit("[e:2]I be dead?[w:1.3]"),
				CustomLine.op_Implicit("This is really strange[w:0.5]"),
				CustomLine.op_Implicit("Is this what the icon[0.3]"),
				CustomLine.op_Implicit("under my portrait does?[w:1]"),
				CustomLine.op_Implicit("What does that[w:0.3]"),
				CustomLine.op_Implicit("new thing on the board do?")
			},
			RepeatLines = new List<List<CustomLine>>
			{
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]Ugh. The loop doesn't work the same here") },
				new List<CustomLine>
				{
					CustomLine.op_Implicit("Being in a state of alive and dead?[w:0.3]"),
					CustomLine.op_Implicit("[e:2]This feels horrible, please decide already")
				},
				new List<CustomLine> { CustomLine.op_Implicit("[e:3]More corpses") },
				new List<CustomLine>
				{
					CustomLine.op_Implicit("Oh my Celestia[e:1][w:1]"),
					CustomLine.op_Implicit("[e:2] This is fucking awful")
				},
				new List<CustomLine> { CustomLine.op_Implicit("[e:3] Again.. and again..") },
				new List<CustomLine> { CustomLine.op_Implicit("Please don't") },
				new List<CustomLine> { CustomLine.op_Implicit("Can I finally rest?") },
				new List<CustomLine> { CustomLine.op_Implicit("I'm so tired") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]I'm in your hooves..") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:4] This really hurts you know") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:3]I hope you get to feel this someday") },
				new List<CustomLine> { CustomLine.op_Implicit("I'm just a passenger of fate") },
				new List<CustomLine> { CustomLine.op_Implicit("Is this amusing to you?") },
				new List<CustomLine> { CustomLine.op_Implicit("Hurry up.") },
				new List<CustomLine> { CustomLine.op_Implicit("I hate you.") },
				new List<CustomLine> { CustomLine.op_Implicit("Don't mind me, just casually dying.") },
				new List<CustomLine> { CustomLine.op_Implicit("Having no agency sucks.") },
				new List<CustomLine> { CustomLine.op_Implicit("Leave me alone.") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]It never fucking ends.") },
				new List<CustomLine>
				{
					CustomLine.op_Implicit("I don't even know how it feels[w:0.5]"),
					CustomLine.op_Implicit("[e:1]To be mortal anymore.")
				},
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]Let me die.") }
			}
		};

		public static PonyDialogueData OnAbilityActivated = new PonyDialogueData
		{
			Name = _eventPrefix + "OnAbilityActivated",
			MainLines = new List<CustomLine>
			{
				CustomLine.op_Implicit("I see[w:0.5]"),
				CustomLine.op_Implicit("So the board was reset[w:1]"),
				CustomLine.op_Implicit("[e:3]So I really am just here as a pawn[w:0.3]"),
				CustomLine.op_Implicit("[e:3]for someone else's amusement, huh?[w:0.8]"),
				CustomLine.op_Implicit("[e:1][w:0.2][shake:1]How utterly sickening,[w:0.2] honestly")
			},
			RepeatLines = new List<List<CustomLine>>
			{
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]Back again") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]Lovely") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]Why do you keep doing this to me?") },
				new List<CustomLine> { CustomLine.op_Implicit("Anything to win, right?") },
				new List<CustomLine> { CustomLine.op_Implicit("You think this is just a game don't you?") },
				new List<CustomLine> { CustomLine.op_Implicit("Do you think what I feel isn't real?") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]Whatever") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:3]I swear..") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]Having fun?") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]....") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:1]Why not,[e:2] I guess?[e:3]") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:3]Bye bye board.") },
				new List<CustomLine> { CustomLine.op_Implicit("At least it doesn't hurt now.") },
				new List<CustomLine> { CustomLine.op_Implicit("The pain is over at least.") }
			}
		};

		public static PonyDialogueData OnAbilityNotUsed = new PonyDialogueData
		{
			Name = _eventPrefix + "OnAbilityNotUsed",
			MainLines = new List<CustomLine>
			{
				CustomLine.op_Implicit("This is it for now huh?[w:0.7]"),
				CustomLine.op_Implicit("[e:4]Thank [w:0.4]you[e:5]")
			},
			RepeatLines = new List<List<CustomLine>>
			{
				new List<CustomLine> { CustomLine.op_Implicit("[e:4]Hell yeah..") },
				new List<CustomLine> { CustomLine.op_Implicit("..[w:1][e:4][w:1][e:3]") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:4]Into oblivion..") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:3][shake:1].[shake:1][w:0.5].[shake:1][w:0.5]") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:3]The end of me.. finally.") },
				new List<CustomLine> { CustomLine.op_Implicit("[e:4]Seeya never.") },
				new List<CustomLine> { CustomLine.op_Implicit("I better not wake up after this.") }
			}
		};
	}
}
namespace MLPCPCK.Patches
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public class CanAttackDirectlyPatch
	{
		[HarmonyPostfix]
		public static void Postfix(CardSlot opposingSlot, ref bool __result, ref PlayableCard __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (!__result && (Object)(object)CardExtensions.OpposingSlot(__instance) != (Object)(object)opposingSlot && (Object)(object)opposingSlot.Card != (Object)null && opposingSlot.Card.HasAbility(MLPAbility.Forgettable))
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch]
	public class TurnManagerPatch
	{
		[HarmonyPatch(typeof(TurnManager), "PlayerTurn")]
		[HarmonyPatch(typeof(TurnManager), "OpponentTurn")]
		[HarmonyPostfix]
		public static IEnumerator APostfix(IEnumerator enumerator, TurnManager __instance)
		{
			yield return enumerator;
			yield return SurpriseSpecialBehaviour.TryToReturnOld(__instance);
		}

		[HarmonyPatch(typeof(TurnManager), "CleanupPhase")]
		[HarmonyPostfix]
		public static void CleanupPhasePatch()
		{
			SurpriseSpecialBehaviour.ClearSurprises();
		}
	}
}
namespace MLPCPCK.Helpers
{
	public class HardResetButtonColliderBehaviour : MainInputInteractable
	{
		internal Action OnClick;

		private static bool ClickAvailable => GameFlowManager.IsCardBattle && Singleton<GlobalTriggerHandler>.Instance.StackSize == 0 && ((Object)(object)Singleton<BoardManager>.Instance == (Object)null || (!Singleton<BoardManager>.Instance.ChoosingSlot && !Singleton<BoardManager>.Instance.ChoosingSacrifices)) && Singleton<TurnManager>.Instance.IsPlayerMainPhase && !Singleton<TurnManager>.Instance.GameEnding && !Singleton<ItemsManager>.Instance.ActivatingItem;

		public override CursorType CursorType => (CursorType)10;

		public override void OnCursorSelectStart()
		{
			if (ClickAvailable && OnClick != null)
			{
				OnClick();
			}
		}
	}
}
namespace MLPCPCK.Abilities
{
	public class CandyCurse : AbilityBehaviour
	{
		internal static Ability ability;

		private const string ID = "-cc.ab";

		private CardModificationInfo _curse;

		public override Ability Ability => ability;

		public static void AddAbility()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = AbilityManager.New("MLPAbility", "Candy Curse", "This sigil permanently grants 1 attack per card killed by it's bearer. Upon the card's death it will permanently lose 2 attack. Upon reaching 4 or above attack the sigil's bearer will gain Made of Stone. Upon reaching 7 or above attack, the card will gain Omnistrike. This sigil may not obey cards that are not The Candy Mare.", typeof(CandyCurse), "candisigilmlp.png");
			RuleBookRedirectExtensions.SetAbilityRedirect(val, "Made of Stone", (Ability)105, GameColors.Instance.seafoam);
			RuleBookRedirectExtensions.SetAbilityRedirect(val, "Omnistrike", (Ability)33, GameColors.Instance.seafoam);
			AbilityExtensions.SetPixelAbilityIcon(val, TextureHelper.GetImageAsTexture("candisigilmlpsmall.png", (FilterMode)0), (FilterMode?)null);
			AbilityExtensions.AddMetaCategories(val, (AbilityMetaCategory[])(object)new AbilityMetaCategory[1]);
			AbilityExtensions.SetNotMergeable(val, true);
			val.powerLevel = 4;
			val.canStack = false;
			val.opponentUsable = false;
			ability = val.ability;
		}

		private void Start()
		{
			//IL_0059: 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_006e: Expected O, but got Unknown
			List<CardModificationInfo> mods = ((Card)((AbilityBehaviour)this).Card).Info.Mods;
			if (mods.Count > 0)
			{
				_curse = mods.Find((CardModificationInfo m) => m.singletonId != null && m.singletonId.Equals("-cc.ab"));
			}
			if (_curse == null)
			{
				_curse = new CardModificationInfo
				{
					singletonId = "-cc.ab"
				};
				RunState.Run.playerDeck.ModifyCard(((Card)((AbilityBehaviour)this).Card).Info, _curse);
			}
			UpdateAbilities();
		}

		public override bool RespondsToOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer)
		{
			return fromCombat && (Object)(object)killer == (Object)(object)((AbilityBehaviour)this).Card;
		}

		public override IEnumerator OnOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer)
		{
			CardModificationInfo curse = _curse;
			curse.attackAdjustment++;
			((AbilityBehaviour)this).Card.OnStatsChanged();
			((Card)((AbilityBehaviour)this).Card).Anim.LightNegationEffect();
			yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
		}

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

		public override IEnumerator OnDie(bool wasSacrifice, PlayableCard killer)
		{
			int atk = _curse.attackAdjustment;
			if (atk <= 8)
			{
				atk -= 2;
				_curse.attackAdjustment = ((atk > 0) ? atk : 0);
				yield break;
			}
			double st = (double)atk / 2.0;
			double nd = 8.0 / (double)atk;
			nd = 2.0 / nd;
			st -= nd;
			CardModificationInfo curse = _curse;
			curse.attackAdjustment -= (int)st;
		}

		public override bool RespondsToAttackEnded()
		{
			return ((AbilityBehaviour)this).Card.OnBoard;
		}

		public override IEnumerator OnAttackEnded()
		{
			UpdateAbilities();
			yield break;
		}

		private void UpdateAbilities()
		{
			int attackAdjustment = _curse.attackAdjustment;
			List<Ability> abilities = _curse.abilities;
			List<Ability> list = new List<Ability>(2);
			if (attackAdjustment > 3)
			{
				list.Add((Ability)105);
			}
			if (attackAdjustment > 6)
			{
				list.Add((Ability)33);
			}
			if (abilities.Count != list.Count)
			{
				_curse.abilities = list;
				((AbilityBehaviour)this).Card.OnStatsChanged();
				((Card)((AbilityBehaviour)this).Card).Anim.PlayTransformAnimation();
			}
		}
	}
	public class ChaosAgent : AbilityBehaviour
	{
		private enum Strategy
		{
			Flying,
			Submerge,
			Morsel,
			BeesOnHit,
			Dogging,
			None
		}

		internal static Ability ability;

		private const string ID = "-ch.ab";

		private readonly CardModificationInfo _chaosStrategy = new CardModificationInfo
		{
			singletonId = "-ch.ab",
			abilities = new List<Ability>(1) { (Ability)25 },
			negateAbilities = new List<Ability>(5)
			{
				(Ability)19,
				(Ability)13,
				(Ability)103,
				(Ability)2,
				(Ability)25
			}
		};

		private Strategy _currentStrategy = Strategy.None;

		private static Texture2D[] _icons = (Texture2D[])(object)new Texture2D[5]
		{
			TextureHelper.GetImageAsTexture("chaos.flying.sigilmlp.png", (FilterMode)0),
			TextureHelper.GetImageAsTexture("chaos.submerge.sigilmlp.png", (FilterMode)0),
			TextureHelper.GetImageAsTexture("chaos.morsel.sigilmlp.png", (FilterMode)0),
			TextureHelper.GetImageAsTexture("chaos.beehive.sigilmlp.png", (FilterMode)0),
			TextureHelper.GetImageAsTexture("chaos.dogging.sigilmlp.png", (FilterMode)0)
		};

		public override Ability Ability => ability;

		public static void AddAbility()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = AbilityManager.New("MLPAbility", "Chaos Agent", "A shard of Discord's chaotic power imprisoned inside [creature].Under it's influence, behavior of the [creature] will randomly change every turn.\nThis sigil permanently negates Flying, Submerge, Morsel and Beehive sigils.", typeof(ChaosAgent), "chaossigilmlp.png");
			AbilityExtensions.SetAbilityLearnedDialogue(val, (Line[])(object)new Line[1]
			{
				new Line
				{
					text = "Madness...",
					speakerIndex = 1,
					emotion = (Emotion)0
				}
			});
			RuleBookRedirectExtensions.SetAbilityRedirect(val, "Flying", (Ability)19, GameColors.Instance.seafoam);
			RuleBookRedirectExtensions.SetAbilityRedirect(val, "Submerge", (Ability)13, GameColors.Instance.seafoam);
			RuleBookRedirectExtensions.SetAbilityRedirect(val, "Morsel", (Ability)103, GameColors.Instance.seafoam);
			RuleBookRedirectExtensions.SetAbilityRedirect(val, "Beehive", (Ability)2, GameColors.Instance.seafoam);
			AbilityExtensions.SetPixelAbilityIcon(val, TextureHelper.GetImageAsTexture("chaossigilmlpsmall.png", (FilterMode)0), (FilterMode?)null);
			AbilityExtensions.AddMetaCategories(val, (AbilityMetaCategory[])(object)new AbilityMetaCategory[1]);
			val.powerLevel = 2;
			val.canStack = false;
			val.opponentUsable = false;
			ability = val.ability;
		}

		private void Start()
		{
			((AbilityBehaviour)this).Card.AddTemporaryMod(_chaosStrategy);
			if (((AbilityBehaviour)this).Card.OnBoard)
			{
				ChangeStrategy();
				UpdateDisplay();
			}
		}

		public override bool RespondsToResolveOnBoard()
		{
			return true;
		}

		public override IEnumerator OnResolveOnBoard()
		{
			ChangeStrategy();
			yield return (object)new WaitForSeconds(0.15f);
			UpdateDisplay();
			if (!((AbilityBehaviour)this).HasLearned)
			{
				yield return ((AbilityBehaviour)this).LearnAbility(0.5f);
			}
			else
			{
				yield return (object)new WaitForSeconds(0.15f);
			}
		}

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

		public override IEnumerator OnUpkeep(bool _)
		{
			return ((TriggerReceiver)this).OnResolveOnBoard();
		}

		private void ChangeStrategy()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Invalid comparison between Unknown and I4
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Invalid comparison between Unknown and I4
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Invalid comparison between Unknown and I4
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			_chaosStrategy.attackAdjustment = 0;
			if (((AbilityBehaviour)this).Card.Health > 2)
			{
				_chaosStrategy.healthAdjustment = 0;
			}
			if (_currentStrategy != Strategy.None && _currentStrategy != Strategy.Dogging)
			{
				Ability val = _chaosStrategy.abilities[0];
				_chaosStrategy.negateAbilities[(int)_currentStrategy] = val;
				((AbilityBehaviour)this).Card.Status.hiddenAbilities.Remove(val);
				if ((int)val == 13 || (int)val == 103 || (int)val == 2)
				{
					((AbilityBehaviour)this).Card.TriggerHandler.RemoveAbility(val);
				}
			}
			List<Strategy> list = new List<Strategy>
			{
				Strategy.Flying,
				Strategy.Submerge,
				Strategy.Morsel,
				Strategy.BeesOnHit,
				Strategy.Dogging
			};
			list.Remove(_currentStrategy);
			_currentStrategy = list[SeededRandom.Range(0, list.Count, ((TriggerReceiver)this).GetRandomSeed())];
			switch (_currentStrategy)
			{
			case Strategy.Flying:
				_chaosStrategy.attackAdjustment = ((((AbilityBehaviour)this).Card.Attack > 2) ? (-2) : 0);
				break;
			case Strategy.BeesOnHit:
				_chaosStrategy.healthAdjustment = 2;
				break;
			case Strategy.Dogging:
				_chaosStrategy.attackAdjustment = 2;
				_chaosStrategy.abilities[0] = (Ability)25;
				return;
			}
			int currentStrategy = (int)_currentStrategy;
			Ability val2 = _chaosStrategy.negateAbilities[currentStrategy];
			_chaosStrategy.abilities[0] = val2;
			_chaosStrategy.negateAbilities[currentStrategy] = (Ability)0;
			((AbilityBehaviour)this).Card.Status.hiddenAbilities.Add(val2);
			((AbilityBehaviour)this).Card.TriggerHandler.AddAbility(val2);
		}

		private void UpdateDisplay()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			((Card)((AbilityBehaviour)this).Card).Anim.LightNegationEffect();
			((Card)((AbilityBehaviour)this).Card).RenderInfo.OverrideAbilityIcon(MLPAbility.ChaosAgent, (Texture)(object)_icons[(int)_currentStrategy]);
			((AbilityBehaviour)this).Card.OnStatsChanged();
		}
	}
	public class Forgettable : AbilityBehaviour
	{
		internal static Ability ability;

		public override Ability Ability => ability;

		public static void AddAbility()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = AbilityManager.New("MLPAbility", "Forgettable", "[creature] cannot be attacked unless directly opposed.", typeof(Forgettable), "forgettablesigilmlp.png");
			AbilityExtensions.AddMetaCategories(val, (AbilityMetaCategory[])(object)new AbilityMetaCategory[1]);
			AbilityExtensions.SetNotMergeable(val, true);
			val.powerLevel = -5;
			val.canStack = false;
			val.opponentUsable = false;
			ability = val.ability;
		}
	}
	public class HardReset : AbilityBehaviour, IModifyDamageTaken, IOnPreScalesChangedRef, IOnBellRung
	{
		internal static Ability ability;

		private BoardState _state;

		private bool _needResetFlag;

		private static GameObject _resetItem;

		internal static GameObject ResetItemPrefab;

		private bool _resetReady;

		private int _damageStored = 0;

		private PlayableCard _killer = null;

		private static AudioClip _clock;

		private static AudioClip _clockLooped;

		private static AudioSource _soundLoop;

		private static bool _deferredDialogueFlag;

		public override Ability Ability => ability;

		public static void AddAbility()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = AbilityManager.New("MLPAbility", "Hard Reset", "The card bearing this sigil is cursed with undeath. Once Twilight takes lethal damage you will be able to choose whether to let her die, or to reset back to when you first placed her.", typeof(HardReset), "hardresetsigilmlp.png");
			AbilityExtensions.SetPixelAbilityIcon(val, TextureHelper.GetImageAsTexture("hardresetsigilmlpsmall.png", (FilterMode)0), (FilterMode?)null);
			val.powerLevel = 4;
			val.canStack = false;
			val.opponentUsable = false;
			AbilityExtensions.AddMetaCategories(val, (AbilityMetaCategory[])(object)new AbilityMetaCategory[1]);
			AbilityExtensions.SetNotMergeable(val, true);
			ability = val.ability;
			_clock = AudioTools.GetAudioClip("MLPCPCK-U", "HardReset.Clock");
			_clockLooped = AudioTools.GetAudioClip("MLPCPCK-U", "HardReset.ClockLoop");
			ResetItemPrefab.transform.position = new Vector3(-1.429f, 4.071f, -4.716f);
			ResetItemPrefab.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
			((Component)ResetItemPrefab.transform.Find("Anim/model/Collider")).gameObject.AddComponent<HardResetButtonColliderBehaviour>();
		}

		private IEnumerator Start()
		{
			if (!((AbilityBehaviour)this).Card.OnBoard)
			{
				yield break;
			}
			_state = BoardState.GenerateFromCurrentBoard();
			if (!_deferredDialogueFlag)
			{
				yield break;
			}
			_deferredDialogueFlag = false;
			TalkingCard talkingComponent = default(TalkingCard);
			((Component)((AbilityBehaviour)this).Card).TryGetComponent<TalkingCard>(ref talkingComponent);
			if (!((Object)(object)talkingComponent == (Object)null))
			{
				if (DialogueEventsData.EventIsPlayed("MLPCPCK-U.Twilight.HardReset.OnAbilityActivated"))
				{
					yield return talkingComponent.PlaySoloDialogueEvent("MLPCPCK-U.Twilight.HardReset.OnAbilityActivated");
					yield break;
				}
				View currentView = Singleton<ViewManager>.Instance.CurrentView;
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
				Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
				yield return (object)new WaitForSeconds(0.5f);
				yield return talkingComponent.PlaySoloDialogueEvent("MLPCPCK-U.Twilight.HardReset.OnAbilityActivated");
				yield return (object)new WaitForSeconds(0.5f);
				Singleton<ViewManager>.Instance.SwitchToView(currentView, false, false);
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
			}
		}

		public override bool RespondsToResolveOnBoard()
		{
			return true;
		}

		public override IEnumerator OnResolveOnBoard()
		{
			_state = BoardState.GenerateFromCurrentBoard();
			yield break;
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)_resetItem) || _resetReady)
			{
				DestroyResetItem();
			}
			if (Object.op_Implicit((Object)(object)_soundLoop))
			{
				Object.Destroy((Object)(object)_soundLoop, _soundLoop.clip.length - _soundLoop.time);
			}
		}

		public bool RespondsToModifyDamageTaken(PlayableCard target, int damage, PlayableCard attacker, int originalDamage)
		{
			return (Object)(object)target == (Object)(object)((AbilityBehaviour)this).Card && !((AbilityBehaviour)this).Card.HasShield();
		}

		public int OnModifyDamageTaken(PlayableCard target, int damage, PlayableCard attacker, int originalDamage)
		{
			if (target.Health > damage && ((Object)(object)attacker == (Object)null || !attacker.HasAbility((Ability)4)))
			{
				return damage;
			}
			if (_needResetFlag)
			{
				return 0;
			}
			if (!Object.op_Implicit((Object)(object)_soundLoop))
			{
				_soundLoop = AudioTools.PlayAudioLooped(_clockLooped, 0.05f);
			}
			((Card)((AbilityBehaviour)this).Card).RenderInfo.hiddenAttack = true;
			((Card)((AbilityBehaviour)this).Card).RenderInfo.hiddenHealth = true;
			((AbilityBehaviour)this).Card.AttackedThisTurn = true;
			((Card)((AbilityBehaviour)this).Card).RenderCard();
			_killer = attacker;
			_needResetFlag = true;
			return 0;
		}

		public int TriggerPriority(PlayableCard target, int damage, PlayableCard attacker)
		{
			return int.MaxValue;
		}

		public override bool RespondsToTakeDamage(PlayableCard source)
		{
			return _needResetFlag && !_resetReady;
		}

		public override IEnumerator OnTakeDamage(PlayableCard source)
		{
			TalkingCard talkingComponent = default(TalkingCard);
			((Component)((AbilityBehaviour)this).Card).TryGetComponent<TalkingCard>(ref talkingComponent);
			if ((Object)(object)talkingComponent != (Object)null)
			{
				yield return talkingComponent.PlaySoloDialogueEvent("MLPCPCK-U.Twilight.HardReset.LethalDamageTaken");
			}
			yield return SpawnResetItem();
		}

		public bool RespondsToPreScalesChangedRef(int damage, int numWeights, bool toPlayer)
		{
			return toPlayer && _needResetFlag;
		}

		public int CollectPreScalesChangedRef(int damage, ref int numWeights, ref bool toPlayer)
		{
			_damageStored = damage;
			numWeights = 0;
			return 0;
		}

		public bool RespondsToBellRung(bool playerCombatPhase)
		{
			return playerCombatPhase && _resetReady;
		}

		public IEnumerator OnBellRung(bool playerCombatPhase)
		{
			return AbilityNotUsed(needToStoreView: false);
		}

		public override bool RespondsToOtherCardResolve(PlayableCard card)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			return CardExtensions.IsPlayerCard(card) && _resetReady && (int)Singleton<TurnManager>.Instance.PlayerPhase == 1;
		}

		public override IEnumerator OnOtherCardResolve(PlayableCard card)
		{
			return AbilityNotUsed(needToStoreView: true);
		}

		private IEnumerator SpawnResetItem()
		{
			if (!Object.op_Implicit((Object)(object)_resetItem))
			{
				_resetItem = Object.Instantiate<GameObject>(ResetItemPrefab);
			}
			((Component)_resetItem.transform.Find("Anim/model/Collider")).GetComponent<HardResetButtonColliderBehaviour>().OnClick = delegate
			{
				((MonoBehaviour)this).StartCoroutine(RevertToSnapshot());
			};
			_resetReady = true;
			yield break;
		}

		private void DestroyResetItem()
		{
			if (Object.op_Implicit((Object)(object)_resetItem))
			{
				Object.Destroy((Object)(object)_resetItem);
			}
			_resetItem = null;
			_resetReady = false;
		}

		private IEnumerator AbilityNotUsed(bool needToStoreView)
		{
			View currentView = Singleton<ViewManager>.Instance.CurrentView;
			_needResetFlag = false;
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
			Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
			yield return (object)new WaitForSeconds(0.5f);
			TalkingCard talkingComponent = default(TalkingCard);
			((Component)((AbilityBehaviour)this).Card).TryGetComponent<TalkingCard>(ref talkingComponent);
			if ((Object)(object)talkingComponent != (Object)null)
			{
				yield return talkingComponent.PlaySoloDialogueEvent("MLPCPCK-U.Twilight.HardReset.OnAbilityNotUsed");
			}
			if (Object.op_Implicit((Object)(object)_soundLoop) && (Object)(object)_soundLoop.clip != (Object)(object)_clock)
			{
				_soundLoop.loop = false;
				_soundLoop.clip = _clock;
				yield return (object)new WaitUntil((Func<bool>)(() => !_soundLoop.isPlaying));
				_soundLoop.Play();
			}
			DestroyResetItem();
			yield return ((AbilityBehaviour)this).Card.Die(false, _killer, true);
			yield return (object)new WaitForSeconds(0.5f);
			if (_damageStored != 0)
			{
				Singleton<ViewManager>.Instance.SwitchToView((View)7, false, false);
				yield return Singleton<LifeManager>.Instance.ShowDamageSequence(_damageStored, _damageStored, true, 0.25f, (GameObject)null, 0.5f, true);
			}
			if (needToStoreView)
			{
				Singleton<ViewManager>.Instance.SwitchToView(currentView, false, false);
			}
			Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
		}

		private IEnumerator RevertToSnapshot()
		{
			_deferredDialogueFlag = true;
			if (Object.op_Implicit((Object)(object)_resetItem))
			{
				DestroyResetItem();
			}
			if (Object.op_Implicit((Object)(object)_soundLoop) && (Object)(object)_soundLoop.clip != (Object)(object)_clock)
			{
				_soundLoop.loop = false;
				_soundLoop.clip = _clock;
				yield return (object)new WaitUntil((Func<bool>)(() => !_soundLoop.isPlaying));
				_soundLoop.Play();
			}
			Singleton<LifeManager>.Instance.SetNumWeightsImmediate(_state.playerDamage, _state.opponentDamage);
			foreach (CardSlot allSlot in Singleton<BoardManager>.Instance.AllSlots)
			{
				if (Object.op_Implicit((Object)(object)allSlot.Card))
				{
					PlayableCard card = allSlot.Card;
					allSlot.Card.UnassignFromSlot();
					Object.Destroy((Object)(object)((Component)card).gameObject);
				}
			}
			MethodInfo applySlotState = AccessTools.Method(typeof(PhotographerSnapshotManager), "ApplySlotState", (Type[])null, (Type[])null);
			PhotographerSnapshotManager obj = new PhotographerSnapshotManager();
			List<SlotState> slots = _state.playerSlots;
			List<CardSlot> actualSlots = Singleton<BoardManager>.Instance.PlayerSlotsCopy;
			int i = 0;
			while (i < slots.Count)
			{
				if (slots[i].card != null)
				{
					((MonoBehaviour)this).StartCoroutine((IEnumerator)applySlotState.Invoke(obj, new object[2]
					{
						slots[i],
						actualSlots[i]
					}));
				}
				int num = i + 1;
				i = num;
			}
			slots = _state.opponentSlots;
			actualSlots = Singleton<BoardManager>.Instance.OpponentSlotsCopy;
			int i2 = 0;
			while (i2 < slots.Count)
			{
				if (slots[i2].card != null)
				{
					((MonoBehaviour)this).StartCoroutine((IEnumerator)applySlotState.Invoke(obj, new object[2]
					{
						slots[i2],
						actualSlots[i2]
					}));
				}
				int num = i2 + 1;
				i2 = num;
			}
			((ScreenEffect)Singleton<UIManager>.Instance.Effects.GetEffect<ScreenGlitchEffect>()).SetIntensity(1f, 0.4f);
			yield return (object)new WaitForSeconds(1f);
		}
	}
	public class Swarm : AbilityBehaviour, IPassiveAttackBuff
	{
		internal static Ability ability;

		private readonly string[] _cardsToPlace = new string[4] { "MLPCPCK_Changeling", "MLPCPCK_Changeling_Drone", "MLPCPCK_Changeling_Brute", "MLPCPCK_Changeling_Scout" };

		public override Ability Ability => ability;

		public static void AddAbility()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			AbilityInfo val = AbilityManager.New("MLPAbility", "Swarm", "This sigil will place a random changeling card on either side of it's bearer once placed.", typeof(Swarm), "swarmsigilmlp.png");
			AbilityExtensions.SetPixelAbilityIcon(val, TextureHelper.GetImageAsTexture("swarmsigilmlpsmall.png", (FilterMode)0), (FilterMode?)null);
			AbilityExtensions.AddMetaCategories(val, (AbilityMetaCategory[])(object)new AbilityMetaCategory[1]);
			AbilityExtensions.SetNotMergeable(val, true);
			val.powerLevel = 2;
			val.canStack = false;
			val.opponentUsable = false;
			ability = val.ability;
		}

		public int GetPassiveAttackBuff(PlayableCard target)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return (CardExtensions.HasTrait(target, MLPTrait.Changeling) && CardExtensions.IsPlayerCard(target) == CardExtensions.IsPlayerCard(((AbilityBehaviour)this).Card) && ((AbilityBehaviour)this).Card.OnBoard) ? 1 : 0;
		}

		public override bool RespondsToResolveOnBoard()
		{
			return true;
		}

		public override IEnumerator OnResolveOnBoard()
		{
			bool isPlayerCard = CardExtensions.IsPlayerCard(((AbilityBehaviour)this).Card);
			yield return CreateAdjacentCards(isPlayerCard);
		}

		private IEnumerator CreateAdjacentCards(bool isPlayerCard)
		{
			List<CardSlot> slots = Singleton<BoardManager>.Instance.GetSlots(isPlayerCard);
			int index = slots.IndexOf(((AbilityBehaviour)this).Card.Slot);
			if (index < 0)
			{
				yield break;
			}
			int index2 = index - 1;
			CardSlot toLeft = ((index2 >= 0) ? slots[index2] : null);
			index2 = index + 1;
			CardSlot toRight = ((index2 < slots.Count) ? slots[index2] : null);
			bool toLeftValid = (Object)(object)toLeft != (Object)null && (Object)(object)toLeft.Card == (Object)null;
			bool toRightValid = (Object)(object)toRight != (Object)null && (Object)(object)toRight.Card == (Object)null;
			if (toLeftValid || toRightValid)
			{
				yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
				int seed = ((TriggerReceiver)this).GetRandomSeed();
				CardInfo cardToPlace = CardLoader.GetCardByName(_cardsToPlace[SeededRandom.Range(0, 3, seed)]);
				if (toLeftValid)
				{
					yield return Singleton<BoardManager>.Instance.CreateCardInSlot(cardToPlace, toLeft, 0.1f, true);
				}
				cardToPlace = CardLoader.GetCardByName(_cardsToPlace[SeededRandom.Range(0, 3, seed + 50)]);
				if (toRightValid)
				{
					yield return Singleton<BoardManager>.Instance.CreateCardInSlot(cardToPlace, toRight, 0.1f, true);
				}
			}
		}
	}
}