internal static void OnUpdate() { if (IsInitialized) { if (was_level_loaded) { OnLevelWasInitialized(level_loaded_index); was_level_loaded = false; level_loaded_index = -1; } if (Imports.IsIl2CppGame()) { if (IsVRChat) { VRChat_CheckUiManager(); } if (!Imports.IsMUPOTMode()) { CheckForSceneChange(); } } if (Mods.Count() > 0) { foreach (MelonMod mod in Mods) { try { mod.OnUpdate(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } if (Imports.IsIl2CppGame() && !Imports.IsMUPOTMode()) { MelonCoroutines.Process(); } } }
private static void OnApplicationStart() { if (Imports.IsIl2CppGame()) { Assembly_CSharp = Assembly.Load("Assembly-CSharp"); UnhollowerSupport.Initialize(); } SupportModule.Initialize(); MelonModLogger.Log("------------------------------"); MelonModLogger.Log("Unity " + UnityVersion); MelonModLogger.Log("------------------------------"); MelonModLogger.Log("Name: " + CurrentGameAttribute.GameName); MelonModLogger.Log("Developer: " + CurrentGameAttribute.Developer); MelonModLogger.Log("Type: " + (Imports.IsIl2CppGame() ? "Il2Cpp" : (Imports.IsOldMono() ? "Mono" : "MonoBleedingEdge"))); MelonModLogger.Log("------------------------------"); MelonModLogger.Log("Using v" + BuildInfo.Version + " Open-Beta"); MelonModLogger.Log("------------------------------"); LoadMods(); if (Mods.Count > 0) { for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { MelonModLogger.Log(mod.InfoAttribute.Name + (!string.IsNullOrEmpty(mod.InfoAttribute.Version) ? (" v" + mod.InfoAttribute.Version) : "") + (!string.IsNullOrEmpty(mod.InfoAttribute.Author) ? (" by " + mod.InfoAttribute.Author) : "") + (!string.IsNullOrEmpty(mod.InfoAttribute.DownloadLink) ? (" (" + mod.InfoAttribute.DownloadLink + ")") : "") ); if (Imports.IsDebugMode()) { MelonModLogger.Log("Preload: " + mod.IsPreload.ToString()); } MelonModLogger.LogModStatus((mod.GameAttributes.Any()) ? (mod.IsUniversal ? 0 : 1) : 2); MelonModLogger.Log("------------------------------"); } } for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { try { mod.OnApplicationStart(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } } else { MelonModLogger.Log("No Mods Loaded!"); MelonModLogger.Log("------------------------------"); } }
internal static void OnModSettingsApplied() { if (IsInitialized && (Mods.Count() > 0)) { foreach (MelonMod mod in Mods) { try { mod.OnModSettingsApplied(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } }
internal static void OnApplicationStart() { if (Mods.Count() > 0) { foreach (MelonMod mod in Mods) { try { mod.OnApplicationStart(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } IsInitialized = true; }
internal static void OnApplicationQuit() { if (IsInitialized && (Mods.Count() > 0)) { foreach (MelonMod mod in Mods) { try { mod.OnApplicationQuit(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } ModPrefs.SaveConfig(); NET_SDK.Harmony.Manager.UnpatchAll(); }
internal static void OnLevelWasLoaded(int level) { if (Mods.Count() > 0) { for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { try { mod.OnLevelWasLoaded(level); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } } }
public static void OnGUI() { if (Mods.Count() > 0) { for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { try { mod.OnGUI(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } } }
internal static void OnLevelWasLoaded(int level) { if (IsInitialized) { if (Mods.Count() > 0) { foreach (MelonMod mod in Mods) { try { mod.OnLevelWasLoaded(level); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } was_level_loaded = true; level_loaded_index = level; } }
private static void OnApplicationQuit() { if (Mods.Count() > 0) { for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { try { mod.OnApplicationQuit(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } } ModPrefs.SaveConfig(); Harmony.HarmonyInstance.UnpatchAllInstances(); }
internal static void OnFixedUpdate() { if (IsInitialized) { if (Mods.Count() > 0) { foreach (MelonMod mod in Mods) { try { mod.OnFixedUpdate(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } if (Imports.IsIl2CppGame() && !Imports.IsMUPOTMode()) { MelonCoroutines.ProcessWaitForFixedUpdate(); } } }
public static void OnUpdate() { SceneHandler.CheckForSceneChange(); if (Imports.IsIl2CppGame() && IsVRChat) { VRChat_CheckUiManager(); } if (Mods.Count() > 0) { for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { try { mod.OnUpdate(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } } }
public static void OnApplicationQuit() { if (Mods.Count() > 0) { for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { try { mod.OnApplicationQuit(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } ModPrefs.SaveConfig(); } Harmony.HarmonyInstance.UnpatchAllInstances(); Imports.UNLOAD_MELONLOADER(); if (Imports.IsQuitFix()) { Process.GetCurrentProcess().Kill(); } }
private static void VRChat_CheckUiManager() { if (ShouldCheckForUiManager) { if (VRCUiManager == null) { VRCUiManager = Assembly_CSharp.GetType("VRCUiManager"); } if (VRCUiManager != null) { if (VRCUiManager_Instance == null) { VRCUiManager_Instance = VRCUiManager.GetProperty("field_Protected_Static_VRCUiManager_0"); } if (VRCUiManager_Instance != null) { object returnval = VRCUiManager_Instance.GetValue(null, new object[0]); if (returnval != null) { ShouldCheckForUiManager = false; if (Mods.Count() > 0) { for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { try { mod.VRChat_OnUiManagerInit(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } } } } } } }
private static void Initialize() { if (string.IsNullOrEmpty(AppDomain.CurrentDomain.BaseDirectory)) { ((AppDomainSetup)typeof(AppDomain).GetProperty("SetupInformationNoCopy", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(AppDomain.CurrentDomain, new object[0])).ApplicationBase = Imports.GetGameDirectory(); } Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); AppDomain.CurrentDomain.UnhandledException += ExceptionHandler; CurrentGameAttribute = new MelonModGameAttribute(Imports.GetCompanyName(), Imports.GetProductName()); UnityVersion = GetUnityFileVersion(); if (Imports.IsIl2CppGame()) { IsVRChat = CurrentGameAttribute.IsGame("VRChat", "VRChat"); IsBoneworks = CurrentGameAttribute.IsGame("Stress Level Zero", "BONEWORKS"); } if (!Imports.IsDebugMode()) { Console.Enabled = true; Console.Create(); } if (Imports.IsIl2CppGame() && !AssemblyGenerator.Main.Initialize()) { Imports.UNLOAD_MELONLOADER(true); } else { LoadMods(true); if (Mods.Count > 0) { for (int i = 0; i < Mods.Count; i++) { MelonMod mod = Mods[i]; if (mod != null) { try { mod.OnPreInitialization(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } } } }
private static void VRChat_CheckUiManager() { if (IsInitialized && ShouldCheckForUiManager) { if (VRCUiManager == null) { VRCUiManager = NET_SDK.SDK.GetClass("VRCUiManager"); } if (VRCUiManager != null) { if (VRCUiManager_GetInstance == null) { NET_SDK.Reflection.IL2CPP_Method[] methods = VRCUiManager.GetMethods(); foreach (NET_SDK.Reflection.IL2CPP_Method method in methods) { NET_SDK.Reflection.IL2CPP_Type returntype = method.GetReturnType(); if ((returntype != null) && !string.IsNullOrEmpty(returntype.Name) && returntype.Name.Equals("VRCUiManager")) { if (method.HasFlag(NET_SDK.Reflection.IL2CPP_BindingFlags.METHOD_STATIC)) { VRCUiManager_GetInstance = method; break; } } } } if (VRCUiManager_GetInstance != null) { NET_SDK.Reflection.IL2CPP_Object returnval = VRCUiManager_GetInstance.Invoke(); if (returnval != null) { ShouldCheckForUiManager = false; if (Mods.Count() > 0) { foreach (MelonMod mod in Mods) { try { mod.VRChat_OnUiManagerInit(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); } } } } } } } }