Esempio n. 1
0
        private IEnumerator Start()
        {
            //Locate files in CSData folder
            Stopwatch loading = Stopwatch.StartNew();

            this.watch = Stopwatch.StartNew();
            yield return(FindAllFiles());

            this.watch.Stop();
            Log($"Found {this.allFiles.Count} files in {this.watch.Elapsed.TotalSeconds}s");

            //Set current working directory to CSData directory
            CSUtils.SetCurrentDirectory(CSUtils.CSDataPath);

            //Load all external assemblies
            this.watch.Restart();
            yield return(LoadAllDlls());

            EndLoader();
            Log($"Loaded {LoadedAssemblies.Count} external assemblies in {this.watch.Elapsed.TotalSeconds}s");

            //Find all loader implementations
            this.watch.Restart();
            yield return(FetchAllLoaders());

            EndLoader();
            Log($"Located {loaders.Count} ILoader implementations and {jsonLoaders.Count} IJsonLoader implementations in {this.watch.Elapsed.TotalSeconds}s");

            //Run all Json loaders
            this.watch.Restart();
            yield return(RunAllJsonLoaders());

            EndLoader();
            Log($"Ran {jsonLoaders.Count} IJsonLoaders in {this.watch.Elapsed.TotalSeconds}s");

            //Run all classic loaders
            this.watch.Restart();
            yield return(RunAllLoaders());

            EndLoader();
            this.loadingbar.SetLabel("Complete");
            this.loadingbar.SetProgress(1);
            Log($"Ran {loaders.Count} ILoaders in {this.watch.Elapsed.TotalSeconds}s");

            //Reset workind directory
            CSUtils.ResetCurrentDirectory();

            //Reset lists size
            loaders          = new List <ILoader>(loaders);
            jsonLoaders      = new List <IJsonLoader>(jsonLoaders);
            assembliesByPath = new Dictionary <string, LoadedAssembly>(assembliesByPath);
            assembliesByName = new Dictionary <string, LoadedAssembly>(assembliesByName);

            //Complete
            loading.Stop();
            Loaded = true;
            Log($"Completed loading sequence in {loading.Elapsed.TotalSeconds}s, going to main menu...");

            yield return(new WaitForSeconds(1));

            GameLogic.Instance.LoadScene(GameScenes.MAIN_MENU);
        }