void OnLevelWasLoaded(int level) { if (Application.loadedLevelName == "MainMenu") { CurrentGameScene = CurrentScene.MainMenu; if (GameObject.Find("Music")) { GameObject.Find("Music").GetComponent <AudioSource>().Play(); } if (QualitySettings.vSyncCount != 0) { vse = true; } if ((bool)ModSettings_menu.forceMenuVsync.GetValue() && !vse) { QualitySettings.vSyncCount = 1; } if (IsDoneLoading && GameObject.Find("MSCLoader Info") == null) { MainMenuInfo(); } if (IsModsDoneLoading) { loaderPrepared = false; mscUnloader.MSCLoaderReset(); unloader = true; } } else if (Application.loadedLevelName == "Intro") { CurrentGameScene = CurrentScene.NewGameIntro; newGameStarted = true; } else if (Application.loadedLevelName == "GAME") { CurrentGameScene = CurrentScene.Game; if ((bool)ModSettings_menu.forceMenuVsync.GetValue() && !vse) { QualitySettings.vSyncCount = 0; } (LoadedMods.First(mod => mod.ID == "MSCLoader_Settings") as ModSettings_menu).ButtonHandler(); StartCoroutine(LoadMods()); } }
private void OnLevelWasLoaded(int level) { if (Application.loadedLevelName == "MainMenu") { CurrentGameScene = CurrentScene.MainMenu; if ((bool)ModSettings_menu.forceMenuVsync.GetValue()) { QualitySettings.vSyncCount = 1; //vsync in menu } if (IsDoneLoading && GameObject.Find("MSCLoader Info") == null) { MainMenuInfo(); } if (IsModsDoneLoading) { loaderPrepared = false; mscUnloader.MSCLoaderReset(); unloader = true; return; } } else if (Application.loadedLevelName == "Intro") { CurrentGameScene = CurrentScene.NewGameIntro; if (!IsModsDoneResetting && !IsModsResetting) { IsModsResetting = true; StartCoroutine(NewGameMods()); } } else if (Application.loadedLevelName == "GAME") { CurrentGameScene = CurrentScene.Game; if ((bool)ModSettings_menu.forceMenuVsync.GetValue()) { QualitySettings.vSyncCount = 0; } if (IsDoneLoading) { menuInfoAnim.SetBool("isHidden", true); } } }
private void OnLevelWasLoaded(int level) { if (Application.loadedLevelName == "MainMenu") { QualitySettings.vSyncCount = 1; //vsync in menu (test) if (IsDoneLoading && GameObject.Find("MSCLoader Info") == null) { MainMenuInfo(); } if (IsModsDoneLoading) { loaderPrepared = false; mscUnloader.MSCLoaderReset(); unloader = true; return; } } else if (Application.loadedLevelName == "Intro") { if (!IsModsDoneResetting && !IsModsResetting) { IsModsResetting = true; StartCoroutine(NewGameMods()); } } else if (Application.loadedLevelName == "GAME") { QualitySettings.vSyncCount = 0; if (IsDoneLoading) { menuInfoAnim.SetBool("isHidden", true); } } }
/// <summary> /// Main function to initialize the ModLoader /// </summary> public static void Init() { //Set config and Assets folder in selected mods folder ConfigFolder = Path.Combine(ModsFolder, @"Config\"); AssetsFolder = Path.Combine(ModsFolder, @"Assets\"); //if mods not loaded and game is loaded. if (GameObject.Find("MSCUnloader") == null) { GameObject go = new GameObject(); go.name = "MSCUnloader"; go.AddComponent <MSCUnloader>(); MSCUnloaderInstance = go.GetComponent <MSCUnloader>(); DontDestroyOnLoad(go); } if (IsModsDoneLoading && Application.loadedLevelName == "MainMenu") { MSCUnloaderInstance.reset = false; MSCUnloaderInstance.MSCLoaderReset(); } if (!IsModsDoneLoading && Application.loadedLevelName == "GAME") { // Load all mods ModConsole.Print("Loading mods..."); Stopwatch s = new Stopwatch(); s.Start(); LoadMods(); ModSettings.LoadBinds(); IsModsDoneLoading = true; s.Stop(); if (s.ElapsedMilliseconds < 1000) { ModConsole.Print(string.Format("Loading mods completed in {0}ms!", s.ElapsedMilliseconds)); } else { ModConsole.Print(string.Format("Loading mods completed in {0} sec(s)!", s.Elapsed.Seconds)); } } if (IsDoneLoading && Application.loadedLevelName == "MainMenu" && GameObject.Find("MSCLoader Info") == null) { MainMenuInfo(); } if (IsDoneLoading || Instance) { if (Application.loadedLevelName != "MainMenu") { menuInfoAnim.SetBool("isHidden", true); } if (Application.loadedLevelName != "GAME") { ModConsole.Print("<color=#505050ff>MSCLoader is already loaded!</color>");//debug } } else { // Create game object and attach self GameObject go = new GameObject(); go.name = "MSCModLoader"; go.AddComponent <ModLoader>(); go.AddComponent <LoadAssets>(); Instance = go.GetComponent <ModLoader>(); loadAssets = go.GetComponent <LoadAssets>(); DontDestroyOnLoad(go); // Init variables ModUI.CreateCanvas(); IsDoneLoading = false; IsModsDoneLoading = false; LoadedMods = new List <Mod>(); InvalidMods = new List <string>(); // Init mod loader settings if (!Directory.Exists(ModsFolder)) { //if mods folder not exists, create it. Directory.CreateDirectory(ModsFolder); } if (!Directory.Exists(ConfigFolder)) { //if config folder not exists, create it. Directory.CreateDirectory(ConfigFolder); } if (!Directory.Exists(AssetsFolder)) { //if config folder not exists, create it. Directory.CreateDirectory(AssetsFolder); } // Loading internal tools (console and settings) LoadMod(new ModConsole(), Version); LoadMod(new ModSettings(), Version); IsDoneLoading = true; ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color>", Version)); PreLoadMods(); ModConsole.Print(string.Format("<color=orange>Found <color=green><b>{0}</b></color> mods!</color>", LoadedMods.Count - 2)); try { Steamworks.SteamAPI.Init(); steamID = Steamworks.SteamUser.GetSteamID().ToString(); ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", Steamworks.SteamFriends.GetPersonaName())); if (!modStats) { ModStats(); modStats = true; } } catch (Exception) { ModConsole.Error("Steam not detected, only steam version is supported."); } ModConsole.Print("Loading core assets..."); Instance.StartCoroutine(Instance.LoadSkin()); } }
/// <summary> /// Main function to initialize the ModLoader /// </summary> public static void Init() { //Set config and Assets folder in selected mods folder ConfigFolder = Path.Combine(ModsFolder, @"Config\"); AssetsFolder = Path.Combine(ModsFolder, @"Assets\"); //if mods not loaded and game is loaded. if (GameObject.Find("MSCUnloader") == null) { GameObject go = new GameObject(); go.name = "MSCUnloader"; go.AddComponent <MSCUnloader>(); MSCUnloaderInstance = go.GetComponent <MSCUnloader>(); DontDestroyOnLoad(go); } if (IsModsDoneLoading && Application.loadedLevelName == "MainMenu") { MSCUnloaderInstance.reset = false; MSCUnloaderInstance.MSCLoaderReset(); } if (!IsModsDoneLoading && Application.loadedLevelName == "GAME" && fullyLoaded && !IsModsLoading) { // Load all mods IsModsLoading = true; Instance.StartCoroutine(Instance.LoadMods()); } if (IsDoneLoading && Application.loadedLevelName == "MainMenu" && GameObject.Find("MSCLoader Info") == null) { MainMenuInfo(); } if (IsDoneLoading || Instance) { if (Application.loadedLevelName != "MainMenu") { menuInfoAnim.SetBool("isHidden", true); } } else { // Create game object and attach self GameObject go = new GameObject(); go.name = "MSCModLoader"; go.AddComponent <ModLoader>(); go.AddComponent <LoadAssets>(); Instance = go.GetComponent <ModLoader>(); loadAssets = go.GetComponent <LoadAssets>(); DontDestroyOnLoad(go); // Init variables ModUI.CreateCanvas(); IsDoneLoading = false; IsModsDoneLoading = false; LoadedMods = new List <Mod>(); InvalidMods = new List <string>(); // Init mod loader settings if (!Directory.Exists(ModsFolder)) { //if mods folder not exists, create it. Directory.CreateDirectory(ModsFolder); } if (!Directory.Exists(ConfigFolder)) { //if config folder not exists, create it. Directory.CreateDirectory(ConfigFolder); } if (!Directory.Exists(AssetsFolder)) { //if config folder not exists, create it. Directory.CreateDirectory(AssetsFolder); } // Loading internal tools (console and settings) LoadMod(new ModConsole(), Version); LoadedMods[0].ModSettings(); LoadMod(new ModSettings_menu(), Version); LoadedMods[1].ModSettings(); ModSettings_menu.LoadSettings(); LoadCoreAssets(); IsDoneLoading = true; ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color>", Version)); LoadReferences(); PreLoadMods(); ModConsole.Print(string.Format("<color=orange>Found <color=green><b>{0}</b></color> mods!</color>", LoadedMods.Count - 2)); try { if (File.Exists(Path.GetFullPath(Path.Combine("LAUNCHER.exe", ""))) || File.Exists(Path.GetFullPath(Path.Combine("SmartSteamEmu64.dll", ""))) || File.Exists(Path.GetFullPath(Path.Combine("SmartSteamEmu.dll", "")))) { ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", "PIRATE IS FREE!!!")); throw new Exception("Do What You Want, Cause A Pirate Is Free... You Are A Pirate!"); //exclude emulators from stats (spam weird stuff sometimes) } Steamworks.SteamAPI.Init(); steamID = Steamworks.SteamUser.GetSteamID().ToString(); ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", Steamworks.SteamFriends.GetPersonaName())); if (!modStats) { ModStats(); modStats = true; } string Name; bool ret = Steamworks.SteamApps.GetCurrentBetaName(out Name, 128); if (ret && !(bool)ModSettings_menu.expWarning.GetValue()) { ModUI.ShowMessage(string.Format("<color=orange><b>Warning:</b></color>{1}You are using beta build: <color=orange><b>{0}</b></color>{1}{1}Remember that some mods may not work correctly on beta branches.", Name, Environment.NewLine), "Experimental build warning"); } } catch (Exception e) { ModConsole.Error("Steam not detected, only steam version is supported."); UnityEngine.Debug.Log(e); } MainMenuInfo(); LoadModsSettings(); } }