/// <summary>
        /// Reloads all contract types from the config nodes.  Also re-runs ModuleManager if it is installed.
        /// </summary>
        private IEnumerator <YieldInstruction> ReloadContractTypes()
        {
            reloading  = true;
            reloadStep = ReloadStep.GAME_DATABASE;

            GameDatabase.Instance.Recompile = true;
            GameDatabase.Instance.StartLoad();

            // Wait for the reload
            while (!GameDatabase.Instance.IsReady())
            {
                yield return(new WaitForEndOfFrame());
            }

            // Attempt to find module manager and do their reload
            reloadStep = ReloadStep.MODULE_MANAGER;
            var allMM = from loadedAssemblies in AssemblyLoader.loadedAssemblies
                        let assembly = loadedAssemblies.assembly
                                       where assembly.GetName().Name.StartsWith("ModuleManager")
                                       orderby assembly.GetName().Version descending, loadedAssemblies.path ascending
            select loadedAssemblies;

            // Reload module manager
            if (allMM.Count() > 0)
            {
                Assembly mmAssembly = allMM.First().assembly;
                LoggingUtil.LogVerbose(this, "Reloading config using ModuleManager: " + mmAssembly.FullName);

                // Get the module manager object
                Type          mmPatchType   = mmAssembly.GetType("ModuleManager.MMPatchLoader");
                LoadingSystem mmPatchLoader = (LoadingSystem)FindObjectOfType(mmPatchType);

                // Do the module manager load
                mmPatchLoader.StartLoad();
                while (!mmPatchLoader.IsReady())
                {
                    yield return(new WaitForEndOfFrame());
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reloads all contract types from the config nodes.  Also re-runs ModuleManager if it is installed.
        /// </summary>
        private IEnumerator <YieldInstruction> ReloadContractTypes()
        {
            reloading  = true;
            reloadStep = ReloadStep.GAME_DATABASE;

            GameDatabase.Instance.Recompile = true;
            GameDatabase.Instance.StartLoad();

            // Wait for the reload
            while (!GameDatabase.Instance.IsReady())
            {
                yield return(new WaitForEndOfFrame());
            }

            // Attempt to find module manager and do their reload
            reloadStep = ReloadStep.MODULE_MANAGER;
            var allMM = from loadedAssemblies in AssemblyLoader.loadedAssemblies
                        let assembly = loadedAssemblies.assembly
                                       where assembly.GetName().Name.StartsWith("ModuleManager")
                                       orderby assembly.GetName().Version descending, loadedAssemblies.path ascending
            select loadedAssemblies;

            // Reload module manager
            if (allMM.Count() > 0)
            {
                Assembly mmAssembly = allMM.First().assembly;
                LoggingUtil.LogVerbose(this, "Reloading config using ModuleManager: " + mmAssembly.FullName);

                // Get the module manager object
                Type          mmPatchType   = mmAssembly.GetType("ModuleManager.MMPatchLoader");
                LoadingSystem mmPatchLoader = (LoadingSystem)FindObjectOfType(mmPatchType);

                // Do the module manager load
                mmPatchLoader.StartLoad();
                while (!mmPatchLoader.IsReady())
                {
                    yield return(new WaitForEndOfFrame());
                }
            }

            // Clear contract configurator
            reloadStep = ReloadStep.CLEAR_CONFIG;
            yield return(new WaitForEndOfFrame());

            ClearContractConfig();

            // Load contract configurator
            reloadStep = ReloadStep.LOAD_CONFIG;
            IEnumerator <YieldInstruction> iterator = LoadContractConfig();

            while (iterator.MoveNext())
            {
                yield return(iterator.Current);
            }

            // Adjust contract types
            reloadStep = ReloadStep.ADJUST_TYPES;
            yield return(new WaitForEndOfFrame());

            AdjustContractTypes();

            // We're done!
            reloading = false;
            ScreenMessages.PostScreenMessage("Loaded " + successContracts + " out of " + totalContracts
                                             + " contracts successfully.", 5, ScreenMessageStyle.UPPER_CENTER);

            yield return(new WaitForEndOfFrame());

            DebugWindow.scrollPosition  = new Vector2();
            DebugWindow.scrollPosition2 = new Vector2();
        }