Decompiled source of MeteorMod v0.2.1

MeteorMod.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
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.Logging;
using HarmonyLib;
using MeteorCore;
using MeteorCore.Localiser;
using MeteorCore.Setting;
using MeteorCore.Setting.AbstractClasses;
using MeteorCore.Setting.Interfaces;
using MeteorMod.Settings;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
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.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MeteorMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+0e3f2f6e4dbe75d8844716add93267e4a32980ca")]
[assembly: AssemblyProduct("Meteor Mod")]
[assembly: AssemblyTitle("MeteorMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MeteorMod
{
	[BepInPlugin("MeteorMod", "Meteor Mod", "0.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		internal static BepInPlugin metadata;

		internal static Harmony harmony;

		internal static UnityAction OnUpdate;

		internal static readonly string settingPageName = "Meteor Mod";

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin MeteorMod is loaded!");
			metadata = MetadataHelper.GetMetadata((object)this);
			harmony = new Harmony("MeteorMod");
			harmony.PatchAll();
			PluginLocaliser.RegisterPlugin(metadata, (string)null, "MeteorMod");
			InitializeSettings();
		}

		private void InitializeSettings()
		{
			Mgr_PluginSettings.AddPage<PluginSettingsPage>(settingPageName, PluginLocaliser.ConvertPluginToDictionaryName(metadata), "MeteorMod Settings");
			BuiltInDebugMenuSetting.Init();
			ShowHiddenSettingsSetting.Init();
			DisableSubtitlesSetting.Init();
			SkipSplashScreenSetting.Init();
			DisableBeatmapsSetting.Init();
		}

		private void Update()
		{
			UnityAction onUpdate = OnUpdate;
			if (onUpdate != null)
			{
				onUpdate.Invoke();
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MeteorMod";

		public const string PLUGIN_NAME = "Meteor Mod";

		public const string PLUGIN_VERSION = "0.2.0";
	}
}
namespace MeteorMod.Settings
{
	public static class BuiltInDebugMenuSetting
	{
		public static PluginSettingBool enableDebugSetting;

		public static DebugMenuToggle debugMenuToggle;

		public static Mgr_DebugTools debugTools;

		private static bool firstSceneLoad = true;

		public static void Init()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			enableDebugSetting = new PluginSettingBool("EnableDebugMenu", "Enable Debug Menu", false, "Enables debugTools and debug menu\n\nAccess the menu with CTRL+SHIFT+D", "Meteor Mod", Plugin.metadata);
			Mgr_PluginSettings.AddSetting<bool, PluginSettingToggleUIItem>((IPluginSetting<bool>)(object)enableDebugSetting, Plugin.settingPageName, Plugin.metadata);
			((PluginSetting<bool>)(object)enableDebugSetting).OnValueChanged += DebugSettingChanged;
			SceneManager.sceneLoaded += SceneLoaded;
		}

		private static void DebugSettingChanged(IPluginSetting<bool> setting)
		{
			bool value = setting.Value;
			SetDebugMenuState(value);
		}

		public static void SceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (!SceneHelper.IsTitleScene || !firstSceneLoad)
			{
				return;
			}
			firstSceneLoad = false;
			string text = "MANAGER_MASTER/Debug";
			GameObject val = GameObject.Find(text);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)("Could not get debug object," + text + "GameObject not found"));
				return;
			}
			debugTools = val.GetComponent<Mgr_DebugTools>();
			if ((Object)(object)debugTools == (Object)null)
			{
				Plugin.Logger.LogError((object)("Could not get debug, Mgr_DebugTools component not in GameObject" + text));
				return;
			}
			debugMenuToggle = Object.FindObjectOfType<DebugMenuToggle>(true);
			if ((Object)(object)debugMenuToggle == (Object)null)
			{
				Plugin.Logger.LogError((object)"Could not get DebugMenuToggle");
			}
			else
			{
				SetDebugMenuState(((PluginSetting<bool>)(object)enableDebugSetting).Value);
			}
		}

		public static void SetDebugMenuState(bool state)
		{
			if ((Object)(object)debugTools == (Object)null || (Object)(object)debugMenuToggle == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"BuiltInDebugMenuSetting errored at Init, cannot apply debug setting");
				return;
			}
			if (IsMenuActive())
			{
				debugMenuToggle.ToggleAllDebugBoxes();
			}
			if (state)
			{
				debugTools.DisableAllDebug = false;
				Plugin.Logger.LogInfo((object)"Enabled GVH debug");
				((Component)debugMenuToggle).gameObject.SetActive(true);
				Plugin.Logger.LogInfo((object)"Enabled GVH debug button");
			}
			else
			{
				debugTools.DisableAllDebug = true;
				Plugin.Logger.LogInfo((object)"Disabled GVH debug");
				((Component)debugMenuToggle).gameObject.SetActive(false);
				Plugin.Logger.LogInfo((object)"Disabled GVH debug button");
			}
		}

		public static bool IsMenuActive()
		{
			if ((Object)(object)debugMenuToggle == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"DebugMenuToggle is null");
				return false;
			}
			if (debugMenuToggle.debugGameobjects.Length == 0)
			{
				Plugin.Logger.LogWarning((object)"debugGameobjects is empty");
				return false;
			}
			return debugMenuToggle.debugGameobjects[0].activeInHierarchy;
		}
	}
	public static class DisableBeatmapsSetting
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<IPluginSetting<bool>> <0>__DisableBeatmapsSettingChanged;

			public static UnityAction<Scene, LoadSceneMode> <1>__SceneLoaded;

			public static UnityAction <2>__OnUpdate;
		}

		public static PluginSettingBool disableBeatmapsSetting;

		private static GameObject GameplayUI;

		public static List<KeyCode> KeyCombos = new List<KeyCode>
		{
			(KeyCode)306,
			(KeyCode)304,
			(KeyCode)102
		};

		private static bool comboKeyDown = false;

		private static bool IsPressingCombo
		{
			get
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				foreach (KeyCode keyCombo in KeyCombos)
				{
					if (!Input.GetKey(keyCombo))
					{
						return false;
					}
				}
				return true;
			}
		}

		public static void Init()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			disableBeatmapsSetting = new PluginSettingBool("DisableBeatmaps", "Disable Beatmaps", false, "Disables rhythm game segments' interactivity and UI.\nWhile in a performance toggle with CTRL+SHIFT+F", "Meteor Mod", Plugin.metadata);
			Mgr_PluginSettings.AddSetting<bool, PluginSettingToggleUIItem>((IPluginSetting<bool>)(object)disableBeatmapsSetting, Plugin.settingPageName, Plugin.metadata);
			((PluginSetting<bool>)(object)disableBeatmapsSetting).OnValueChanged += DisableBeatmapsSettingChanged;
			SceneManager.sceneLoaded += SceneLoaded;
			UnityAction onUpdate = Plugin.OnUpdate;
			object obj = <>O.<2>__OnUpdate;
			if (obj == null)
			{
				UnityAction val = OnUpdate;
				<>O.<2>__OnUpdate = val;
				obj = (object)val;
			}
			Plugin.OnUpdate = (UnityAction)Delegate.Combine((Delegate?)(object)onUpdate, (Delegate?)obj);
		}

		public static void SceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (SceneHelper.IsPerformenceScene)
			{
				GameplayUI = GameObject.Find("GameplayUI Root");
				if ((Object)(object)GameplayUI == (Object)null)
				{
					Plugin.Logger.LogWarning((object)"Could not find GameplayUI Root");
				}
				else
				{
					DisableBeatmapsSettingChanged((IPluginSetting<bool>)(object)disableBeatmapsSetting);
				}
			}
		}

		public static void OnUpdate()
		{
			if ((Object)(object)GameplayUI == (Object)null)
			{
				return;
			}
			if (IsPressingCombo)
			{
				if (!comboKeyDown)
				{
					comboKeyDown = true;
					((PluginSetting<bool>)(object)disableBeatmapsSetting).SetValue(!((PluginSetting<bool>)(object)disableBeatmapsSetting).Value, true, false, true);
				}
			}
			else
			{
				comboKeyDown = false;
			}
		}

		public static void DisableBeatmapsSettingChanged(IPluginSetting<bool> setting)
		{
			SetBeatmapState(!setting.Value);
		}

		public static void SetBeatmapState(bool state)
		{
			if (!((Object)(object)GameplayUI == (Object)null))
			{
				GameplayUI.SetActive(state);
				Plugin.Logger.LogInfo((object)$"Set beatmap GameplayUI to {state}");
			}
		}
	}
	public static class DisableSubtitlesSetting
	{
		public static PluginSettingBool disableSubtitlesSetting;

		private static GameObject subtitlesGameObject;

		public static void Init()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			disableSubtitlesSetting = new PluginSettingBool("DisableSubtitles", "Disable Subtitles", false, "Disables subtitles in the game", "Meteor Mod", Plugin.metadata);
			Mgr_PluginSettings.AddSetting<bool, PluginSettingToggleUIItem>((IPluginSetting<bool>)(object)disableSubtitlesSetting, "Meteor Mod", Plugin.metadata);
			((PluginSetting<bool>)(object)disableSubtitlesSetting).OnValueChanged += DisableSubtitlesSettingChanged;
			SceneManager.sceneLoaded += SceneLoaded;
		}

		public static void SceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (SceneHelper.IsGameScene)
			{
				subtitlesGameObject = GameObject.Find("SCENE_MASTER/SpeechMaster/SpeechCanvas/SafeArea/Subtitles");
				if ((Object)(object)subtitlesGameObject == (Object)null)
				{
					Plugin.Logger.LogWarning((object)"Could not find DialogueSubtitles GameObject");
				}
				else
				{
					SetSubtitlesState(!((PluginSetting<bool>)(object)disableSubtitlesSetting).Value);
				}
			}
		}

		public static void DisableSubtitlesSettingChanged(IPluginSetting<bool> setting)
		{
			SetSubtitlesState(!setting.Value);
		}

		public static void SetSubtitlesState(bool state)
		{
			if ((Object)(object)subtitlesGameObject != (Object)null)
			{
				subtitlesGameObject.SetActive(state);
			}
		}
	}
	[HarmonyPatch(typeof(InkMaster), "ClearSubtitles")]
	public static class ClearSubtitlesPatch
	{
		private static bool Prefix(InkMaster __instance)
		{
			return (Object)(object)__instance.SubtitlesController != (Object)null;
		}
	}
	public static class ShowHiddenSettingsSetting
	{
		public static PluginSettingBool enableHiddenSettingsSetting;

		private static List<SettingsItem> disabledSettings = new List<SettingsItem>();

		public static void Init()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			enableHiddenSettingsSetting = new PluginSettingBool("ShowHiddenSettings", "Show Hidden Settings", false, "Shows hidden settings.\n\nAs they are hidden there is a good chance they may not work.\nThey are labelled <color=#FFFFB2>yellow</color>.", "Meteor Mod", Plugin.metadata);
			Mgr_PluginSettings.AddSetting<bool, PluginSettingToggleUIItem>((IPluginSetting<bool>)(object)enableHiddenSettingsSetting, "Meteor Mod", Plugin.metadata);
			((PluginSetting<bool>)(object)enableHiddenSettingsSetting).OnValueChanged += ShowHiddenSettingChanged;
			SceneManager.sceneLoaded += SceneLoaded;
		}

		private static void SceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if (!Mgr_PluginSettings.SceneHasSettingsMenu)
			{
				return;
			}
			SettingsMenu val = Object.FindObjectsOfType<SettingsMenu>(true)[0];
			SettingsItem[] componentsInChildren = ((Component)val).gameObject.GetComponentsInChildren<SettingsItem>(true);
			SettingsItem[] array = componentsInChildren;
			foreach (SettingsItem val2 in array)
			{
				if (!((Component)val2).gameObject.activeSelf && !disabledSettings.Contains(val2))
				{
					disabledSettings.Add(val2);
					TMP_Text componentInChildren = ((Component)val2).GetComponentInChildren<TMP_Text>();
					((Graphic)componentInChildren).color = new Color(1f, 1f, 0.7f, 1f);
				}
			}
			ShowHiddenSettingChanged((IPluginSetting<bool>)(object)enableHiddenSettingsSetting);
			Plugin.Logger.LogInfo((object)("ShowHiddenSettings initialized with " + disabledSettings.Count + " settings"));
		}

		public static void ShowHiddenSettingChanged(IPluginSetting<bool> setting)
		{
			bool value = setting.Value;
			SetHiddenSettingsState(value);
		}

		public static void SetHiddenSettingsState(bool state)
		{
			foreach (SettingsItem disabledSetting in disabledSettings)
			{
				if (!((Object)(object)disabledSetting == (Object)null))
				{
					((Component)disabledSetting).gameObject.SetActive(state);
				}
			}
			Plugin.Logger.LogInfo((object)((state ? "Enabled" : "Disabled") + $" {disabledSettings.Count} hidden settings"));
		}
	}
	public static class SkipSplashScreenSetting
	{
		[HarmonyPatch(typeof(SplashScreen), "Start")]
		public class SplashScreen_Start_Patch_Skip
		{
			private static bool Prefix(SplashScreen __instance)
			{
				if (skipSplashScreenSetting == null)
				{
					Plugin.Logger.LogError((object)"SkipSplashScreenSetting is null");
					return true;
				}
				if (!((PluginSetting<bool>)(object)skipSplashScreenSetting).Value)
				{
					return true;
				}
				Plugin.Logger.LogInfo((object)"Skipping SplashScreen");
				IEnumerator enumerator = Skip(__instance);
				((MonoBehaviour)__instance).StartCoroutine(enumerator);
				return false;
			}

			private static IEnumerator Skip(SplashScreen instance)
			{
				AsyncOperation loadSceneOp = SceneManager.LoadSceneAsync("Title", (LoadSceneMode)1);
				while (!loadSceneOp.isDone)
				{
					yield return null;
				}
				SceneManager.UnloadSceneAsync(((Component)instance).gameObject.scene);
			}
		}

		public static PluginSettingBool skipSplashScreenSetting;

		public static void Init()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			skipSplashScreenSetting = new PluginSettingBool("SkipSplashScreen", "Skip Splash Screen", false, "Skips the start splash screen", "Meteor Mod", Plugin.metadata);
			Mgr_PluginSettings.AddSetting<bool, PluginSettingToggleUIItem>((IPluginSetting<bool>)(object)skipSplashScreenSetting, Plugin.settingPageName, Plugin.metadata);
		}
	}
}