Decompiled source of CyanToolbox v0.3.3

CyanToolbox.dll

Decompiled a month ago
using System;
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 AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HarmonyLib;
using LBoL.Base;
using LBoL.Base.Extensions;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Adventures;
using LBoL.Core.Battle;
using LBoL.Core.Battle.BattleActions;
using LBoL.Core.Cards;
using LBoL.Core.Randoms;
using LBoL.Core.StatusEffects;
using LBoL.Core.Units;
using LBoL.EntityLib.Adventures;
using LBoL.EntityLib.EnemyUnits.Character;
using LBoL.EntityLib.Exhibits.Adventure;
using LBoL.EntityLib.StatusEffects.Basic;
using LBoL.Presentation.UI.Panels;
using LBoL.Presentation.UI.Widgets;
using LBoL.Presentation.Units;
using LBoLEntitySideloader;
using LBoLEntitySideloader.Attributes;
using LBoLEntitySideloader.Entities;
using LBoLEntitySideloader.Resource;
using LBoLEntitySideloader.Utils;
using UnityEngine;
using UnityEngine.Events;
using Yarn;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[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("CyanToolbox")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CyanToolbox")]
[assembly: AssemblyTitle("CyanToolbox")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace CyanToolbox
{
	[BepInPlugin("cyaneko.lbol.mods.toolbox", "CyanToolbox", "0.3.3")]
	[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;

		internal static IResourceSource embeddedSource = (IResourceSource)new EmbeddedSource(Assembly.GetExecutingAssembly());

		internal static TemplateSequenceTable sequenceTable = new TemplateSequenceTable(0);

		internal static DirectorySource directorySource = new DirectorySource("cyaneko.lbol.mods.toolbox", "");

		internal static BatchLocalization jadeboxLoc = new BatchLocalization((IResourceSource)(object)directorySource, typeof(JadeBoxTemplate), "Jadeboxes", (Locale)0, false);

		internal static BatchLocalization seLoc = new BatchLocalization((IResourceSource)(object)directorySource, typeof(StatusEffectTemplate), "StatusEffects", (Locale)0, false);

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			EntityManager.RegisterSelf();
			harmony.PatchAll();
			if (Chainloader.PluginInfos.ContainsKey("neo.lbol.tools.watermark"))
			{
				WatermarkWrapper.ActivateWatermark();
			}
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public static class PInfo
	{
		public const string GUID = "cyaneko.lbol.mods.toolbox";

		public const string Name = "CyanToolbox";

		public const string version = "0.3.3";

		public static readonly Harmony harmony = new Harmony("cyaneko.lbol.mods.toolbox");
	}
	internal class WatermarkWrapper
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void ActivateWatermark()
		{
			API.ActivateWatermark();
		}
	}
}
namespace CyanToolbox.JadeBoxes
{
	public sealed class DoubleTroubleDef : JadeBoxTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("DoubleTroubleJadebox");
		}

		public override JadeBoxConfig MakeConfig()
		{
			return ((JadeBoxTemplate)this).DefaultConfig();
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)BepinexPlugin.jadeboxLoc.AddEntity((EntityDefinition)(object)this);
		}
	}
	[EntityLogic(typeof(DoubleTroubleDef))]
	public sealed class DoubleTroubleJadebox : JadeBox
	{
		private readonly Type[] AllBosses = new Type[3]
		{
			typeof(Sanae),
			typeof(Junko),
			typeof(Remilia)
		};

		protected override void OnEnterBattle()
		{
			((JadeBox)this).ReactBattleEvent<GameEventArgs>(((JadeBox)this).Battle.BattleStarting, (EventSequencedReactor<GameEventArgs>)OnBattleStarting);
		}

		private IEnumerable<BattleAction> OnBattleStarting(GameEventArgs args)
		{
			EnemyUnit enemyByRootIndex = ((JadeBox)this).Battle.GetEnemyByRootIndex(0);
			if (enemyByRootIndex == null)
			{
				yield break;
			}
			Type rootEnemyType = ((object)enemyByRootIndex).GetType();
			if (!AllBosses.Contains(rootEnemyType))
			{
				yield break;
			}
			((JadeBox)this).NotifyActivating();
			GameDirector.ActiveFormation = "Shu";
			Type type = CollectionsExtensions.Sample<Type>(AllBosses.Where((Type boss) => boss != rootEnemyType), ((GameEntity)this).GameRun.EnemyBattleRng);
			yield return (BattleAction)new SpawnEnemyAction(enemyByRootIndex, type, 1, 0f, 0.3f, false);
			EnemyFormation ef = Singleton<GameDirector>.Instance.Formations[GameDirector.ActiveFormation];
			int i = 0;
			while (i < ef.enemyLocations.Count)
			{
				EnemyUnit enemy = ((JadeBox)this).Battle.GetEnemyByRootIndex(i);
				if (enemy != null)
				{
					yield return (BattleAction)(object)new ApplyStatusEffectAction<StrengthSuppressionSe>((Unit)(object)enemy, (int?)null, (int?)null, (int?)null, (int?)null, 0f, true);
					IEnemyUnitView view = enemy.View;
					IEnemyUnitView obj = ((view is UnitView) ? view : null);
					if (obj != null)
					{
						TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOMove(((Component)obj).transform, ((Component)ef.enemyLocations[i]).transform.position, 0.8f, false), (Ease)6);
					}
					if (obj != null)
					{
						TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(((Component)obj).transform, 0.8f, 0.8f), (Ease)6);
					}
				}
				int num = i + 1;
				i = num;
			}
		}
	}
	public sealed class StrengthSuppressionDef : StatusEffectTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("StrengthSuppressionSe");
		}

		public override StatusEffectConfig MakeConfig()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			return new StatusEffectConfig(0, "", 8, (StatusEffectType)2, false, false, (int?)null, false, (StackType?)(StackType)0, false, (StackType?)(StackType)0, (DurationDecreaseTiming)0, false, (StackType?)(StackType)3, (StackType?)(StackType)3, false, (Keyword)0, (IReadOnlyList<string>)new List<string>(), "DebuffBlack", "DebuffBlack", "Debuff");
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)BepinexPlugin.seLoc.AddEntity((EntityDefinition)(object)this);
		}

		public override Sprite LoadSprite()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ResourceLoader.LoadSprite(IdContainer.op_Implicit(((EntityDefinition)this).GetId()) + ".png", (IResourceSource)(object)BepinexPlugin.directorySource, (Rect?)null, 1, (Vector2?)null);
		}
	}
	[EntityLogic(typeof(StrengthSuppressionDef))]
	[HarmonyPatch]
	public sealed class StrengthSuppressionSe : StatusEffect
	{
		protected override void OnAdded(Unit unit)
		{
			((StatusEffect)this).ShowCount = false;
			((StatusEffect)this).HandleOwnerEvent<DamageDealingEventArgs>(unit.DamageDealing, (GameEventHandler<DamageDealingEventArgs>)OnDamageDealing);
			((StatusEffect)this).ReactOwnerEvent<DieEventArgs>(((StatusEffect)this).Battle.EnemyDied, (EventSequencedReactor<DieEventArgs>)OnEnemyDied);
		}

		private void OnDamageDealing(DamageDealingEventArgs args)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			DamageInfo damageInfo = args.DamageInfo;
			if ((int)((DamageInfo)(ref damageInfo)).DamageType == 2)
			{
				((DamageInfo)(ref damageInfo)).Damage = ((DamageInfo)(ref damageInfo)).Amount * 0.5f;
				args.DamageInfo = damageInfo;
				((GameEventArgs)args).AddModifier((GameEntity)(object)this);
			}
		}

		private IEnumerable<BattleAction> OnEnemyDied(DieEventArgs args)
		{
			if (((StatusEffect)this).Battle.BattleShouldEnd)
			{
				yield break;
			}
			foreach (StrengthSuppressionSe item in from e in ((StatusEffect)this).Battle.AllAliveEnemies
				select ((Unit)e).GetStatusEffect<StrengthSuppressionSe>() into se
				where se != null
				select se)
			{
				yield return (BattleAction)new RemoveStatusEffectAction((StatusEffect)(object)item, true, 0f);
			}
		}
	}
	public sealed class HighlanderDef : JadeBoxTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("HighlanderJadebox");
		}

		public override JadeBoxConfig MakeConfig()
		{
			return ((JadeBoxTemplate)this).DefaultConfig();
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)BepinexPlugin.jadeboxLoc.AddEntity((EntityDefinition)(object)this);
		}
	}
	[EntityLogic(typeof(HighlanderDef))]
	public sealed class HighlanderJadebox : JadeBox
	{
		[HarmonyPatch(typeof(GameRunController), "RollCards", new Type[]
		{
			typeof(RandomGen),
			typeof(CardWeightTable),
			typeof(int),
			typeof(ManaGroup?),
			typeof(bool),
			typeof(bool),
			typeof(bool),
			typeof(bool),
			typeof(Predicate<CardConfig>)
		})]
		private class GameRunController_RollCards
		{
			private static void Prefix(ref bool battleRolling, ref Predicate<CardConfig> filter, GameRunController __instance)
			{
				if (IsHighlander(__instance) && !battleRolling)
				{
					Predicate<CardConfig> predCopy = filter;
					filter = (CardConfig cfg) => AlsoAbsentFromLibrary(__instance, predCopy, cfg);
				}
			}
		}

		public static bool IsHighlander(GameRunController run)
		{
			if (run == null)
			{
				return false;
			}
			return run.HasJadeBox<HighlanderJadebox>();
		}

		public static bool AlsoAbsentFromLibrary(GameRunController run, Predicate<CardConfig> prevPred, CardConfig cardCfg)
		{
			if (prevPred == null || prevPred(cardCfg))
			{
				return !run.BaseDeck.Any((Card card) => card.Config.Id == cardCfg.Id);
			}
			return false;
		}
	}
	public sealed class MillennialRevelationDef : JadeBoxTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("MillennialRevelationJadebox");
		}

		public override JadeBoxConfig MakeConfig()
		{
			return ((JadeBoxTemplate)this).DefaultConfig();
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)BepinexPlugin.jadeboxLoc.AddEntity((EntityDefinition)(object)this);
		}
	}
	[EntityLogic(typeof(MillennialRevelationDef))]
	public sealed class MillennialRevelationJadebox : JadeBox
	{
		private bool DrawStep;

		protected override void OnEnterBattle()
		{
			((JadeBox)this).HandleBattleEvent<UnitEventArgs>(((Unit)((JadeBox)this).Battle.Player).TurnStarting, (GameEventHandler<UnitEventArgs>)OnPreTurnStart);
			((JadeBox)this).HandleBattleEvent<UnitEventArgs>(((Unit)((JadeBox)this).Battle.Player).TurnStarted, (GameEventHandler<UnitEventArgs>)OnPostTurnStart);
			((JadeBox)this).HandleBattleEvent<CardEventArgs>(((JadeBox)this).Battle.Predraw, (GameEventHandler<CardEventArgs>)OnPredraw);
		}

		private void OnPreTurnStart(UnitEventArgs args)
		{
			DrawStep = true;
			((JadeBox)this).Battle.DrawCardCount = ((JadeBox)this).Battle.MaxHand - ((JadeBox)this).Battle.HandZone.Count;
		}

		private void OnPostTurnStart(UnitEventArgs args)
		{
			DrawStep = false;
		}

		private void OnPredraw(CardEventArgs args)
		{
			if (!DrawStep)
			{
				((JadeBox)this).NotifyActivating();
				((GameEventArgs)args).CancelBy((GameEntity)(object)this);
			}
		}
	}
	public sealed class NightOfNightmaresDef : JadeBoxTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("NightOfNightmaresJadebox");
		}

		public override JadeBoxConfig MakeConfig()
		{
			return ((JadeBoxTemplate)this).DefaultConfig();
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)BepinexPlugin.jadeboxLoc.AddEntity((EntityDefinition)(object)this);
		}
	}
	[EntityLogic(typeof(NightOfNightmaresDef))]
	public sealed class NightOfNightmaresJadebox : JadeBox
	{
		[HarmonyPatch(typeof(ManaFreezer))]
		private class ManaFreezer_FreezeLevel
		{
			[HarmonyPatch(/*Could not decode attribute arguments.*/)]
			[HarmonyPostfix]
			private static void GetFreezeLevel(ManaFreezer __instance, ref int __result)
			{
				if (IsNightOfNightmares(((GameEntity)__instance).GameRun))
				{
					if (__instance is NightMana1)
					{
						__result = 1;
					}
					else if (__instance is NightMana2)
					{
						__result = 2;
					}
					else if (__instance is NightMana3 || __instance is NightMana4)
					{
						__result = 3;
					}
				}
			}
		}

		[HarmonyPatch(typeof(BattleController))]
		private class BattleController_OnAddCardToHand
		{
			[HarmonyPatch("AddCardToHand", new Type[] { typeof(Card) })]
			[HarmonyPostfix]
			private static void SetFreezeTimes(BattleController __instance, ref Card card)
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				if (!IsNightOfNightmares(__instance.GameRun))
				{
					return;
				}
				Card obj = card;
				ManaFreezer val = (ManaFreezer)(object)((obj is ManaFreezer) ? obj : null);
				if (val != null)
				{
					CardConfig val2 = ObjectExtensions.Copy<CardConfig>(((Card)val).Config);
					if (val is NightMana1)
					{
						val2.Mana = ManaGroup.Anys(1);
					}
					else if (val is NightMana2)
					{
						val2.Mana = ManaGroup.Anys(2);
					}
					else if (val is NightMana3 || val is NightMana4)
					{
						val2.Mana = ManaGroup.Anys(3);
					}
					val.FreezeTimes = 1;
					((Card)val).Config = val2;
				}
			}
		}

		[HarmonyPatch(typeof(StartGamePanel))]
		private class StartGamePanel_Awake_Patch
		{
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void EnsureLongNightIsOn(ref StartGamePanel __instance)
			{
				try
				{
					StartGamePanel sgp = __instance;
					JadeBoxToggle jt = sgp._jadeBoxToggles.FirstOrDefault((KeyValuePair<JadeBox, JadeBoxToggle> t) => t.Value.JadeBox is NightOfNightmaresJadebox).Value;
					JadeBoxToggle obj = jt;
					if (obj == null)
					{
						return;
					}
					((UnityEvent<bool>)(object)obj.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate
					{
						if (jt.IsOn && (!sgp._puzzleToggles.TryGetValue((PuzzleFlag)64, out var value) || !value.Toggle.isOn))
						{
							jt.Toggle.isOn = false;
						}
					});
				}
				catch (Exception arg)
				{
					BepinexPlugin.log.LogError((object)$"Error while checking jadebox toggle and puzzle flags compat\n{arg}");
				}
			}
		}

		public static bool IsNightOfNightmares(GameRunController run)
		{
			if (run == null)
			{
				return false;
			}
			return run.HasJadeBox<NightOfNightmaresJadebox>();
		}
	}
	public sealed class RainbowCardsDef : JadeBoxTemplate
	{
		public const int ExtraCards = 1;

		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("RainbowCardsJadebox");
		}

		public override JadeBoxConfig MakeConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			JadeBoxConfig obj = ((JadeBoxTemplate)this).DefaultConfig();
			obj.Value1 = 1;
			obj.Mana = ManaGroup.Single((ManaColor)7);
			return obj;
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)BepinexPlugin.jadeboxLoc.AddEntity((EntityDefinition)(object)this);
		}
	}
	[EntityLogic(typeof(RainbowCardsDef))]
	public sealed class RainbowCardsJadebox : JadeBox
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private class GameRunController_ctor
		{
			private static void Postfix(GameRunStartupParameters startupParameters, GameRunController __instance)
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: 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_0078: Unknown result type (might be due to invalid IL or missing references)
				if (__instance.HasJadeBox<RainbowCardsJadebox>())
				{
					__instance.RewardAndShopCardColorLimitFlag += 1;
					__instance.AdditionalRewardCardCount += 1;
					initialExhibit = startupParameters.InitExhibit;
					if (startupParameters.Player.Config.InitialMana + BaseManaGroup.op_Implicit(initialExhibit.BaseMana) == __instance.BaseMana)
					{
						__instance.GainBaseMana(ManaGroup.Single((ManaColor)7), false);
						__instance.LoseBaseMana(BaseManaGroup.op_Implicit(initialExhibit.BaseMana), false);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Debut), "InitVariables", new Type[] { typeof(IVariableStorage) })]
		private class Debut_InitVariables
		{
			private static void Postfix(Debut __instance, IVariableStorage storage)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				GameRunController gameRun = ((Adventure)__instance).GameRun;
				if (gameRun.HasJadeBox<RainbowCardsJadebox>())
				{
					ManaGroup baseMana = gameRun.BaseMana;
					if (initialExhibit == null || !ManaGroupExtensions.IsSuperset(baseMana, BaseManaGroup.op_Implicit(initialExhibit.BaseMana)))
					{
						storage.SetValue("$twoColorStart", true);
					}
				}
			}
		}

		private static Exhibit initialExhibit;
	}
	public sealed class RustyBatteryDef : JadeBoxTemplate
	{
		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("RustyBatteryJadebox");
		}

		public override JadeBoxConfig MakeConfig()
		{
			return ((JadeBoxTemplate)this).DefaultConfig();
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)BepinexPlugin.jadeboxLoc.AddEntity((EntityDefinition)(object)this);
		}
	}
	[EntityLogic(typeof(RustyBatteryDef))]
	public sealed class RustyBatteryJadebox : JadeBox
	{
		[HarmonyPatch]
		private class UltimateSkill_MaxPowerLevel
		{
			[HarmonyPatch(/*Could not decode attribute arguments.*/)]
			[HarmonyPostfix]
			private static void GetLevel(UltimateSkill __instance, ref int __result)
			{
				if (IsRustyBattery(((GameEntity)__instance).GameRun))
				{
					__result = Math.Max(__result - 1, 1);
				}
			}

			[HarmonyPatch(typeof(JuanzengZhengming), "OnAdded")]
			[HarmonyPrefix]
			private static bool SetLevelFix(JuanzengZhengming __instance, PlayerUnit player)
			{
				if (IsRustyBattery(((GameEntity)player).GameRun))
				{
					UltimateSkill us = player.Us;
					us.MaxPowerLevel += ((Exhibit)__instance).Value1 + 1;
					player.Us.UsRepeatableType = (UsRepeatableType)0;
					return false;
				}
				return true;
			}
		}

		public static bool IsRustyBattery(GameRunController run)
		{
			if (run == null)
			{
				return false;
			}
			return run.HasJadeBox<RustyBatteryJadebox>();
		}
	}
	public sealed class ThunderlordDef : JadeBoxTemplate
	{
		private const int PlayerBuffMultiplier = 2;

		private const int EnemyBuffMultiplier = 1;

		private const int BuffCap = 3;

		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("ThunderlordJadebox");
		}

		public override JadeBoxConfig MakeConfig()
		{
			JadeBoxConfig obj = ((JadeBoxTemplate)this).DefaultConfig();
			obj.Value1 = 2;
			obj.Value2 = 1;
			obj.Value3 = 3;
			return obj;
		}

		public override LocalizationOption LoadLocalization()
		{
			return (LocalizationOption)(object)BepinexPlugin.jadeboxLoc.AddEntity((EntityDefinition)(object)this);
		}
	}
	[EntityLogic(typeof(ThunderlordDef))]
	public sealed class ThunderlordJadebox : JadeBox
	{
		protected override void OnEnterBattle()
		{
			((JadeBox)this).ReactBattleEvent<GameEventArgs>(((JadeBox)this).Battle.BattleStarting, (EventSequencedReactor<GameEventArgs>)OnBattleStarting);
			((JadeBox)this).ReactBattleEvent<UnitEventArgs>(((JadeBox)this).Battle.EnemySpawned, (EventSequencedReactor<UnitEventArgs>)OnEnemySpawned);
		}

		private int GetBuffLevel(int actNum)
		{
			return Math.Min(actNum, ((JadeBox)this).Value3);
		}

		private IEnumerable<BattleAction> OnBattleStarting(GameEventArgs args)
		{
			((JadeBox)this).NotifyActivating();
			int actNum = ((GameEntity)this).GameRun._stageIndex + 1;
			yield return (BattleAction)(object)new ApplyStatusEffectAction<Electric>((Unit)(object)((JadeBox)this).Battle.Player, (int?)(((JadeBox)this).Value1 * GetBuffLevel(actNum)), (int?)null, (int?)null, (int?)null, 0f, true);
			foreach (EnemyUnit allAliveEnemy in ((JadeBox)this).Battle.AllAliveEnemies)
			{
				yield return (BattleAction)(object)new ApplyStatusEffectAction<Electric>((Unit)(object)allAliveEnemy, (int?)(((JadeBox)this).Value2 * GetBuffLevel(actNum)), (int?)null, (int?)null, (int?)null, 0f, true);
			}
		}

		private IEnumerable<BattleAction> OnEnemySpawned(UnitEventArgs args)
		{
			((JadeBox)this).NotifyActivating();
			int actNum = ((GameEntity)this).GameRun._stageIndex + 1;
			yield return (BattleAction)(object)new ApplyStatusEffectAction<Electric>(args.Unit, (int?)(((JadeBox)this).Value2 * GetBuffLevel(actNum)), (int?)null, (int?)null, (int?)null, 0f, true);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}