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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Battle;
using LBoL.Core.Stations;
using LBoL.Core.Units;
using LBoL.Presentation;
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("YourThemewhenWinning")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("YourThemewhenWinning")]
[assembly: AssemblyTitle("YourThemewhenWinning")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace YourThemewhenWinning
{
[BepInPlugin("intoxicatedkid.yourthemewhenwinning", "Your Theme when Winning", "1.0.1")]
[BepInProcess("LBoL.exe")]
public class BepinexPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(BattleController))]
private class BattleController_Patch
{
private static bool Changed;
[HarmonyPatch("PlayerTurnFlow")]
[HarmonyPrefix]
private static bool PlayerTurnFlow_Prefix(BattleController __instance)
{
GameMaster instance = Singleton<GameMaster>.Instance;
object obj;
if (instance == null)
{
obj = null;
}
else
{
GameRunController currentGameRun = instance.CurrentGameRun;
obj = ((currentGameRun != null) ? currentGameRun.CurrentStation : null);
}
Station val = (Station)obj;
BossStation bs = (BossStation)(object)((val is BossStation) ? val : null);
if (bs != null && !Changed && (AllBosses.Value || Singleton<GameMaster>.Instance.CurrentGameRun.CurrentStage.Level == 4))
{
PlayerUnit player = Singleton<GameMaster>.Instance.CurrentGameRun.Battle.Player;
EnemyUnit val2 = ((BattleStation)bs).EnemyGroup.Alives.Where((EnemyUnit enemyUnit) => ((GameEntity)enemyUnit).Id == bs.BossId).FirstOrDefault();
if (player != null && val2 != null && ((Unit)player).Hp >= ((Unit)player).MaxHp * 75 / 100 && ((Unit)val2).Hp <= ((Unit)val2).MaxHp * 25 / 100)
{
if (BgmConfig.FromID(((GameEntity)Singleton<GameMaster>.Instance.CurrentGameRun.Battle.Player).Id) != null)
{
AudioManager.PlayInLayer1(((GameEntity)Singleton<GameMaster>.Instance.CurrentGameRun.Battle.Player).Id);
}
Changed = true;
}
}
return true;
}
[HarmonyPatch("StartBattle")]
[HarmonyPostfix]
private static void StartBattle_Postfix(BattleController __instance)
{
GameMaster instance = Singleton<GameMaster>.Instance;
object obj;
if (instance == null)
{
obj = null;
}
else
{
GameRunController currentGameRun = instance.CurrentGameRun;
obj = ((currentGameRun != null) ? currentGameRun.CurrentStation : null);
}
BossStation val = (BossStation)((obj is BossStation) ? obj : null);
if (val != null)
{
Changed = false;
}
}
}
private static readonly Harmony harmony = PInfo.harmony;
internal static ManualLogSource log;
public static ConfigEntry<bool> AllBosses;
private void Awake()
{
log = ((BaseUnityPlugin)this).Logger;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
AllBosses = ((BaseUnityPlugin)this).Config.Bind<bool>("AllBosses", "All Bosses", false, "Allows your theme to be played on any boss battle.");
harmony.PatchAll();
}
private void OnDestroy()
{
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
public static class PInfo
{
public const string GUID = "intoxicatedkid.yourthemewhenwinning";
public const string Name = "Your Theme when Winning";
public const string version = "1.0.1";
public static readonly Harmony harmony = new Harmony("intoxicatedkid.yourthemewhenwinning");
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}