Decompiled source of SkipCharSelect v1.0.3

SkipCharSelect.dll

Decompiled 2 months ago
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 UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization.Components;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("SkipCharSelect")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Skip Character Select")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("SkipCharSelect")]
[assembly: AssemblyTitle("SkipCharSelect")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
namespace SkipCharSelect;

[BepInPlugin("SkipCharSelect", "SkipCharSelect", "1.0.3")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(HomeController))]
	public static class HomeControllerPatches
	{
		[HarmonyPatch("loadscene")]
		public static bool Prefix(HomeController __instance)
		{
			LeanTween.cancelAll();
			if (__instance.loadsceneindex == 0 && !loadCharScene)
			{
				GlobalVariables.scene_destination = "levelselect";
				SceneManager.LoadScene("levelselect");
				return false;
			}
			if (__instance.loadsceneindex == 4 && !loadCharScene)
			{
				GlobalVariables.scene_destination = "freeplay";
				GlobalVariables.chosen_track = "freeplay";
				SceneManager.LoadScene("gameplay");
				return false;
			}
			loadCharScene = false;
			return true;
		}

		[HarmonyPatch("Start")]
		public static void Postfix(HomeController __instance)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			if ((Object)(object)btnPrefab == (Object)null)
			{
				GameObject gameObject = ((Component)__instance.fullsettingspanel.transform.Find("Settings/GRAPHICS/btn_opengraphicspanel")).gameObject;
				btnPrefab = Object.Instantiate<GameObject>(gameObject);
				Object.Destroy((Object)(object)btnPrefab.GetComponentInChildren<LocalizeStringEvent>());
				btnPrefab.GetComponentInChildren<Text>().text = "CharSelect";
				Button component = btnPrefab.GetComponent<Button>();
				ColorBlock colors = default(ColorBlock);
				((ColorBlock)(ref colors)).fadeDuration = 0.2f;
				((ColorBlock)(ref colors)).colorMultiplier = 1f;
				((ColorBlock)(ref colors)).disabledColor = Color.gray;
				((ColorBlock)(ref colors)).normalColor = Color.black;
				((ColorBlock)(ref colors)).highlightedColor = Color.gray;
				((ColorBlock)(ref colors)).pressedColor = Color.white;
				((ColorBlock)(ref colors)).selectedColor = Color.black;
				((Selectable)component).colors = colors;
				RectTransform component2 = btnPrefab.GetComponent<RectTransform>();
				component2.anchoredPosition = Vector2.zero;
				component2.sizeDelta = new Vector2(164f, 42f);
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0.49f, 0.93f);
				component2.anchorMax = val;
				component2.anchorMin = val;
				Object.DontDestroyOnLoad((Object)(object)btnPrefab);
			}
			if (enableButtons.Value)
			{
				GameObject val2 = Object.Instantiate<GameObject>(btnPrefab, __instance.fullcanvas.transform);
				Button component3 = val2.GetComponent<Button>();
				((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
				{
					loadCharScene = true;
					__instance.btnclick1();
				});
			}
		}
	}

	[HarmonyPatch(typeof(LevelSelectController))]
	public static class LevelSelectControllerPatches
	{
		[HarmonyPatch("fadeOut")]
		public static void Postfix(string scene_name, LevelSelectController __instance)
		{
			if (scene_name == "charselect" && !loadCharScene)
			{
				__instance.nextscene = "home";
			}
			loadCharScene = false;
		}
	}

	public static ConfigEntry<bool> enableButtons;

	public static Plugin Instance;

	public static ManualLogSource Log;

	public static bool loadCharScene;

	public static GameObject btnPrefab;

	private void Awake()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		enableButtons = ((BaseUnityPlugin)this).Config.Bind<bool>("Default", "EnableButtons", true, "Enable buttons to access the char select screen.");
		new Harmony("SkipCharSelect").PatchAll();
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "SkipCharSelect";

	public const string PLUGIN_NAME = "SkipCharSelect";

	public const string PLUGIN_VERSION = "1.0.3";
}