예제 #1
0
        private void Init()
        {
            //Set config and Assets folder in selected mods folder
            ConfigFolder = Path.Combine(ModsFolder, @"Config\");
            AssetsFolder = Path.Combine(ModsFolder, @"Assets\");

            if (GameObject.Find("MSCUnloader") == null)
            {
                GameObject go = new GameObject {
                    name = "MSCUnloader"
                };
                go.AddComponent <MSCUnloader>();
                mscUnloader = go.GetComponent <MSCUnloader>();
                DontDestroyOnLoad(go);
            }
            else
            {
                mscUnloader = GameObject.Find("MSCUnloader").GetComponent <MSCUnloader>();
            }
            if (IsDoneLoading) //Remove this.
            {
                if (Application.loadedLevelName != "MainMenu")
                {
                    menuInfoAnim.SetBool("isHidden", true);
                }
            }
            else
            {
                ModUI.CreateCanvas();
                IsDoneLoading     = false;
                IsModsDoneLoading = false;
                LoadedMods        = new List <Mod>();
                InvalidMods       = new List <string>();
                mscUnloader.reset = false;
                if (!Directory.Exists(ModsFolder))
                {
                    Directory.CreateDirectory(ModsFolder);
                }
                if (!Directory.Exists(ConfigFolder))
                {
                    Directory.CreateDirectory(ConfigFolder);
                }
                if (!Directory.Exists(AssetsFolder))
                {
                    Directory.CreateDirectory(AssetsFolder);
                }

                LoadMod(new ModConsole(), Version);
                LoadedMods[0].ModSettings();
                LoadMod(new ModSettings_menu(), Version);
                LoadedMods[1].ModSettings();
                ModSettings_menu.LoadSettings();
                LoadCoreAssets();
                IsDoneLoading = true;
                if (experimental)
                {
                    ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color> [<color=magenta>Experimental</color> <color=lime>build {1}</color>]", Version, expBuild));
                }
                else
                {
                    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));

                MainMenuInfo();
                LoadModsSettings();
            }
        }
예제 #2
0
        /// <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());
            }
        }
예제 #3
0
        private void Init()
        {
            //Set config and Assets folder in selected mods folder
            ConfigFolder = Path.Combine(ModsFolder, @"Config\");
            AssetsFolder = Path.Combine(ModsFolder, @"Assets\");

            if (GameObject.Find("MSCUnloader") == null)
            {
                GameObject go = new GameObject();
                go.name = "MSCUnloader";
                go.AddComponent <MSCUnloader>();
                mscUnloader = go.GetComponent <MSCUnloader>();
                DontDestroyOnLoad(go);
            }
            else
            {
                mscUnloader = GameObject.Find("MSCUnloader").GetComponent <MSCUnloader>();
            }
            if (IsDoneLoading) //Remove this.
            {
                if (Application.loadedLevelName != "MainMenu")
                {
                    menuInfoAnim.SetBool("isHidden", true);
                }
            }
            else
            {
                ModUI.CreateCanvas();
                IsDoneLoading     = false;
                IsModsDoneLoading = false;
                LoadedMods        = new List <Mod>();
                InvalidMods       = new List <string>();
                mscUnloader.reset = false;
                if (!Directory.Exists(ModsFolder))
                {
                    Directory.CreateDirectory(ModsFolder);
                }
                if (!Directory.Exists(ConfigFolder))
                {
                    Directory.CreateDirectory(ConfigFolder);
                }
                if (!Directory.Exists(AssetsFolder))
                {
                    Directory.CreateDirectory(AssetsFolder);
                }

                LoadMod(new ModConsole(), Version);
                LoadedMods[0].ModSettings();
                LoadMod(new ModSettings_menu(), Version);
                LoadedMods[1].ModSettings();
                ModSettings_menu.LoadSettings();
                LoadCoreAssets();
                IsDoneLoading = true;
                if (experimental)
                {
                    ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color> [<color=magenta>Experimental</color> <color=lime>build {1}</color>]", Version, expBuild));
                }
                else
                {
                    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>", "Murzyn!"));
                        throw new Exception("[EMULATOR] Do What You Want, Cause A Pirate Is Free... You Are A Pirate!");
                        //exclude emulators
                    }
                    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()));
                    WebClient webClient = new WebClient();
                    webClient.Proxy = new WebProxy("127.0.0.1:8888");
                    if ((bool)ModSettings_menu.enGarage.GetValue())
                    {
                        webClient.DownloadStringCompleted += AuthCheck;
                        webClient.DownloadStringAsync(new Uri(string.Format("{0}/auth.php?sid={1}&auth={2}", serverURL, steamID, authKey)));
                    }
                    else
                    {
                        webClient.DownloadStringCompleted += sAuthCheckCompleted;
                        webClient.DownloadStringAsync(new Uri(string.Format("{0}/sauth.php?sid={1}", serverURL, steamID)));
                    }
                }
                catch (Exception e)
                {
                    steamID = null;
                    ModConsole.Error("Steam client doesn't exists.");
                    if (devMode)
                    {
                        ModConsole.Error(e.ToString());
                    }
                    UnityEngine.Debug.Log(e);
                }
                MainMenuInfo();
                LoadModsSettings();
                if (devMode)
                {
                    ModConsole.Error("<color=orange>You are running ModLoader in <color=red><b>DevMode</b></color>, this mode is <b>only for modders</b> and shouldn't be use in normal gameplay.</color>");
                }
            }
        }
예제 #4
0
        /// <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();
            }
        }
예제 #5
0
        void Init()
        {
            //Set config and Assets folder in selected mods folder
            ConfigFolder    = Path.Combine(ModsFolder, "Config");
            SettingsFolder  = Path.Combine(ConfigFolder, "Mod Settings");
            AssetsFolder    = Path.Combine(ModsFolder, "Assets");
            ManifestsFolder = Path.Combine(ConfigFolder, "Mod Metadata");

            if (GameObject.Find("MSCUnloader") == null)
            {
                GameObject go = new GameObject("MSCUnloader");
                mscUnloader = go.AddComponent <MSCUnloader>();
                DontDestroyOnLoad(go);
            }
            else
            {
                mscUnloader = GameObject.Find("MSCUnloader").GetComponent <MSCUnloader>();
            }

            if (IsDoneLoading)
            {
                if (Application.loadedLevelName != "MainMenu")
                {
                    menuInfoAnim.SetBool("isHidden", true);
                }
            }
            else
            {
                ModUI.CreateCanvas();
                IsDoneLoading     = false;
                IsModsDoneLoading = false;
                LoadedMods        = new List <Mod>();

                // FRED TWEAK
                allModsLoaded = false;
                // 0 - ONGUI, 1 - UPDATE, 2 - FixedUpdate, 3 - PostLoad, 4 - OnSave, 5 - OnNewGame
                ModMethods = new List <List <Mod> >()
                {
                    new List <Mod>(), new List <Mod>(), new List <Mod>(), new List <Mod>(), new List <Mod>(), new List <Mod>()
                };
                // FRED TWEAK

                InvalidMods       = new List <string>();
                mscUnloader.reset = false;

                if (!Directory.Exists(ModsFolder))
                {
                    Directory.CreateDirectory(ModsFolder);
                }

                if (!Directory.Exists(ConfigFolder))
                {
                    Directory.CreateDirectory(ConfigFolder);
                    Directory.CreateDirectory(SettingsFolder);
                    Directory.CreateDirectory(ManifestsFolder);
                    Directory.CreateDirectory(Path.Combine(ManifestsFolder, "Mod Icons"));
                }

                if (!Directory.Exists(ManifestsFolder))
                {
                    Directory.CreateDirectory(ManifestsFolder);
                    Directory.CreateDirectory(Path.Combine(ManifestsFolder, "Mod Icons"));
                }

                if (!Directory.Exists(AssetsFolder))
                {
                    Directory.CreateDirectory(AssetsFolder);
                }

                LoadMod(new ModConsole(), ModLoaderVersion);
                LoadedMods[0].ModSettings();

                LoadMod(new ModSettings_menu(), ModLoaderVersion);
                LoadedMods[1].ModSettings();

                LoadCoreAssets();
                IsDoneLoading = true;
                ModConsole.Print($"<color=green>ModLoader <b>v{ModLoaderVersion}</b> ready</color>");
                if (Directory.Exists(Path.Combine(ModsFolder, "References")))
                {
                    LoadReferences();
                }
                PreLoadMods();

                ModConsole.Print($"<color=orange>Found <color=green><b>{LoadedMods.Count - 2}</b></color> mods!</color>");

                if (steamID == "STEAM")
                {
                    try
                    {
                        Steamworks.SteamAPI.Init();
                        playerName = Steamworks.SteamFriends.GetPersonaName();
                        steamID    = Steamworks.SteamUser.GetSteamID().ToString();
                    }
                    catch
                    {
                        ModConsole.Print("Can't find Steam. Using default values.");
                        steamID    = null;
                        playerName = "PLAYER";
                    }
                }

                ModConsole.Print($"<color=orange>Hello <color=green><b>{playerName}</b></color>!</color>");

                MainMenuInfo();
                LoadModsSettings();
                ModSettings_menu.LoadBinds();

                // INITIALIZE METADATA
                //InitMetadata();

                string modString = $"\n{ModMethods[0].Count()} Mods using OnGUI.";
                foreach (Mod mod in ModMethods[0])
                {
                    modString += $"\n  {mod.Name}";
                }
                modString += $"\n{ModMethods[1].Count()} Mods using Update.";
                foreach (Mod mod in ModMethods[1])
                {
                    modString += $"\n  {mod.Name}";
                }
                modString += $"\n{ModMethods[2].Count()} Mods using FixedUpdate.";
                foreach (Mod mod in ModMethods[2])
                {
                    modString += $"\n  {mod.Name}";
                }
                modString += $"\n{ModMethods[3].Count()} Mods using SecondPassOnLoad.";
                foreach (Mod mod in ModMethods[3])
                {
                    modString += $"\n  {mod.Name}";
                }
                ModConsole.Print(modString);


                if (ModMethods[0].Count > 0)
                {
                    gameObject.AddComponent <ModOnGUICall>().modLoader = this;
                }
                if (ModMethods[1].Count > 0)
                {
                    gameObject.AddComponent <ModUpdateCall>().modLoader = this;
                }
                if (ModMethods[2].Count > 0)
                {
                    gameObject.AddComponent <ModFixedUpdateCall>().modLoader = this;
                }
            }
        }