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 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.4.0")]
[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.4.0";
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
{
[CompilerGenerated]
private sealed class <>c__DisplayClass2_0
{
public Type rootEnemyType;
internal bool <OnBattleStarting>b__0(Type boss)
{
return boss != rootEnemyType;
}
}
[CompilerGenerated]
private sealed class <OnBattleStarting>d__2 : IEnumerable<BattleAction>, IEnumerable, IEnumerator<BattleAction>, IEnumerator, IDisposable
{
private int <>1__state;
private BattleAction <>2__current;
private int <>l__initialThreadId;
public DoubleTroubleJadebox <>4__this;
private EnemyFormation <ef>5__2;
private int <i>5__3;
private EnemyUnit <enemy>5__4;
BattleAction IEnumerator<BattleAction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OnBattleStarting>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<ef>5__2 = null;
<enemy>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
int num = <>1__state;
DoubleTroubleJadebox doubleTroubleJadebox = <>4__this;
int num2;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
EnemyUnit enemyByRootIndex = ((JadeBox)doubleTroubleJadebox).Battle.GetEnemyByRootIndex(0);
if (enemyByRootIndex == null)
{
break;
}
<>c__DisplayClass2_0 CS$<>8__locals0 = new <>c__DisplayClass2_0
{
rootEnemyType = ((object)enemyByRootIndex).GetType()
};
if (doubleTroubleJadebox.AllBosses.Contains(CS$<>8__locals0.rootEnemyType))
{
((JadeBox)doubleTroubleJadebox).NotifyActivating();
GameDirector.ActiveFormation = "Shu";
Type type = CollectionsExtensions.Sample<Type>(doubleTroubleJadebox.AllBosses.Where((Type boss) => boss != CS$<>8__locals0.rootEnemyType), ((GameEntity)doubleTroubleJadebox).GameRun.EnemyBattleRng);
<>2__current = (BattleAction)new SpawnEnemyAction(enemyByRootIndex, type, 1, 0f, 0.3f, false);
<>1__state = 1;
return true;
}
break;
}
case 1:
<>1__state = -1;
<ef>5__2 = Singleton<GameDirector>.Instance.Formations[GameDirector.ActiveFormation];
<i>5__3 = 0;
goto IL_01e6;
case 2:
{
<>1__state = -1;
IEnemyUnitView view = <enemy>5__4.View;
IEnemyUnitView obj = ((view is UnitView) ? view : null);
if (obj != null)
{
TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOMove(((Component)obj).transform, ((Component)<ef>5__2.enemyLocations[<i>5__3]).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);
}
goto IL_01cd;
}
IL_01cd:
<enemy>5__4 = null;
num2 = <i>5__3 + 1;
<i>5__3 = num2;
goto IL_01e6;
IL_01e6:
if (<i>5__3 < <ef>5__2.enemyLocations.Count)
{
<enemy>5__4 = ((JadeBox)doubleTroubleJadebox).Battle.GetEnemyByRootIndex(<i>5__3);
if (<enemy>5__4 != null)
{
<>2__current = (BattleAction)(object)new ApplyStatusEffectAction<StrengthSuppressionSe>((Unit)(object)<enemy>5__4, (int?)null, (int?)null, (int?)null, (int?)null, 0f, true);
<>1__state = 2;
return true;
}
goto IL_01cd;
}
<ef>5__2 = null;
break;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<BattleAction> IEnumerable<BattleAction>.GetEnumerator()
{
<OnBattleStarting>d__2 result;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
result = this;
}
else
{
result = new <OnBattleStarting>d__2(0)
{
<>4__this = <>4__this
};
}
return result;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<BattleAction>)this).GetEnumerator();
}
}
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);
}
[IteratorStateMachine(typeof(<OnBattleStarting>d__2))]
private IEnumerable<BattleAction> OnBattleStarting(GameEventArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OnBattleStarting>d__2(-2)
{
<>4__this = this
};
}
}
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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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>(), (string)null, "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
{
[CompilerGenerated]
private sealed class <OnEnemyDied>d__2 : IEnumerable<BattleAction>, IEnumerable, IEnumerator<BattleAction>, IEnumerator, IDisposable
{
private int <>1__state;
private BattleAction <>2__current;
private int <>l__initialThreadId;
public StrengthSuppressionSe <>4__this;
private IEnumerator<StrengthSuppressionSe> <>7__wrap1;
BattleAction IEnumerator<BattleAction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OnEnemyDied>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>7__wrap1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
try
{
int num = <>1__state;
StrengthSuppressionSe strengthSuppressionSe = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
if (((StatusEffect)strengthSuppressionSe).Battle.BattleShouldEnd)
{
return false;
}
<>7__wrap1 = (from e in ((StatusEffect)strengthSuppressionSe).Battle.AllAliveEnemies
select ((Unit)e).GetStatusEffect<StrengthSuppressionSe>() into se
where se != null
select se).GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
break;
}
if (<>7__wrap1.MoveNext())
{
StatusEffect current = (StatusEffect)(object)<>7__wrap1.Current;
<>2__current = (BattleAction)new RemoveStatusEffectAction(current, true, 0f);
<>1__state = 1;
return true;
}
<>m__Finally1();
<>7__wrap1 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>7__wrap1 != null)
{
<>7__wrap1.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<BattleAction> IEnumerable<BattleAction>.GetEnumerator()
{
<OnEnemyDied>d__2 result;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
result = this;
}
else
{
result = new <OnEnemyDied>d__2(0)
{
<>4__this = <>4__this
};
}
return result;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<BattleAction>)this).GetEnumerator();
}
}
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);
}
}
[IteratorStateMachine(typeof(<OnEnemyDied>d__2))]
private IEnumerable<BattleAction> OnEnemyDied(DieEventArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OnEnemyDied>d__2(-2)
{
<>4__this = this
};
}
}
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
{
[CompilerGenerated]
private sealed class <OnBattleStarting>d__2 : IEnumerable<BattleAction>, IEnumerable, IEnumerator<BattleAction>, IEnumerator, IDisposable
{
private int <>1__state;
private BattleAction <>2__current;
private int <>l__initialThreadId;
public ThunderlordJadebox <>4__this;
private int <actNum>5__2;
private IEnumerator<EnemyUnit> <>7__wrap2;
BattleAction IEnumerator<BattleAction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OnBattleStarting>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 2)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>7__wrap2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
try
{
int num = <>1__state;
ThunderlordJadebox thunderlordJadebox = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
((JadeBox)thunderlordJadebox).NotifyActivating();
<actNum>5__2 = ((GameEntity)thunderlordJadebox).GameRun._stageIndex + 1;
<>2__current = (BattleAction)(object)new ApplyStatusEffectAction<Electric>((Unit)(object)((JadeBox)thunderlordJadebox).Battle.Player, (int?)(((JadeBox)thunderlordJadebox).Value1 * thunderlordJadebox.GetBuffLevel(<actNum>5__2)), (int?)null, (int?)null, (int?)null, 0f, true);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>7__wrap2 = ((JadeBox)thunderlordJadebox).Battle.AllAliveEnemies.GetEnumerator();
<>1__state = -3;
break;
case 2:
<>1__state = -3;
break;
}
if (<>7__wrap2.MoveNext())
{
EnemyUnit current = <>7__wrap2.Current;
<>2__current = (BattleAction)(object)new ApplyStatusEffectAction<Electric>((Unit)(object)current, (int?)(((JadeBox)thunderlordJadebox).Value2 * thunderlordJadebox.GetBuffLevel(<actNum>5__2)), (int?)null, (int?)null, (int?)null, 0f, true);
<>1__state = 2;
return true;
}
<>m__Finally1();
<>7__wrap2 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>7__wrap2 != null)
{
<>7__wrap2.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<BattleAction> IEnumerable<BattleAction>.GetEnumerator()
{
<OnBattleStarting>d__2 result;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
result = this;
}
else
{
result = new <OnBattleStarting>d__2(0)
{
<>4__this = <>4__this
};
}
return result;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<BattleAction>)this).GetEnumerator();
}
}
[CompilerGenerated]
private sealed class <OnEnemySpawned>d__3 : IEnumerable<BattleAction>, IEnumerable, IEnumerator<BattleAction>, IEnumerator, IDisposable
{
private int <>1__state;
private BattleAction <>2__current;
private int <>l__initialThreadId;
public ThunderlordJadebox <>4__this;
private UnitEventArgs args;
public UnitEventArgs <>3__args;
BattleAction IEnumerator<BattleAction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OnEnemySpawned>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
ThunderlordJadebox thunderlordJadebox = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
((JadeBox)thunderlordJadebox).NotifyActivating();
int actNum = ((GameEntity)thunderlordJadebox).GameRun._stageIndex + 1;
<>2__current = (BattleAction)(object)new ApplyStatusEffectAction<Electric>(args.Unit, (int?)(((JadeBox)thunderlordJadebox).Value2 * thunderlordJadebox.GetBuffLevel(actNum)), (int?)null, (int?)null, (int?)null, 0f, true);
<>1__state = 1;
return true;
}
case 1:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<BattleAction> IEnumerable<BattleAction>.GetEnumerator()
{
<OnEnemySpawned>d__3 <OnEnemySpawned>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<OnEnemySpawned>d__ = this;
}
else
{
<OnEnemySpawned>d__ = new <OnEnemySpawned>d__3(0)
{
<>4__this = <>4__this
};
}
<OnEnemySpawned>d__.args = <>3__args;
return <OnEnemySpawned>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<BattleAction>)this).GetEnumerator();
}
}
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);
}
[IteratorStateMachine(typeof(<OnBattleStarting>d__2))]
private IEnumerable<BattleAction> OnBattleStarting(GameEventArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OnBattleStarting>d__2(-2)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<OnEnemySpawned>d__3))]
private IEnumerable<BattleAction> OnEnemySpawned(UnitEventArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OnEnemySpawned>d__3(-2)
{
<>4__this = this,
<>3__args = args
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}