Decompiled source of AlwaysL7 v0.1.1

AlwaysL7.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
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.Core;
using LBoL.Core.SaveData;
using LBoL.Presentation;
using LBoL.Presentation.UI.ExtraWidgets;
using LBoL.Presentation.UI.Panels;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[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("AlwaysL7")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AlwaysL7")]
[assembly: AssemblyTitle("AlwaysL7")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace AlwaysL7;

[BepInPlugin("cyaneko.lbol.mods.alwaysl7", "AlwaysL7", "0.1.1")]
[BepInProcess("LBoL.exe")]
public class BepinexPlugin : BaseUnityPlugin
{
	private static readonly Harmony harmony = PInfo.harmony;

	internal static ManualLogSource log;

	internal static ConfigEntry<bool> CustomOverride;

	internal static ConfigEntry<GameDifficulty> DifficultyOverride;

	internal static ConfigEntry<PuzzleFlag> RequestsOverride;

	internal static ConfigEntry<bool> UnlockAll;

	internal static ConfigEntry<bool> AutoStartGame;

	private void Awake()
	{
		log = ((BaseUnityPlugin)this).Logger;
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
		CustomOverride = ((BaseUnityPlugin)this).Config.Bind<bool>("CustomOverride", "Use custom override", false, "Set your specified difficulty modifier to be the default, instead of the highest possible");
		DifficultyOverride = ((BaseUnityPlugin)this).Config.Bind<GameDifficulty>("DifficultyOverride", "Difficulty override", (GameDifficulty)3, "Default difficulty override");
		RequestsOverride = ((BaseUnityPlugin)this).Config.Bind<PuzzleFlag>("RequestsOverride", "Requests override", (PuzzleFlag)127, "Default requests override");
		UnlockAll = ((BaseUnityPlugin)this).Config.Bind<bool>("UnlockAll", "Unlock everything", false, "Unlocks all characters, difficulties, requests and jadeboxes right off the bat");
		AutoStartGame = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoStartGame", "Start game immediately", false, "Start game immediately, auto-selecting the default difficulty");
		harmony.PatchAll();
	}

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

	public const string Name = "AlwaysL7";

	public const string version = "0.1.1";

	public static readonly Harmony harmony = new Harmony("cyaneko.lbol.mods.alwaysl7");
}
[HarmonyPatch(typeof(StartGamePanel))]
public class StartGamePanel_Patches
{
	[HarmonyPatch("RefreshConfirm")]
	[HarmonyPostfix]
	public static void UnlockCharacter(StartGamePanel __instance)
	{
		if (BepinexPlugin.UnlockAll.Value && __instance._playerIndex >= 0 && __instance._playerIndex <= __instance._players.Length && __instance._players[__instance._playerIndex].Config.UnlockLevel.HasValue)
		{
			__instance.characterHintRoot.gameObject.SetActive(false);
			((TMP_Text)__instance.characterHint).text = "";
			((Selectable)__instance.characterConfirmButton).interactable = true;
		}
	}

	[HarmonyPatch("RefreshDifficultyConfirm")]
	[HarmonyPostfix]
	public static void UnlockDifficulty(StartGamePanel __instance)
	{
		if (BepinexPlugin.UnlockAll.Value && !__instance.gameModeSwitch.IsOn)
		{
			__instance.difficultyGroups[__instance._difficultyIndex].SetLocked(false);
			__instance._isDifficultyLock = false;
			((Selectable)__instance.difficultyConfirmButton).interactable = true;
			__instance._confirmTooltip.SetDirect("", (string)null);
		}
	}

	[HarmonyPatch("SetPuzzleStatus")]
	[HarmonyPostfix]
	public static void UnlockRequests(StartGamePanel __instance)
	{
		if (!BepinexPlugin.UnlockAll.Value)
		{
			return;
		}
		for (int i = 0; i < PuzzleFlags.AllPuzzleFlags.Count; i++)
		{
			foreach (PuzzleToggleWidget value in __instance._puzzleToggles.Values)
			{
				value.IsLock = false;
			}
		}
		__instance.puzzleSelectAllGroup.SetActive(true);
	}

	[HarmonyPatch("SetJadeBoxStatus")]
	[HarmonyPostfix]
	public static void UnlockJadeboxes(StartGamePanel __instance)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		if (BepinexPlugin.UnlockAll.Value)
		{
			((Selectable)__instance.jadeBoxButton).interactable = true;
			((Behaviour)__instance._jadeBoxTooltip).enabled = false;
			((Component)__instance.jadeBoxLockImage).gameObject.SetActive(false);
			((Graphic)__instance.jadeBoxText).color = Color.white;
		}
	}

	[HarmonyPatch("OnShowing")]
	[HarmonyPostfix]
	public static void SetDifficulty(StartGamePanel __instance)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		((UnityEvent)__instance.characterConfirmButton.onClick).AddListener((UnityAction)delegate
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected I4, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected I4, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected I4, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			int num = 1;
			if (__instance._player != null)
			{
				ProfileSaveData currentProfile = Singleton<GameMaster>.Instance.CurrentProfile;
				GameDifficulty? highestDifficulty = currentProfile.GetHighestDifficulty(((GameEntity)__instance._player).Id);
				GameDifficulty? highestPerfectDifficulty = currentProfile.GetHighestPerfectDifficulty(((GameEntity)__instance._player).Id);
				int val = 0;
				if (BepinexPlugin.UnlockAll.Value)
				{
					val = __instance.difficultyGroups.Length - 1;
				}
				else
				{
					if (highestPerfectDifficulty.HasValue)
					{
						val = Math.Max(val, (int)highestPerfectDifficulty.Value);
					}
					if (highestDifficulty.HasValue)
					{
						val = Math.Max(val, (int)highestDifficulty.Value);
					}
					val = Math.Min(val, __instance.difficultyGroups.Length - 1);
				}
				int num2 = (int)BepinexPlugin.DifficultyOverride.Value;
				num = ((!BepinexPlugin.CustomOverride.Value || num2 > val) ? Math.Max(num, val) : num2);
			}
			__instance.SelectDifficulty(num, true);
			foreach (PuzzleToggleWidget value in __instance._puzzleToggles.Values)
			{
				if (!value.IsLock && (!BepinexPlugin.CustomOverride.Value || (value._puzzleFlag & BepinexPlugin.RequestsOverride.Value) != 0))
				{
					value.Toggle.isOn = true;
				}
			}
			if (BepinexPlugin.AutoStartGame.Value)
			{
				((UnityEvent)__instance.difficultyConfirmButton.onClick).Invoke();
			}
		});
	}
}