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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using LBoL.Base;
using LBoL.Base.Extensions;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Stations;
using LBoL.Core.StatusEffects;
using LBoL.Core.Units;
using LBoL.EntityLib.EnemyUnits.Normal;
using LBoL.EntityLib.Exhibits.Adventure;
using LBoL.EntityLib.Stages.NormalStages;
using LBoL.EntityLib.StatusEffects.Enemy;
using LBoL.EntityLib.StatusEffects.Enemy.SeijaItems;
using LBoL.Presentation;
using LBoLEntitySideloader;
using LBoLEntitySideloader.Attributes;
using LBoLEntitySideloader.Entities;
using LBoLEntitySideloader.Resource;
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("EndlessMode")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EndlessMode")]
[assembly: AssemblyTitle("EndlessMode")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace EndlessMode
{
[BepInPlugin("intoxicatedkid.endlessmode", "Endless Mode", "0.1.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 TemplateSequenceTable sequenceTable = new TemplateSequenceTable(0);
internal static IResourceSource embeddedSource = (IResourceSource)new EmbeddedSource(Assembly.GetExecutingAssembly());
internal static DirectorySource directorySource = new DirectorySource("intoxicatedkid.endlessmode", "");
public static ConfigEntry<bool> EnableFinalAct;
private void Awake()
{
log = ((BaseUnityPlugin)this).Logger;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
EnableFinalAct = ((BaseUnityPlugin)this).Config.Bind<bool>("EnableFinalAct", "Enable Final Act", false, "Add Act 4 to Endless Mode. Does not require Border Sensor and can be toggled mid-run.\nSeija's Liberator of Items and Overdecorated Gold Cup is removed.");
EntityManager.RegisterSelf();
harmony.PatchAll();
if (Chainloader.PluginInfos.ContainsKey("neo.lbol.tools.watermark"))
{
WatermarkWrapper.ActivateWatermark();
}
}
private void OnDestroy()
{
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
public sealed class EndlessModeJadeBoxDef : JadeBoxTemplate
{
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("EndlessModeJadeBox");
}
public override LocalizationOption LoadLocalization()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
return (LocalizationOption)new DirectLocalization(new Dictionary<string, object>
{
{ "Name", "Endless Mode" },
{ "Description", "Defeating the Act 3 boss will send you back to Act 1.\nEach loop empowers enemies." }
}, (Locale)0, (Locale)0, false);
}
public override JadeBoxConfig MakeConfig()
{
JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
val.Order = -99;
return val;
}
}
[EntityLogic(typeof(EndlessModeJadeBoxDef))]
public sealed class EndlessModeJadeBox : JadeBox
{
[HarmonyPatch(typeof(Station), "ForceFinish")]
private class Station_ForceFinish_Patch
{
private static void Postfix(Station __instance)
{
if (Singleton<GameMaster>.Instance.CurrentGameRun != null && Singleton<GameMaster>.Instance.CurrentGameRun._jadeBoxes.Any((JadeBox j) => j is EndlessModeJadeBox))
{
__instance.IsNormalEnd = false;
__instance.IsTrueEnd = false;
}
}
}
protected override void OnGain(GameRunController gameRun)
{
if (!BepinexPlugin.EnableFinalAct.Value)
{
((GameEntity)this).GameRun._stages.Remove(((GameEntity)this).GameRun._stages.Last());
}
((GameEntity)this).GameRun.GainExhibitInstantly((Exhibit)(object)Library.CreateExhibit<JingjieGanzhiyi>(), false, (VisualSourceData)null);
}
protected override void OnAdded()
{
((JadeBox)this).HandleGameRunEvent<GameEventArgs>(((GameEntity)this).GameRun.StageEntered, (GameEventHandler<GameEventArgs>)delegate
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Invalid comparison between Unknown and I4
((GameEntity)this).GameRun.CurrentStage.Index = ((GameEntity)this).GameRun._stageIndex;
if (((GameEntity)this).GameRun.CurrentStage.Boss == null)
{
((GameEntity)this).GameRun.CurrentStage.InitBoss(new RandomGen(((GameEntity)this).GameRun.InitBossSeed));
}
if (((GameEntity)this).GameRun.CurrentStage is BambooForest && ((GameEntity)this).GameRun.CurrentStage.Index > 0)
{
((GameEntity)this).GameRun.ExhibitPool = new List<Type>();
((GameEntity)this).GameRun.ShiningExhibitPool = new List<Type>();
foreach (var (type, val5) in Library.EnumerateRollableExhibitTypes(((GameEntity)this).GameRun.UnlockLevel))
{
if ((int)val5.Rarity == 3 && !((GameEntity)this).GameRun.Player.HasExhibit(type))
{
((GameEntity)this).GameRun.ShiningExhibitPool.Add(type);
}
else if (val5.IsPooled && !((GameEntity)this).GameRun.Player.HasExhibit(type))
{
((GameEntity)this).GameRun.ExhibitPool.Add(type);
}
}
}
});
((JadeBox)this).HandleGameRunEvent<StationEventArgs>(((GameEntity)this).GameRun.StationEntered, (GameEventHandler<StationEventArgs>)delegate(StationEventArgs args)
{
((GameEntity)this).GameRun.CurrentStage.Index = ((GameEntity)this).GameRun._stageIndex;
if (((GameEntity)this).GameRun.CurrentStage == ((GameEntity)this).GameRun._stages.Last() && args.Station is BossStation)
{
((GameEntity)this).GameRun.CurrentStation.IsNormalEnd = false;
((GameEntity)this).GameRun.CurrentStation.IsTrueEnd = false;
Stage val = (Stage)(object)Library.CreateStage<BambooForest>();
((GameEntity)val).GameRun = ((GameEntity)this).GameRun;
((GameEntity)this).GameRun._stages.Add(val);
Stage val2 = (Stage)(object)Library.CreateStage<XuanwuRavine>();
((GameEntity)val2).GameRun = ((GameEntity)this).GameRun;
((GameEntity)this).GameRun._stages.Add(val2);
Stage val3 = (Stage)(object)Library.CreateStage<WindGodLake>();
((GameEntity)val3).GameRun = ((GameEntity)this).GameRun;
((GameEntity)this).GameRun._stages.Add(val3);
if (BepinexPlugin.EnableFinalAct.Value)
{
Stage val4 = (Stage)(object)Library.CreateStage<FinalStage>();
((GameEntity)val4).GameRun = ((GameEntity)this).GameRun;
((GameEntity)this).GameRun._stages.Add(val4);
}
}
});
}
protected override void OnEnterBattle()
{
((JadeBox)this).HandleBattleEvent<GameEventArgs>(((JadeBox)this).Battle.BattleStarted, (GameEventHandler<GameEventArgs>)OnBattleStarted);
((JadeBox)this).HandleBattleEvent<StatusEffectApplyEventArgs>(((Unit)((JadeBox)this).Battle.Player).StatusEffectAdding, (GameEventHandler<StatusEffectApplyEventArgs>)OnPlayerStatusEffectAdding);
((JadeBox)this).HandleBattleEvent<UnitEventArgs>(((JadeBox)this).Battle.EnemySpawned, (GameEventHandler<UnitEventArgs>)OnEnemySpawned);
}
private void OnBattleStarted(GameEventArgs args)
{
int num = MathExtensions.TruncateToInt((float)(((GameEntity)this).GameRun._stageIndex - (((GameEntity)this).GameRun._stages.Count((Stage s) => s is FinalStage) - ((((GameEntity)this).GameRun.CurrentStage is BambooForest) ? 1 : 0))) / 3f);
foreach (EnemyUnit alife in ((JadeBox)this).Battle.EnemyGroup.Alives)
{
if (alife is HardworkRabbit || alife is LazyRabbit)
{
((GameEntity)this).GameRun.SetEnemyHpAndMaxHp(Math.Min(((Unit)alife).Hp * (num + 1), 50), Math.Min(((Unit)alife).MaxHp * (num + 1), 50), alife, false);
}
else
{
((GameEntity)this).GameRun.SetEnemyHpAndMaxHp(((Unit)alife).Hp * (num + 1), ((Unit)alife).MaxHp * (num + 1), alife, false);
}
((JadeBox)this).HandleBattleEvent<StatusEffectApplyEventArgs>(((Unit)alife).StatusEffectAdding, (GameEventHandler<StatusEffectApplyEventArgs>)OnEnemyStatusEffectAdding);
((JadeBox)this).HandleBattleEvent<DamageDealingEventArgs>(((Unit)alife).DamageDealing, (GameEventHandler<DamageDealingEventArgs>)OnEnemyDamageDealing);
}
}
private void OnPlayerStatusEffectAdding(StatusEffectApplyEventArgs args)
{
if (args.Effect is FoxCharm)
{
int num = MathExtensions.TruncateToInt((float)(((GameEntity)this).GameRun._stageIndex - (((GameEntity)this).GameRun._stages.Count((Stage s) => s is FinalStage) - ((((GameEntity)this).GameRun.CurrentStage is BambooForest) ? 1 : 0))) / 3f);
StatusEffect effect = args.Effect;
effect.Limit += num;
}
}
private void OnEnemyStatusEffectAdding(StatusEffectApplyEventArgs args)
{
if (args.Effect is ScarletDestiny)
{
int num = MathExtensions.TruncateToInt((float)(((GameEntity)this).GameRun._stageIndex - (((GameEntity)this).GameRun._stages.Count((Stage s) => s is FinalStage) - ((((GameEntity)this).GameRun.CurrentStage is BambooForest) ? 1 : 0))) / 3f);
StatusEffect effect = args.Effect;
effect.Limit += num;
}
if (args.Effect is LimitedDamage || args.Effect is HolyGrailSe)
{
((GameEventArgs)args).CancelBy((GameEntity)(object)this);
}
}
private void OnEnemyDamageDealing(DamageDealingEventArgs args)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Invalid comparison between Unknown and I4
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
int num = MathExtensions.TruncateToInt((float)(((GameEntity)this).GameRun._stageIndex - (((GameEntity)this).GameRun._stages.Count((Stage s) => s is FinalStage) - ((((GameEntity)this).GameRun.CurrentStage is BambooForest) ? 1 : 0))) / 3f);
DamageInfo damageInfo = args.DamageInfo;
if ((int)((DamageInfo)(ref damageInfo)).DamageType == 2)
{
damageInfo = args.DamageInfo;
args.DamageInfo = ((DamageInfo)(ref damageInfo)).MultiplyBy(num + 1);
((GameEventArgs)args).AddModifier((GameEntity)(object)this);
}
}
private void OnEnemySpawned(UnitEventArgs args)
{
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
int num = MathExtensions.TruncateToInt((float)(((GameEntity)this).GameRun._stageIndex - (((GameEntity)this).GameRun._stages.Count((Stage s) => s is FinalStage) - ((((GameEntity)this).GameRun.CurrentStage is BambooForest) ? 1 : 0))) / 3f);
if (args.Unit is HardworkRabbit || args.Unit is LazyRabbit)
{
((GameEntity)this).GameRun.SetEnemyHpAndMaxHp(Math.Min(args.Unit.Hp * (num + 1), 50), Math.Min(args.Unit.MaxHp * (num + 1), 50), (EnemyUnit)args.Unit, false);
}
else
{
((GameEntity)this).GameRun.SetEnemyHpAndMaxHp(args.Unit.Hp * (num + 1), args.Unit.MaxHp * (num + 1), (EnemyUnit)args.Unit, false);
}
((JadeBox)this).HandleBattleEvent<StatusEffectApplyEventArgs>(args.Unit.StatusEffectAdding, (GameEventHandler<StatusEffectApplyEventArgs>)OnEnemyStatusEffectAdding);
((JadeBox)this).HandleBattleEvent<DamageDealingEventArgs>(args.Unit.DamageDealing, (GameEventHandler<DamageDealingEventArgs>)OnEnemyDamageDealing);
}
}
public static class PInfo
{
public const string GUID = "intoxicatedkid.endlessmode";
public const string Name = "Endless Mode";
public const string version = "0.1.3";
public static readonly Harmony harmony = new Harmony("intoxicatedkid.endlessmode");
}
internal class WatermarkWrapper
{
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void ActivateWatermark()
{
API.ActivateWatermark();
}
}
}
namespace EndlessMode.StatusEffects
{
public sealed class EndlessModeCurseSeDef : StatusEffectTemplate
{
[EntityLogic(typeof(EndlessModeCurseSeDef))]
public sealed class EndlessModeCurseSe : StatusEffect
{
}
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("EndlessModeCurseSe");
}
public override LocalizationOption LoadLocalization()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
GlobalLocalization val = new GlobalLocalization((IResourceSource)(object)BepinexPlugin.directorySource);
val.DiscoverAndLoadLocFiles((EntityDefinition)(object)this);
return (LocalizationOption)(object)val;
}
public override Sprite LoadSprite()
{
return ResourceLoader.LoadSprite("Resources.EndlessModeCurseSe.png", BepinexPlugin.embeddedSource, (Rect?)null, 1, (Vector2?)null);
}
public override StatusEffectConfig MakeConfig()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
return new StatusEffectConfig(BepinexPlugin.sequenceTable.Next(typeof(StatusEffectConfig)), "", 10, (StatusEffectType)0, 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>(), "Default", "Default", "Default");
}
}
}
namespace EndlessMode.Exhibits
{
public sealed class EndlessModeCurseofBleedingDef : ExhibitTemplate
{
[EntityLogic(typeof(EndlessModeCurseofBleedingDef))]
[UsedImplicitly]
public sealed class EndlessModeCurseofBleeding : Exhibit
{
[HarmonyPatch(typeof(Unit), "Heal")]
private class Unit_Heal_Patch
{
private static void Prefix(Unit __instance, ref int healValue)
{
if (__instance is PlayerUnit && Singleton<GameMaster>.Instance.CurrentGameRun.Player.HasExhibit<EndlessModeCurseofBleeding>())
{
healValue = MathExtensions.CeilingToInt((float)healValue * ((100f - (float)((Exhibit)Singleton<GameMaster>.Instance.CurrentGameRun.Player.GetExhibit<EndlessModeCurseofBleeding>()).Counter) / 100f));
}
}
}
protected override void OnGain(PlayerUnit player)
{
((Exhibit)this).Counter = ((Exhibit)this).Value1 * ((GameEntity)this).GameRun.Player.Exhibits.Count((Exhibit e) => e.Config.RelativeEffects.Contains("EndlessModeCurseSe"));
}
protected override void OnAdded(PlayerUnit player)
{
((Exhibit)this).HandleGameRunEvent<GameEventArgs>(((GameEntity)this).GameRun.StageEntered, (GameEventHandler<GameEventArgs>)delegate
{
if (((GameEntity)this).GameRun.CurrentStage is BambooForest)
{
((Exhibit)this).Counter = Math.Min(((Exhibit)this).Counter + ((Exhibit)this).Value1, ((Exhibit)this).Value2);
}
});
}
}
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("EndlessModeCurseofBleeding");
}
public override LocalizationOption LoadLocalization()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
GlobalLocalization val = new GlobalLocalization((IResourceSource)(object)BepinexPlugin.directorySource);
val.DiscoverAndLoadLocFiles((EntityDefinition)(object)this);
return (LocalizationOption)(object)val;
}
public override ExhibitSprites LoadSprite()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
string folder = "";
ExhibitSprites val = new ExhibitSprites();
Func<string, Sprite> func = (string s) => ResourceLoader.LoadSprite(folder + IdContainer.op_Implicit(((EntityDefinition)this).GetId()) + s + ".png", BepinexPlugin.embeddedSource, (Rect?)null, 1, (Vector2?)null);
val.main = func("");
return val;
}
public override ExhibitConfig MakeConfig()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
return new ExhibitConfig(BepinexPlugin.sequenceTable.Next(typeof(ExhibitConfig)), "", 0, false, false, false, false, (AppearanceType)3, "", (ExhibitLosableType)2, (Rarity)4, (int?)10, (int?)70, (int?)null, (ManaGroup?)null, (ManaColor?)null, (ManaColor?)null, 0, true, (int?)0, (Keyword)0, (IReadOnlyList<string>)new List<string> { "EndlessModeCurseSe" }, (IReadOnlyList<string>)new List<string>());
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}