コード例 #1
0
ファイル: CCBase.cs プロジェクト: XCVG/commoncore
        internal static void OnApplicationQuit()
        {
            Debug.Log("[Core] Cleaning up CommonCore...");

            //execute quit methods and unload modules
            foreach (CCModule m in Modules)
            {
                try
                {
                    Debug.Log("[Core] Unloading module " + m.GetType().Name);
                    m.Dispose();
                }
                catch (Exception e)
                {
                    Debug.LogError("[Core] Failed to cleanly unload module " + m.GetType().Name);
                    Debug.LogException(e);
                }
            }

            Modules = null;
            CoreUtils.CollectGarbage(true);
            Terminated = true;

            Debug.Log("[Core] ...done!");
        }
コード例 #2
0
ファイル: CCBase.cs プロジェクト: XCVG/commoncore
        //synchronous startup method
        public static void Startup()
        {
            Initializing = true;
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();

            Debug.Log("[Core] Starting up CommonCore...");
            DoInitialSetup();

            var allModules = GetAllModuleTypes();

            InitializeExplicitModules(allModules);
            InitializeResourceManager();
            PrintSystemData(); //we wait until the console is loaded so we can see it in the console
            InitializeModules(allModules);
            SetupModuleLookupTable();
            ExecuteAllModulesLoaded();

            //mod loading can't happen synchronously
            AddonManager.WarnIfUnsupported();
            AddonManager.WarnOnSyncLoad();
            ExecuteAllAddonsLoaded();

            CoreUtils.CollectGarbage(true);

            Initialized  = true;
            Initializing = false;

            stopwatch.Stop();

            Debug.Log($"[Core] ...done! ({stopwatch.Elapsed.TotalMilliseconds:F4} ms)");
        }
コード例 #3
0
ファイル: CCBase.cs プロジェクト: XCVG/commoncore
        //async startup method (not implemented)
        public static async void StartupAsync()
        {
            Initializing = true;
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();

            Debug.Log("[Core] Starting up CommonCore asynchronously...");

            try
            {
                await Task.Yield(); //wait for a scene transition if we had to do that

                DoInitialSetup();

                var allModules = GetAllModuleTypes();
                await InitializeExplicitModulesAsync(allModules);

                InitializeResourceManager(); //this will be made async someday I think
                PrintSystemData();           //we wait until the console is loaded so we can see it in the console
                await InitializeModulesAsync(allModules);

                SetupModuleLookupTable();
                ExecuteAllModulesLoaded();

                //mod loading will happen here
                AddonManager.WarnIfUnsupported();
                await AddonManager.LoadStreamingAssetsAsync(ExecuteAddonLoaded);

                await AddonManager.LoadAddonsAsync(ExecuteAddonLoaded);

                ExecuteAllAddonsLoaded();

                CoreUtils.CollectGarbage(true);

                Initialized = true;
            }
            catch (Exception e)
            {
                Debug.LogError("[Core] Fatal error");
                Debug.LogException(e);
            }
            finally
            {
                stopwatch.Stop();
                Debug.Log($"[Core] ...done! ({stopwatch.Elapsed.TotalMilliseconds:F4} ms)");
                Initializing = false;
            }
        }