Decompiled source of MirrorMatch v1.0.3

MirrorMatch.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DiskCardGame;
using GBC;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("MirrorMatch")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Placeholder description")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MirrorMatch")]
[assembly: AssemblyTitle("MirrorMatch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MirrorMatch
{
	[BepInPlugin("tvflabs.inscryption.MirrorMatch", "MirrorMatch", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Opponent), "SpawnOpponent")]
		private class Opponent_SpawnOpponent_Patch
		{
			private static void Postfix(Opponent __instance, EncounterData encounterData)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Invalid comparison between Unknown and I4
				List<CardInfo> list = new List<CardInfo>();
				if ((int)encounterData.opponentType == 8)
				{
					list.Add(CardLoader.GetCardByName("Bonehound"));
					list.Add(CardLoader.GetCardByName("Banshee"));
					list.Add(CardLoader.GetCardByName("Sarcophagus"));
				}
				else
				{
					foreach (List<CardInfo> item in encounterData.opponentTurnPlan)
					{
						foreach (CardInfo item2 in item)
						{
							if ((Object)(object)item2 != (Object)null)
							{
								object obj = item2.Clone();
								list.Add((CardInfo)((obj is CardInfo) ? obj : null));
							}
						}
					}
					foreach (StartCondition startCondition in encounterData.startConditions)
					{
						CardInfo[] cardsInOpponentSlots = startCondition.cardsInOpponentSlots;
						foreach (CardInfo val in cardsInOpponentSlots)
						{
							if ((Object)(object)val != (Object)null)
							{
								object obj2 = val.Clone();
								list.Add((CardInfo)((obj2 is CardInfo) ? obj2 : null));
							}
						}
						CardInfo[] cardsInOpponentQueue = startCondition.cardsInOpponentQueue;
						foreach (CardInfo val2 in cardsInOpponentQueue)
						{
							if ((Object)(object)val2 != (Object)null)
							{
								object obj3 = val2.Clone();
								list.Add((CardInfo)((obj3 is CardInfo) ? obj3 : null));
							}
						}
					}
				}
				((CardCollectionInfo)SaveManager.SaveFile.CurrentDeck).CardInfos = list;
			}
		}

		[HarmonyPatch(typeof(Opponent), "ReplaceAndAppendTurnPlan")]
		private class Opponent_ReplaceAndAppendTurnPlan_Patch
		{
			private static void Postfix(Opponent __instance, List<List<CardInfo>> plan)
			{
				if (__instance is GrimoraBossOpponent)
				{
					return;
				}
				List<CardInfo> list = new List<CardInfo>();
				foreach (List<CardInfo> item in __instance.TurnPlan)
				{
					foreach (CardInfo item2 in item)
					{
						if ((Object)(object)item2 != (Object)null)
						{
							object obj = item2.Clone();
							list.Add((CardInfo)((obj is CardInfo) ? obj : null));
						}
					}
				}
				((CardCollectionInfo)SaveManager.SaveFile.CurrentDeck).CardInfos.AddRange(list);
				foreach (CardInfo item3 in list)
				{
					Singleton<CardDrawPiles>.Instance.Deck.AddCard(item3);
				}
				if ((Object)(object)CardDrawPiles3D.Instance != (Object)null)
				{
					CardDrawPiles3D.Instance.Pile.CreateCards(list.Count, 15f);
				}
			}
		}

		[HarmonyPatch(typeof(GrimoraBattleSequencer), "OnOtherCardDie")]
		private class GrimoraBattleSequencer_OnOtherCardDie_Patch
		{
			private static IEnumerator Postfix(IEnumerator values, GrimoraBattleSequencer __instance, PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer)
			{
				object obj = ((Card)card).Info.Clone();
				CardInfo cardToAdd = (CardInfo)((obj is CardInfo) ? obj : null);
				((CardCollectionInfo)SaveManager.SaveFile.CurrentDeck).CardInfos.Add(cardToAdd);
				Singleton<CardDrawPiles>.Instance.Deck.AddCard(cardToAdd);
				yield return values;
			}
		}

		private Harmony harmony = new Harmony("tvflabs.inscryption.MirrorMatch");

		private const string PluginGuid = "tvflabs.inscryption.MirrorMatch";

		private const string PluginName = "MirrorMatch";

		private const string PluginVersion = "1.0.3";

		private const string PluginPrefix = "MirrorMatch";

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded MirrorMatch!");
			harmony.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MirrorMatch";

		public const string PLUGIN_NAME = "MirrorMatch";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}