Decompiled source of NoMoreMetaScaling v1.1.8

NoMetaScaling.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
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 AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LBoL.Base;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Battle;
using LBoL.Core.Battle.BattleActions;
using LBoL.Core.Cards;
using LBoL.Core.StatusEffects;
using LBoL.Core.Units;
using LBoL.EntityLib.Exhibits;
using LBoL.EntityLib.StatusEffects.Enemy;
using LBoL.Presentation;
using LBoL.Presentation.UI.Panels;
using LBoLEntitySideloader;
using LBoLEntitySideloader.Attributes;
using LBoLEntitySideloader.BattleModifiers.Actions;
using LBoLEntitySideloader.CustomHandlers;
using LBoLEntitySideloader.Entities;
using LBoLEntitySideloader.PersistentValues;
using LBoLEntitySideloader.ReflectionHelpers;
using LBoLEntitySideloader.Resource;
using LBoLEntitySideloader.Utils;
using NoMetaScaling;
using NoMetaScaling.Core;
using NoMetaScaling.Core.API;
using NoMetaScaling.Core.EnemyGroups;
using NoMetaScaling.Core.Loc;
using NoMetaScaling.Core.Trackers;
using NoMetaScalling;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("NoMetaScaling")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoMetaScaling")]
[assembly: AssemblyTitle("NoMetaScaling")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace NoMetaScaling
{
	public static class PConfig
	{
		private static string banSection = "Ban rules";

		private static ConfigEntry<BanLevel> banLevel;

		private static ConfigEntry<bool> allowFirstTimeDeckedGen;

		public static BanLevel BanLevel => banLevel.Value;

		public static bool AllowFirstTimeDeckedGen => allowFirstTimeDeckedGen.Value;

		public static void DoBinds(ConfigFile configFile)
		{
			banLevel = configFile.Bind<BanLevel>(banSection, "BanLevel", BanLevel.RealCopiesAllowed, "Ban strictness. Copies are considered generated cards and thus banned unless BanLevel option is `RealCopiesAllowed`.");
			allowFirstTimeDeckedGen = configFile.Bind<bool>(banSection, "AllowFirstTimeDeckedGen", true, "Cards generated by legal, decked card will be legal when that card performs generation for the first time in combat.");
		}
	}
	public enum BanLevel
	{
		RealCopiesAllowed,
		Strict
	}
	internal static class Statics
	{
		internal static IResourceSource embeddedSource = (IResourceSource)new EmbeddedSource(Assembly.GetExecutingAssembly());

		internal static DirectorySource directorySource = new DirectorySource("neo.lbol.modifiers.noMetaScaling", "");

		internal static BatchLocalization seBatchLoc = new BatchLocalization((IResourceSource)(object)directorySource, typeof(StatusEffectTemplate), "fakeSE", (Locale)0, false);
	}
}
namespace NoMetaScaling.Debug
{
	public class DebugCardDef : CardTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("DebugCard");
		}

		public override CardImages LoadCardImages()
		{
			return null;
		}

		public override LocalizationOption LoadLocalization()
		{
			return null;
		}

		public override CardConfig MakeConfig()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			CardConfig val = ((CardTemplate)this).DefaultConfig();
			val.Type = (CardType)3;
			val.TargetType = (TargetType)0;
			ManaGroup cost = default(ManaGroup);
			((ManaGroup)(ref cost)).Any = 2;
			val.Cost = cost;
			return val;
		}
	}
	public class DebugCard : Card
	{
		protected override void OnEnterBattle(BattleController battle)
		{
			((Card)this).ReactBattleEvent<CardUsingEventArgs>(battle.CardUsed, (EventSequencedReactor<CardUsingEventArgs>)OnCardUsedReactor);
		}

		private IEnumerable<BattleAction> OnCardUsedReactor(CardUsingEventArgs args)
		{
			yield return (BattleAction)new GainMoneyAction(10, (SpecialSourceType)0);
			((GameEntity)this).GameRun.GainMaxHpOnly(3, false);
		}

		private void OnCardUsed(CardUsingEventArgs args)
		{
			((GameEntity)this).GameRun.GainMaxHpOnly(3, false);
		}
	}
}
namespace NoMetaScaling.Core
{
	public static class ActionCancel
	{
		[HarmonyPatch(typeof(GameRunController), "GainMaxHp")]
		private class GainMaxHp_Patch
		{
			private static bool Prefix(GameRunController __instance)
			{
				return PrefixCancel(__instance, NoMoreMetaScalingLocSE.LocalizeProp("MaxHp"));
			}
		}

		[HarmonyPatch(typeof(GameRunController), "GainMaxHpOnly")]
		private class GainMaxHpOnly_Patch
		{
			private static bool Prefix(GameRunController __instance)
			{
				return PrefixCancel(__instance, NoMoreMetaScalingLocSE.LocalizeProp("MaxHp"));
			}
		}

		[HarmonyPatch]
		private class GainMoney_Patch
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(GameRunController), "GainMoney", (Type[])null, (Type[])null);
			}

			private static bool Prefix(GameRunController __instance)
			{
				return PrefixCancel(__instance, NoMoreMetaScalingLocSE.LocalizeProp("Money"));
			}
		}

		[HarmonyPatch(typeof(GainMoneyAction), "ResolvePhase")]
		private class GainMoneyAction_Patch
		{
			private static FieldInfo f_Money;

			private static FieldInfo F_Money
			{
				get
				{
					if (f_Money == null)
					{
						f_Money = AccessTools.Field(typeof(GainMoneyAction), ConfigReflection.BackingWrap("Money"));
					}
					return f_Money;
				}
			}

			private static bool Prefix(GainMoneyAction __instance)
			{
				bool flag = PrefixCancel(((BattleAction)__instance).Battle.GameRun, NoMoreMetaScalingLocSE.LocalizeProp("Money"), ((BattleAction)__instance).Source);
				if (!flag)
				{
					F_Money.SetValue(__instance, 0);
				}
				return flag;
			}
		}

		[HarmonyPatch(typeof(GameRunVisualPanel), "ViewGainMoney")]
		private class ViewGainMoney_Patch
		{
			private static bool Prefix(GainMoneyAction action)
			{
				if (action.Money <= 0)
				{
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(GainPowerAction), "PreEventPhase")]
		private class GainPowerAction_Patch
		{
			private static void Postfix(GainPowerAction __instance)
			{
				PowerEventArgs args = ((EventBattleAction<PowerEventArgs>)(object)__instance).Args;
				CancelAction((GameEventArgs)(object)args, NoMoreMetaScalingLocSE.LocalizeProp("Power"));
			}
		}

		[HarmonyPatch(typeof(GameRunController), "GainPower")]
		private class GainPower_Patch
		{
			private static bool Prefix(GameRunController __instance)
			{
				return PrefixCancel(__instance, NoMoreMetaScalingLocSE.LocalizeProp("Power"));
			}
		}

		[HarmonyPatch(typeof(GameRunController), "UpgradeDeckCards")]
		private class UpgradeDeckCard_Patch
		{
			private static bool Prefix(GameRunController __instance)
			{
				return PrefixCancel(__instance, NoMoreMetaScalingLocSE.LocalizeProp("UpgradeACard"));
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private class FinalBossInitialDamage_Patch
		{
			private static bool Prefix(GameRunController __instance, int value)
			{
				if (value > 0)
				{
					return PrefixCancel(__instance, NoMoreMetaScalingLocSE.LocalizeProp("SeijaDmg"));
				}
				return true;
			}
		}

		private static IEnumerable<BattleAction> DoChat(GameEntity source, string cancelTarget, BanReason reason)
		{
			GameRunController currentGameRun = Singleton<GameMaster>.Instance.CurrentGameRun;
			PlayerUnit player = ((currentGameRun != null) ? currentGameRun.Player : null);
			if (player != null)
			{
				if (Random.Range(0f, 1f) > 0.96f)
				{
					yield return (BattleAction)(object)PerformAction.Chat((Unit)(object)player, "I'M A DEGENERATE", 1.75f, 0f, 0f, true);
					yield break;
				}
				string chatString = NoMoreMetaScalingLocSE.GetBanChatString(source, cancelTarget, reason);
				yield return (BattleAction)(object)PerformAction.Chat((Unit)(object)player, chatString, 6f, 0f, 0f, true);
			}
		}

		private static void DoYap(GameEntity source, string cancelTarget, BanReason reason)
		{
			foreach (BattleAction item in DoChat(source, cancelTarget, reason))
			{
				BattleCWT.Battle.RequestDebugAction(item, "Yapping");
			}
		}

		private static bool PrefixCancel(GameRunController gr, string cancelTarget, GameEntity actionSource = null)
		{
			BattleController battle = gr.Battle;
			if (battle == null)
			{
				return true;
			}
			if (!GrCWT.GetGrState(gr).cancelEnnabled)
			{
				return true;
			}
			if (actionSource == null)
			{
				actionSource = ARTracker.lastActionSource;
			}
			if (CardFilter.IsEntityBanned(actionSource, out var reason))
			{
				DoYap(ARTracker.lastActionSource, cancelTarget, reason);
				return false;
			}
			GameEntity obj = actionSource.TrickleDownActionSource();
			Card val = (Card)(object)((obj is Card) ? obj : null);
			if (val != null)
			{
				BattleCWT.GetBanData(battle).QueueBan(val, BanReason.MetaResourcesAlreadyProvided);
			}
			return true;
		}

		private static void CancelAction(GameEventArgs args, string cancelTarget)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			if (!GrCWT.GetGrState(GrCWT.GR).cancelEnnabled)
			{
				return;
			}
			if (CardFilter.IsEntityBanned(args.ActionSource, out var reason))
			{
				if (BattleCWT.Battle._resolver._reactors == null)
				{
					DoYap(args.ActionSource, cancelTarget, reason);
				}
				else
				{
					BattleCWT.Battle.React(new Reactor(DoChat(args.ActionSource, cancelTarget, reason)), (GameEntity)null, (ActionCause)0);
				}
				args.CancelBy(args.ActionSource);
			}
			GameEntity obj = args.ActionSource.TrickleDownActionSource();
			Card val = (Card)(object)((obj is Card) ? obj : null);
			if (val != null)
			{
				BattleCWT.GetBanData(BattleCWT.Battle).QueueBan(val, BanReason.MetaResourcesAlreadyProvided);
			}
		}

		public static void RegisterHandlers()
		{
			CHandlerManager.RegisterBattleEventHandler<HealEventArgs>((EventProvider<HealEventArgs, BattleController>)((BattleController bt) => ((Unit)bt.Player).HealingReceiving), (GameEventHandler<HealEventArgs>)OnPlayerHealing, (Predicate<BattleController>)null, (GameEventPriority)int.MaxValue);
		}

		private static void OnPlayerHealing(HealEventArgs args)
		{
			CancelAction((GameEventArgs)(object)args, NoMoreMetaScalingLocSE.LocalizeProp("Healing"));
		}
	}
	public static class BattleCWT
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPriority(0)]
		private class BattleController_Patch
		{
			private static void Prefix(BattleController __instance)
			{
				battle_ref = new WeakReference<BattleController>(__instance);
				cwt_battleData.Add(__instance, new BattleData());
			}

			private static void Postfix(BattleController __instance)
			{
				startingId = __instance._cardInstanceId;
			}
		}

		internal static int startingId = 1000;

		private static ConditionalWeakTable<BattleController, BattleData> cwt_battleData = new ConditionalWeakTable<BattleController, BattleData>();

		private static WeakReference<BattleController> battle_ref;

		public static BattleController Battle
		{
			get
			{
				GameRunController currentGameRun = Singleton<GameMaster>.Instance.CurrentGameRun;
				BattleController target = ((currentGameRun != null) ? currentGameRun.Battle : null);
				if (target == null)
				{
					battle_ref.TryGetTarget(out target);
				}
				return target;
			}
		}

		public static CopyHistory CopyHistory => GetCopyHistory(Battle);

		public static BattleData GetBattleData(BattleController battle)
		{
			return cwt_battleData.GetOrCreateValue(battle);
		}

		public static BanData GetBanData(BattleController battle)
		{
			return GetBattleData(battle).banData;
		}

		public static CopyHistory GetCopyHistory(BattleController battle)
		{
			return GetBattleData(battle).copyHistory;
		}
	}
	public class BattleData
	{
		public BanData banData = new BanData();

		public CopyHistory copyHistory = new CopyHistory();
	}
	public static class CardFilter
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private class OnCardUsing_Patch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Expected O, but got Unknown
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Expected O, but got Unknown
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Expected O, but got Unknown
				return new CodeMatcher(instructions, (ILGenerator)null).MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(CardUsingEventArgs), "PlayTwice"))) }).MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertySetter(typeof(Card), "PlayTwiceSourceCard"))) }).Advance(1)
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Ldloc_1, (object)null)
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(CardFilter), "OnCardUsing", (Type[])null, (Type[])null))
					})
					.InstructionEnumeration();
			}
		}

		[return: MaybeNull]
		public static GameEntity TrickleDownActionSource(this GameEntity actionSource)
		{
			GameEntity result = actionSource;
			StatusEffect val = (StatusEffect)(object)((actionSource is StatusEffect) ? actionSource : null);
			if (val != null && val.SourceCard != null)
			{
				result = (GameEntity)(object)val.SourceCard;
			}
			return result;
		}

		public static bool IsEntityBanned(GameEntity gameEntity, out BanReason reason)
		{
			reason = BanReason.NotBanned;
			StatusEffect val = (StatusEffect)(object)((gameEntity is StatusEffect) ? gameEntity : null);
			if (val != null && StatusEffectSplitter.TryGetIsSEReal(val, out var isSEReal))
			{
				if (!isSEReal.isReal)
				{
					reason = BanReason.StatusEffectWasFake;
					return true;
				}
				return false;
			}
			GameEntity obj = gameEntity?.TrickleDownActionSource();
			return ((Card)(object)((obj is Card) ? obj : null))?.IsBanned(out reason) ?? false;
		}

		public static bool WasGenerated(this Card card)
		{
			return card.InstanceId > BattleCWT.startingId;
		}

		public static bool IsBanned(this Card card, out BanReason reason)
		{
			if (BattleCWT.Battle == null)
			{
				reason = BanReason.NotBanned;
				return false;
			}
			return BattleCWT.GetBanData(BattleCWT.Battle).IsBanned(card, out reason);
		}

		public static void RegisterHandlers()
		{
			NoMetaScalinAPI.ExemptFromBanIfGenerated("PurpleMogu");
			NoMetaScalinAPI.ExemptFromBanIfPlayed("VampireShoot1");
			NoMetaScalinAPI.ExemptFromBanIfPlayed("VampireShoot2");
			NoMetaScalinAPI.ExemptFromBanIfPlayed("Psychedelic");
			NoMetaScalinAPI.ExemptFromBanIfPlayed("BuyPeace");
			NoMetaScalinAPI.ExemptFromBanIfPlayed("PoisonTeaParty");
			NoMetaScalinAPI.AddBanByDefault("FakeMoon");
			RegisterCommonHandlers(OnCardCreated, (GameEventPriority)10);
			CHandlerManager.RegisterBattleEventHandler<CardUsingEventArgs>((EventProvider<CardUsingEventArgs, BattleController>)((BattleController bt) => bt.CardUsed), (GameEventHandler<CardUsingEventArgs>)OnCardUsedPlayed, (Predicate<BattleController>)null, (GameEventPriority)9999);
			CHandlerManager.RegisterBattleEventHandler<CardUsingEventArgs>((EventProvider<CardUsingEventArgs, BattleController>)((BattleController bt) => bt.CardPlayed), (GameEventHandler<CardUsingEventArgs>)OnCardUsedPlayed, (Predicate<BattleController>)null, (GameEventPriority)9999);
		}

		private static void OnCardUsedPlayed(CardUsingEventArgs args)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			Card card = args.Card;
			if ((int)card.CardType == 5 && card.Summoned && !BattleCWT.GetBanData(BattleCWT.Battle).alreadySummoned.Contains(card))
			{
				BattleCWT.GetBanData(BattleCWT.Battle).alreadySummoned.Add(card);
			}
		}

		private static void OnCardUsing(UseCardAction action)
		{
			CardUsingEventArgs args = action.Args;
			Card card = args.Card;
			Card twiceTokenCard = action._twiceTokenCard;
			if (!args.PlayTwice)
			{
				return;
			}
			WeakReference<GameEntity>? weakReference = ((GameEventArgs)args)._modifiers.LastOrDefault();
			if (weakReference != null && weakReference.TryGetTarget(out var target))
			{
				GameEntity obj = target.TrickleDownActionSource();
				Card val = (Card)(object)((obj is Card) ? obj : null);
				if (val != null && HandleCopying(val, card, out var reason))
				{
					BattleCWT.GetBanData(BattleCWT.Battle).BanCard(twiceTokenCard, reason);
				}
			}
		}

		internal static bool HandleCopying(Card sourceCard, Card original, out BanReason reason)
		{
			reason = BanReason.NotBanned;
			bool result = true;
			BanData banData = BattleCWT.GetBanData(BattleCWT.Battle);
			if (PConfig.BanLevel <= BanLevel.RealCopiesAllowed)
			{
				if (!sourceCard.IsBanned(out var reason2))
				{
					if (!original.IsBanned(out reason2))
					{
						result = false;
					}
					else
					{
						reason = BanReason.CopyTargetWasBanned;
					}
				}
				else
				{
					reason = BanReason.CopySourceWasBanned;
				}
				if (((GameEntity)sourceCard).Id == "BailianMagic" && sourceCard.IsUpgraded && banData.GetCopiedTimes(sourceCard) < 1)
				{
					banData.IncreaseCopyTimes(sourceCard);
				}
				else
				{
					banData.QueueBan(sourceCard, BanReason.CardWasAlreadyUsed);
				}
			}
			else
			{
				reason = BanReason.CardWasCopied;
				banData.QueueBan(sourceCard, BanReason.CardWasAlreadyUsed);
			}
			return result;
		}

		private static void OnCardCreated(Card[] cards, GameEventArgs args)
		{
			GameEntity obj = args.ActionSource.TrickleDownActionSource();
			Card val = (Card)(object)((obj is Card) ? obj : null);
			if (val == null)
			{
				return;
			}
			BanData banData = BattleCWT.GetBanData(BattleCWT.Battle);
			foreach (Card val2 in cards)
			{
				if (!val.IsBanned(out var reason) && ExposedStatics.exemptFromGenBan.Contains(((GameEntity)val2).Id))
				{
					continue;
				}
				bool flag = true;
				BanReason reason2 = BanReason.CardWasGenerated;
				if (PConfig.AllowFirstTimeDeckedGen && !val.IsBanned(out reason) && !val.WasGenerated() && ((GameEntity)val2).Id != "FakeMoon")
				{
					banData.QueueBan(val, BanReason.CardWasAlreadyUsed);
					continue;
				}
				if (!val.IsBanned(out reason) && val.InvokedEcho() && (val.IsNaturalEcho() || val.IsNaturalPermaEcho()))
				{
					banData.QueueBan(val, BanReason.CardWasAlreadyUsed);
					continue;
				}
				if (BattleCWT.GetCopyHistory(BattleCWT.Battle).IfWasCopiedForget(val2, out var copyPair))
				{
					flag = HandleCopying(val, copyPair.original, out reason2);
				}
				if (flag)
				{
					banData.BanCard(val2, reason2);
				}
			}
		}

		private static void RegisterCommonHandlers(Action<Card[], GameEventArgs> handler, GameEventPriority priority = 10)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			GameEventHandler<CardsAddingToDrawZoneEventArgs> val = delegate(CardsAddingToDrawZoneEventArgs args)
			{
				handler(args.Cards, (GameEventArgs)(object)args);
			};
			GameEventHandler<CardsEventArgs> val2 = delegate(CardsEventArgs args)
			{
				handler(args.Cards, (GameEventArgs)(object)args);
			};
			CHandlerManager.RegisterBattleEventHandler<CardsEventArgs>((EventProvider<CardsEventArgs, BattleController>)((BattleController bt) => bt.CardsAddedToExile), val2, (Predicate<BattleController>)null, priority);
			CHandlerManager.RegisterBattleEventHandler<CardsAddingToDrawZoneEventArgs>((EventProvider<CardsAddingToDrawZoneEventArgs, BattleController>)((BattleController bt) => bt.CardsAddedToDrawZone), val, (Predicate<BattleController>)null, priority);
			CHandlerManager.RegisterBattleEventHandler<CardsEventArgs>((EventProvider<CardsEventArgs, BattleController>)((BattleController bt) => bt.CardsAddedToHand), val2, (Predicate<BattleController>)null, priority);
			CHandlerManager.RegisterBattleEventHandler<CardsEventArgs>((EventProvider<CardsEventArgs, BattleController>)((BattleController bt) => bt.CardsAddedToDiscard), val2, (Predicate<BattleController>)null, priority);
		}
	}
	public enum BanReason
	{
		NotBanned,
		MetaResourcesAlreadyProvided,
		CardWasAlreadyUsed,
		StatusEffectWasFake,
		CopySourceWasBanned,
		CopyTargetWasBanned,
		CardWasCopied,
		CardWasGenerated,
		BannedByDefault,
		Other
	}
	public class BanData
	{
		public static readonly BanReason[] CopiedReasons = new BanReason[3]
		{
			BanReason.CopySourceWasBanned,
			BanReason.CopyTargetWasBanned,
			BanReason.CardWasCopied
		};

		private Dictionary<Card, BanReason> pendingBan = new Dictionary<Card, BanReason>();

		private Dictionary<Card, BanReason> bannedCards = new Dictionary<Card, BanReason>();

		internal HashSet<Card> alreadySummoned = new HashSet<Card>();

		private Dictionary<Card, int> copiedTimes;

		private Dictionary<Card, int> CopiedTimes
		{
			get
			{
				if (copiedTimes == null)
				{
					copiedTimes = new Dictionary<Card, int>();
				}
				return copiedTimes;
			}
		}

		public void BanCard(Card card, BanReason reason)
		{
			DictionaryExtensions.AlwaysAdd<Card, BanReason>(bannedCards, card, reason);
		}

		public bool IsBanned(Card card, out BanReason reason)
		{
			reason = BanReason.NotBanned;
			if (ExposedStatics.alwaysBanned.Contains(((GameEntity)card).Id))
			{
				reason = BanReason.BannedByDefault;
				return true;
			}
			BanReason value;
			bool flag = bannedCards.TryGetValue(card, out value);
			if (flag)
			{
				reason = value;
			}
			return flag;
		}

		internal void FlushPendingBan()
		{
			foreach (KeyValuePair<Card, BanReason> item in pendingBan)
			{
				BanCard(item.Key, item.Value);
			}
			pendingBan.Clear();
		}

		public void QueueBan(Card card, BanReason reason)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			if (!ExposedStatics.exemptFromPlayBan.Contains(((GameEntity)card).Id))
			{
				if ((int)card.CardType == 5 && card.Summoned && !BattleCWT.GetBanData(BattleCWT.Battle).alreadySummoned.Contains(card))
				{
					BattleCWT.GetBanData(BattleCWT.Battle).alreadySummoned.Add(card);
				}
				else
				{
					DictionaryExtensions.AlwaysAdd<Card, BanReason>(pendingBan, card, reason);
				}
			}
		}

		public int GetCopiedTimes(Card card)
		{
			if (CopiedTimes.TryGetValue(card, out var value))
			{
				return value;
			}
			return 0;
		}

		public void IncreaseCopyTimes(Card card, int increase = 1)
		{
			if (!CopiedTimes.ContainsKey(card))
			{
				CopiedTimes.Add(card, 0);
			}
			CopiedTimes[card] += increase;
		}
	}
	public static class StatusEffectSplitter
	{
		[HarmonyPatch(typeof(ApplyStatusEffectAction), "PreEventPhase")]
		private class ApplyStatusEffectAction_PreEvent_Patch
		{
			private static void Prefix(ApplyStatusEffectAction __instance)
			{
				StatusEffectApplyEventArgs args = ((EventBattleAction<StatusEffectApplyEventArgs>)(object)__instance).Args;
				if (args.Effect.IsStackable)
				{
					GameEntity obj = ((GameEventArgs)((EventBattleAction<StatusEffectApplyEventArgs>)(object)__instance).Args).ActionSource?.TrickleDownActionSource();
					Card val = (Card)(object)((obj is Card) ? obj : null);
					if (val != null && ExposedStatics.splitableSE_CARD_ids.Contains(((GameEntity)val).Id))
					{
						AttachIsSEReal(args.Effect, !val.IsBanned(out var _));
					}
				}
			}
		}

		[HarmonyPatch(typeof(Unit), "TryAddStatusEffect")]
		private class TryAddStatusEffect_Mathching_Patch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Expected O, but got Unknown
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Expected O, but got Unknown
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Expected O, but got Unknown
				return new CodeMatcher(instructions, (ILGenerator)null).MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Unit), "GetStatusEffect", new Type[1] { typeof(Type) }, (Type[])null))) }).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Pop, (object)null)).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldarg_1, (object)null)
				})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(TryAddStatusEffect_Mathching_Patch), "MatchByIsReal", (Type[])null, (Type[])null))
					})
					.InstructionEnumeration();
			}

			private static StatusEffect MatchByIsReal(Unit unit, StatusEffect otherSE)
			{
				if (TryGetIsSEReal(otherSE, out var isSEOtherReal))
				{
					return ((IEnumerable<StatusEffect>)unit.StatusEffects).FirstOrDefault((Func<StatusEffect, bool>)((StatusEffect se) => ((object)se).GetType() == ((object)otherSE).GetType() && isSEOtherReal.Equals(GetIsSEReal(se))));
				}
				return unit.GetStatusEffect(((object)otherSE).GetType());
			}
		}

		private static ConditionalWeakTable<StatusEffect, IsSEReal> cwt_isReal = new ConditionalWeakTable<StatusEffect, IsSEReal>();

		internal static IsSEReal AttachIsSEReal(StatusEffect se, bool isReal)
		{
			return cwt_isReal.GetValue(se, (StatusEffect _) => new IsSEReal(isReal));
		}

		internal static bool TryGetIsSEReal(StatusEffect se, out IsSEReal isSEReal)
		{
			return cwt_isReal.TryGetValue(se, out isSEReal);
		}

		internal static IsSEReal GetIsSEReal(StatusEffect se)
		{
			if (cwt_isReal.TryGetValue(se, out var value))
			{
				return value;
			}
			return null;
		}
	}
	public class IsSEReal
	{
		public bool isReal;

		public IsSEReal(bool isReal)
		{
			this.isReal = isReal;
		}

		public static bool operator ==(IsSEReal a, IsSEReal b)
		{
			if ((object)a == b)
			{
				return true;
			}
			if ((object)a == null || (object)b == null)
			{
				return false;
			}
			return a.Equals(b);
		}

		public static bool operator !=(IsSEReal a, IsSEReal b)
		{
			return !(a == b);
		}

		public override bool Equals(object obj)
		{
			return obj is IsSEReal isSEReal && isReal == isSEReal.isReal;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(isReal);
		}
	}
}
namespace NoMetaScaling.Core.Trackers
{
	public static class ARTracker
	{
		[HarmonyPatch(typeof(ActionResolver), "Resolve")]
		private class Resolve_Patch
		{
			private static void Prefix(BattleAction root)
			{
				lastActionSource = root.Source;
			}

			private static IEnumerator<object> Postfix(IEnumerator<object> values)
			{
				while (values.MoveNext())
				{
					yield return values.Current;
				}
				BattleCWT.GetBanData(BattleCWT.Battle).FlushPendingBan();
				lastActionSource = null;
			}
		}

		[HarmonyPatch(typeof(ActionResolver), "InternalResolve")]
		private class InternalResolve_Patch
		{
			private static void Prefix(BattleAction action)
			{
				lastActionSource = action.Source;
			}
		}

		[HarmonyPatch(typeof(BattleController), "Leave")]
		private class BattleController_Patch
		{
			private static void Postfix()
			{
				lastActionSource = null;
			}
		}

		internal static GameEntity lastActionSource;
	}
	[HarmonyPatch]
	internal class AttachSourceToAfterUseActions_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			Type useCardDelegateType = typeof(UseCardAction).GetNestedTypes(AccessTools.allDeclared).Single((Type t) => t.Name.Contains("DisplayClass17_0"));
			yield return AccessTools.FirstMethod(useCardDelegateType, (Func<MethodInfo, bool>)((MethodInfo mi) => mi.Name.Contains("GetPhases>b__4")));
			Type playCardDelegateType = typeof(PlayCardAction).GetNestedTypes(AccessTools.allDeclared).Single((Type t) => t.Name.Contains("DisplayClass18_0"));
			yield return AccessTools.FirstMethod(playCardDelegateType, (Func<MethodInfo, bool>)((MethodInfo mi) => mi.Name.Contains("GetPhases>b__2")));
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase originalMethod)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			FieldInfo fieldInfo = originalMethod.DeclaringType.GetFields(AccessTools.allDeclared).First((FieldInfo f) => f.Name.Contains("this"));
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).Start();
			int num = 0;
			while (val.IsValid && num < 2)
			{
				val.MatchEndForward((CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Newobj && ci.operand is MethodBase methodBase && methodBase.DeclaringType == typeof(Reactor)), (string)null),
					CodeMatch.op_Implicit(OpCodes.Ldnull)
				});
				if (!val.IsValid)
				{
					break;
				}
				val.SetInstruction(new CodeInstruction(OpCodes.Ldarg_0, (object)null)).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo)
				})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AttachSourceToAfterUseActions_Patch), "GetArgsCard", (Type[])null, (Type[])null))
					});
				num++;
			}
			return val.InstructionEnumeration();
		}

		private static GameEntity GetArgsCard(BattleAction action)
		{
			UseCardAction val = (UseCardAction)(object)((action is UseCardAction) ? action : null);
			if (val != null)
			{
				return (GameEntity)(object)val.Args.Card;
			}
			PlayCardAction val2 = (PlayCardAction)(object)((action is PlayCardAction) ? action : null);
			if (val2 != null)
			{
				return (GameEntity)(object)val2.Args.Card;
			}
			return null;
		}
	}
	internal class PlayTwiceAction_Patch
	{
		private static void Postfix(PlayTwiceAction __instance, CardUsingEventArgs args)
		{
			((GameEventArgs)((EventBattleAction<CardUsingEventArgs>)(object)__instance).Args)._modifiers.AddRange(((GameEventArgs)args)._modifiers);
		}
	}
	internal class AttachSourceToPlayTwiceAction_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.FirstMethod(typeof(PlayTwiceAction), (Func<MethodInfo, bool>)((MethodInfo mi) => mi.Name.Contains("GetPhases>b__2_1")));
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase originalMethod)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).Start();
			val.MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(OpCodes.Ldnull) });
			val.SetInstruction(new CodeInstruction(OpCodes.Ldarg_0, (object)null)).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AttachSourceToPlayTwiceAction_Patch), "GetDoublePlaySource", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}

		private static GameEntity GetDoublePlaySource(PlayTwiceAction action)
		{
			CardUsingEventArgs args = ((EventBattleAction<CardUsingEventArgs>)(object)action).Args;
			WeakReference<GameEntity>? weakReference = ((GameEventArgs)args)._modifiers.LastOrDefault();
			if (weakReference != null)
			{
				weakReference.TryGetTarget(out var target);
				if (true)
				{
					Log.LogDebug(target);
					return target;
				}
			}
			return null;
		}
	}
	internal static class CopyTracker
	{
		[HarmonyPatch]
		private class CloneBattleCard_Patch
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(Card), "CloneBattleCard", (Type[])null, (Type[])null);
			}

			private static void Postfix(Card __instance, Card __result)
			{
				BattleCWT.CopyHistory.AddCopyPair(new CopyPair(__instance, __result));
			}
		}

		private class CloneTwiceToken_Patch
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(Card), "CloneTwiceToken", (Type[])null, (Type[])null);
			}

			private static void Postfix(Card __instance, Card __result)
			{
				if (__instance.IsBanned(out var _))
				{
					BattleCWT.GetBanData(BattleCWT.Battle).BanCard(__result, BanReason.CopySourceWasBanned);
				}
			}
		}
	}
	public class CopyHistory
	{
		private HashSet<CopyPair> cardsCopied = new HashSet<CopyPair>();

		public void AddCopyPair(CopyPair copyPair)
		{
			cardsCopied.Add(copyPair);
		}

		public bool WasCopied(Card potentialCopy, out CopyPair copyPair)
		{
			return cardsCopied.TryGetValue(new CopyPair(null, potentialCopy), out copyPair);
		}

		public bool IfWasCopiedForget(Card potentialCopy, out CopyPair copyPair)
		{
			bool flag = WasCopied(potentialCopy, out copyPair);
			if (flag)
			{
				cardsCopied.Remove(copyPair);
			}
			return flag;
		}
	}
	public struct CopyPair : IEquatable<CopyPair>
	{
		private readonly bool nonDefault;

		public Card original;

		public Card copy;

		public bool IsNonDefault => nonDefault;

		public CopyPair(Card original, Card copy)
		{
			this.original = original;
			this.copy = copy;
			nonDefault = true;
		}

		public bool Equals(CopyPair other)
		{
			return copy == other.copy;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine<bool, Card>(nonDefault, copy);
		}
	}
	public static class EchoTracker
	{
		[HarmonyPatch(typeof(Card), "EchoCloneAction")]
		private class EchoCloneAction_Patch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Expected O, but got Unknown
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Expected O, but got Unknown
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Expected O, but got Unknown
				return new CodeMatcher(instructions, (ILGenerator)null).MatchEndForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertySetter(typeof(Card), "IsEcho"), (string)null)
				}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null)
				}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(EchoCloneAction_Patch), "SetLastEcho", (Type[])null, (Type[])null))
				})
					.InstructionEnumeration();
			}

			private static void SetLastEcho(Card card)
			{
				lastEchoSource = card;
			}
		}

		[HarmonyPatch(typeof(BattleController), "Leave")]
		private class BattleController_Patch
		{
			private static void Postfix()
			{
				lastEchoSource = null;
			}
		}

		public static Card lastEchoSource;

		public static bool IsNaturalEcho(this Card card)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return card.IsUpgraded ? ((Enum)card.Config.UpgradedKeywords).HasFlag((Enum)(object)(Keyword)131072) : ((Enum)card.Config.Keywords).HasFlag((Enum)(object)(Keyword)131072);
		}

		public static bool IsNaturalPermaEcho(this Card card)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return card.IsUpgraded ? ((Enum)card.Config.UpgradedKeywords).HasFlag((Enum)(object)(Keyword)262144) : ((Enum)card.Config.Keywords).HasFlag((Enum)(object)(Keyword)262144);
		}

		public static bool InvokedEcho(this Card card)
		{
			return lastEchoSource == card;
		}
	}
}
namespace NoMetaScaling.Core.Loc
{
	public sealed class NoMoreMetaScalingLocSEDef : StatusEffectTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("NoMoreMetaScalingLocSE");
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)Statics.seBatchLoc.AddEntity((EntityDefinition)(object)this);
		}

		public override Sprite LoadSprite()
		{
			return null;
		}

		public override StatusEffectConfig MakeConfig()
		{
			return ((StatusEffectTemplate)this).DefaultConfig();
		}
	}
	[EntityLogic(typeof(NoMoreMetaScalingLocSEDef))]
	public sealed class NoMoreMetaScalingLocSE : StatusEffect
	{
		private static NoMoreMetaScalingLocSE _instance;

		public static NoMoreMetaScalingLocSE Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = Library.CreateStatusEffect<NoMoreMetaScalingLocSE>();
				}
				return _instance;
			}
		}

		public static string LocalizeProp(string key, bool decorate = false, bool required = true)
		{
			return ((GameEntity)Instance).LocalizeProperty(key, decorate, required);
		}

		public static string LocReason(BanReason reason)
		{
			return LocalizeProp($"Reason{reason}", decorate: true);
		}

		public static string GetBanChatString(GameEntity source, string cancelTarget, BanReason reason)
		{
			return string.Format(LocalizeProp("CancelExplain", decorate: true), cancelTarget, source.Name, LocReason(reason));
		}
	}
}
namespace NoMetaScaling.Core.Exhibits
{
	[OverwriteVanilla]
	public sealed class BirdFacedUrnDef : ExhibitTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("HuanxiangxiangYuanqi");
		}

		[DontOverwrite]
		public override LocalizationOption LoadLocalization()
		{
			throw new NotImplementedException();
		}

		[DontOverwrite]
		public override ExhibitSprites LoadSprite()
		{
			throw new NotImplementedException();
		}

		public override ExhibitConfig MakeConfig()
		{
			ExhibitConfig val = ObjectExtensions.Copy<ExhibitConfig>(ExhibitConfig.FromId("HuanxiangxiangYuanqi"));
			val.HasCounter = true;
			val.InitialCounter = 7;
			return val;
		}
	}
	[EntityLogic(typeof(BirdFacedUrnDef))]
	public sealed class HuanxiangxiangYuanqi : Exhibit
	{
		public const int counterMax = 7;

		public override string Description => string.Join("", ((Exhibit)this).Description, string.Format(NoMoreMetaScalingLocSE.LocalizeProp("UrnAppend", decorate: true), 7));

		protected override void OnEnterBattle()
		{
			((Exhibit)this).Counter = 7;
			((Exhibit)this).ReactBattleEvent<CardUsingEventArgs>(((Exhibit)this).Battle.CardUsed, (EventSequencedReactor<CardUsingEventArgs>)OnCardUsed);
		}

		protected override void OnLeaveBattle()
		{
			((Exhibit)this).Counter = 7;
		}

		private IEnumerable<BattleAction> OnCardUsed(CardUsingEventArgs args)
		{
			if ((int)args.Card.CardType == 4 && ((Exhibit)this).Counter > 0)
			{
				((Exhibit)this).NotifyActivating();
				int counter = ((Exhibit)this).Counter;
				((Exhibit)this).Counter = counter - 1;
				yield return (BattleAction)new HealAction((Unit)(object)((Exhibit)this).Owner, (Unit)(object)((Exhibit)this).Owner, ((Exhibit)this).Value1, (HealType)0, 0.2f);
			}
		}
	}
	[OverwriteVanilla]
	public sealed class ReimuRedOrbDef : ExhibitTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("ReimuR");
		}

		[DontOverwrite]
		public override LocalizationOption LoadLocalization()
		{
			throw new NotImplementedException();
		}

		[DontOverwrite]
		public override ExhibitSprites LoadSprite()
		{
			throw new NotImplementedException();
		}

		public override ExhibitConfig MakeConfig()
		{
			ExhibitConfig val = ObjectExtensions.Copy<ExhibitConfig>(ExhibitConfig.FromId("ReimuR"));
			val.HasCounter = true;
			val.InitialCounter = 9;
			return val;
		}
	}
	[EntityLogic(typeof(ReimuRedOrbDef))]
	public sealed class ReimuR : ShiningExhibit
	{
		public const int counterMax = 9;

		public override string Description => string.Join("", ((Exhibit)this).Description, string.Format(NoMoreMetaScalingLocSE.LocalizeProp("OrbAppend", decorate: true), 9));

		protected override void OnEnterBattle()
		{
			((Exhibit)this).Counter = 9;
			((Exhibit)this).ReactBattleEvent<DieEventArgs>(((Exhibit)this).Battle.EnemyDied, (EventSequencedReactor<DieEventArgs>)OnEnemyDied);
		}

		protected override void OnLeaveBattle()
		{
			((Exhibit)this).Counter = 9;
		}

		private IEnumerable<BattleAction> OnEnemyDied(DieEventArgs arg)
		{
			((Exhibit)this).NotifyActivating();
			if (!((Exhibit)this).Battle.BattleShouldEnd)
			{
				yield return (BattleAction)(object)new ApplyStatusEffectAction<Firepower>((Unit)(object)((Exhibit)this).Owner, (int?)((Exhibit)this).Value1, (int?)null, (int?)null, (int?)null, 0f, true);
			}
			if (((Exhibit)this).Counter > 0)
			{
				int counter = ((Exhibit)this).Counter;
				((Exhibit)this).Counter = counter - 1;
				yield return (BattleAction)new HealAction((Unit)(object)((Exhibit)this).Owner, (Unit)(object)((Exhibit)this).Owner, ((Exhibit)this).Value2, (HealType)0, 0.2f);
			}
		}
	}
}
namespace NoMetaScaling.Core.Exceptions
{
	[HarmonyPatch(typeof(ShenlingHp), "OnEnemyDied")]
	internal class ShenlingHp_Patch
	{
		private static void Prefix(ShenlingHp __instance)
		{
			ARTracker.lastActionSource = (GameEntity)(object)__instance;
		}
	}
	[HarmonyPatch]
	internal class ShenlingGold_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.FirstMethod(typeof(ShenlingGold), (Func<MethodInfo, bool>)((MethodInfo mi) => mi.Name.Contains("<OnAdded>")));
		}

		private static void Prefix(ShenlingGold __instance)
		{
			ARTracker.lastActionSource = (GameEntity)(object)__instance;
		}
	}
}
namespace NoMetaScaling.Core.EnemyGroups
{
	public static class EnemyGroupHandlers
	{
		public static void RegisterHandlers()
		{
			NoMetaScalinAPI.AddOrOverwriteSummoner("Rin", 21);
			NoMetaScalinAPI.AddOrOverwriteSummoner("Kokoro", 9);
			NoMetaScalinAPI.AddOrOverwriteSummoner("Clownpiece", 3);
			CHandlerManager.RegisterBattleEventHandler<GameEventArgs>((EventProvider<GameEventArgs, BattleController>)((BattleController bt) => bt.BattleStarted), (GameEventHandler<GameEventArgs>)OnBattleStarted, (Predicate<BattleController>)null, (GameEventPriority)10);
		}

		private static void OnBattleStarted(GameEventArgs args)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			BattleController battle = Singleton<GameMaster>.Instance.CurrentGameRun.Battle;
			IEnumerable<EnemyUnit> enumerable = battle.AllAliveEnemies.Where((EnemyUnit e) => ExposedStatics.summonerInfo.ContainsKey(((GameEntity)e).Id));
			foreach (EnemyUnit item in enumerable)
			{
				int limit = ExposedStatics.summonerInfo[((GameEntity)item).Id].limit;
				if (limit >= 0)
				{
					battle.React(Reactor.op_Implicit((BattleAction)new ApplySEnoTriggers(typeof(MaxSummonsSE), (Unit)(object)item, (int?)limit, (int?)null, (int?)null, (int?)null, 0f, true)), (GameEntity)null, (ActionCause)0);
				}
			}
		}
	}
	public struct SummonerInfo
	{
		public string id;

		public int limit;

		public SummonerInfo(string id, int limit)
		{
			this.id = id;
			this.limit = limit;
		}
	}
	public sealed class MaxSummonsSEDef : StatusEffectTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("MaxSummonsSE");
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)Statics.seBatchLoc.AddEntity((EntityDefinition)(object)this);
		}

		public override Sprite LoadSprite()
		{
			return ResourcesHelper.TryGetSprite<StatusEffect>("MoreFriendsSe");
		}

		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig val = ((StatusEffectTemplate)this).DefaultConfig();
			val.Type = (StatusEffectType)2;
			val.HasLevel = true;
			val.LevelStackType = (StackType)0;
			return val;
		}
	}
	[EntityLogic(typeof(MaxSummonsSEDef))]
	public sealed class MaxSummonsSE : StatusEffect
	{
		public override string Description => (((StatusEffect)this).Battle == null || ((StatusEffect)this).Level == 0) ? ((GameEntity)this).LocalizeProperty("NoLevelDesc", true, true) : ((GameEntity)this).Description;

		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ReactOwnerEvent<UnitEventArgs>(((StatusEffect)this).Battle.EnemySpawned, (EventSequencedReactor<UnitEventArgs>)OnFirstSpawns);
		}

		private IEnumerable<BattleAction> OnFirstSpawns(UnitEventArgs args)
		{
			if (((GameEventArgs)args).ActionSource == ((StatusEffect)this).Owner)
			{
				if (((StatusEffect)this).Level > 0)
				{
					((StatusEffect)this).Level = Math.Max(((StatusEffect)this).Level - 1, 0);
				}
				else
				{
					yield return (BattleAction)(object)new ApplyStatusEffectAction<NoPointSummonSE>(args.Unit, (int?)null, (int?)null, (int?)null, (int?)null, 0f, true);
				}
			}
		}
	}
	public sealed class NoPointSummonSEDef : StatusEffectTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("NoPointSummonSE");
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)Statics.seBatchLoc.AddEntity((EntityDefinition)(object)this);
		}

		public override Sprite LoadSprite()
		{
			return ResourcesHelper.TryGetSprite<StatusEffect>("MoreFriendsSe");
		}

		public override StatusEffectConfig MakeConfig()
		{
			StatusEffectConfig val = ((StatusEffectTemplate)this).DefaultConfig();
			val.Type = (StatusEffectType)2;
			val.HasLevel = false;
			return val;
		}
	}
	[EntityLogic(typeof(NoPointSummonSEDef))]
	public sealed class NoPointSummonSE : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).HandleOwnerEvent<DieEventArgs>(((StatusEffect)this).Battle.EnemyPointGenerating, (GameEventHandler<DieEventArgs>)OnPointGenerating, (GameEventPriority)int.MaxValue);
		}

		private void OnPointGenerating(DieEventArgs args)
		{
			Unit unit = args.Unit;
			if (unit == ((StatusEffect)this).Owner && unit.HasStatusEffect<Servant>())
			{
				args.Power = 0;
				args.Money = 0;
				args.BluePoint = 0;
			}
		}
	}
}
namespace NoMetaScaling.Core.API
{
	internal static class ExposedStatics
	{
		internal static Dictionary<string, SummonerInfo> summonerInfo = new Dictionary<string, SummonerInfo>();

		internal static HashSet<string> splitableSE_CARD_ids = new HashSet<string> { "RangziFanshu", "MeihongPower" };

		internal static HashSet<string> alwaysBanned = new HashSet<string> { "JinziDoppelganger" };

		internal static HashSet<string> exemptFromGenBan = new HashSet<string>();

		internal static HashSet<string> exemptFromPlayBan = new HashSet<string>();
	}
	internal class GrCWT
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPriority(600)]
		private class GameRunController_Patch
		{
			private static void Prefix(GameRunController __instance)
			{
				GetGrState(__instance);
				gr_ref = new WeakReference<GameRunController>(__instance);
			}
		}

		private static ConditionalWeakTable<GameRunController, GrState> cwt_grState = new ConditionalWeakTable<GameRunController, GrState>();

		private static WeakReference<GameRunController> gr_ref;

		public static GameRunController GR
		{
			[return: MaybeNull]
			get
			{
				GameMaster instance = Singleton<GameMaster>.Instance;
				GameRunController target = ((instance != null) ? instance.CurrentGameRun : null);
				if (target == null)
				{
					gr_ref.TryGetTarget(out target);
				}
				return target;
			}
		}

		internal static GrState GetGrState(GameRunController gr)
		{
			return cwt_grState.GetOrCreateValue(gr);
		}
	}
	public class GrState
	{
		public bool cancelEnnabled = true;
	}
	public class GrStateContainer : CustomGameRunSaveData
	{
		public bool cancelEnnabled;

		public override void Restore(GameRunController gameRun)
		{
			GrCWT.GetGrState(gameRun).cancelEnnabled = cancelEnnabled;
		}

		public override void Save(GameRunController gameRun)
		{
			cancelEnnabled = GrCWT.GetGrState(gameRun).cancelEnnabled;
		}
	}
	public class NoMetaScalinAPI
	{
		public const string GUID = "neo.lbol.modifiers.noMetaScaling";

		public static void AddBanByDefault(string cardId)
		{
			ExposedStatics.alwaysBanned.Add(cardId);
		}

		public static void AddOrOverwriteSummoner(string summonerId, int summonLimit)
		{
			DictionaryExtensions.AlwaysAdd<string, SummonerInfo>(ExposedStatics.summonerInfo, summonerId, new SummonerInfo(summonerId, summonLimit));
		}

		public static void SelectivelyBanMetaScalingSatusEffect(string se_CARD_ID)
		{
			ExposedStatics.splitableSE_CARD_ids.Add(se_CARD_ID);
		}

		public static void ExemptFromBanIfGenerated(string cardId)
		{
			ExposedStatics.exemptFromGenBan.Add(cardId);
		}

		public static void ExemptFromBanIfPlayed(string cardId)
		{
			ExposedStatics.exemptFromPlayBan.Add(cardId);
		}

		public static bool GetCancelEnnabled(GameRunController gr)
		{
			if (gr == null)
			{
				throw new ArgumentNullException("Trying to GetCancelEnnabled while not in GameRun (gr is null).");
			}
			return GrCWT.GetGrState(gr).cancelEnnabled;
		}

		public static void SetCancelEnnabled(GameRunController gr, bool value)
		{
			if (gr == null)
			{
				throw new ArgumentNullException("Trying to SetCancelEnnabled while not in GameRun (gr is null).");
			}
			GrCWT.GetGrState(gr).cancelEnnabled = value;
		}

		public static GameRunController GetRealGR()
		{
			return GrCWT.GR;
		}
	}
}
namespace NoMetaScalling
{
	[BepInPlugin("neo.lbol.modifiers.noMetaScaling", "No More Meta scaling", "1.1.8")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		private static readonly Harmony harmony = PInfo.harmony;

		internal static ManualLogSource log;

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			PConfig.DoBinds(((BaseUnityPlugin)this).Config);
			EntityManager.RegisterSelf();
			harmony.PatchAll();
			if (Chainloader.PluginInfos.ContainsKey("neo.lbol.tools.watermark"))
			{
				WatermarkWrapper.ActivateWatermark();
			}
			CardFilter.RegisterHandlers();
			ActionCancel.RegisterHandlers();
			EnemyGroupHandlers.RegisterHandlers();
			((CustomGameRunSaveData)new GrStateContainer()).RegisterSelf("neo.lbol.modifiers.noMetaScaling");
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource log = BepinexPlugin.log;

		internal static void LogMessage(object data)
		{
			log.LogMessage(data);
		}

		internal static void LogInfo(object data)
		{
			log.LogInfo(data);
		}

		internal static void LogDebug(object data)
		{
			log.LogDebug(data);
		}

		internal static void LogWarning(object data)
		{
			log.LogWarning(data);
		}

		internal static void LogError(object data)
		{
			log.LogError(data);
		}

		internal static void LogFatal(object data)
		{
			log.LogFatal(data);
		}
	}
	public static class PInfo
	{
		public const string GUID = "neo.lbol.modifiers.noMetaScaling";

		public const string Name = "No More Meta scaling";

		public const string version = "1.1.8";

		public static readonly Harmony harmony = new Harmony("neo.lbol.modifiers.noMetaScaling");
	}
	internal class WatermarkWrapper
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void ActivateWatermark()
		{
			API.ActivateWatermark();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}