Exemple #1
0
        //loads the current game and world
        //starts it up
        protected IEnumerator LoadOverTime()
        {
            Biomes.Get.UseTimeOfDayOverride = false;
            if (mStartupScenePrefab != null)
            {
                GameObject.Destroy(mStartupScenePrefab, 0.5f);
            }
            //Load all the things!
            yield return(StartCoroutine(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack)));

            GUILoading.Lock(this);
            string detailsInfo = string.Empty;

            //load all textures first
            //------------------
            Manager.TexturesLoadStart();
            //------------------
            yield return(null);

            GUILoading.ActivityInfo = "Loading Textures";
            GUILoading.DetailsInfo  = "Compiling mods";
            while (!Manager.FinishedLoadingTextures)
            {
                yield return(null);
            }
            GUILoading.ActivityInfo = "Generating World";
            GUILoading.DetailsInfo  = "Compiling mods";
            yield return(null);

            //------------------
            Manager.ModsLoadStart();
            //------------------
            //wait for the actual mods manager to finish loading mods
            while (!Mods.Get.ModsLoaded)
            {
                yield return(null);
            }
            //------------------
            Manager.ModsLoadFinish();
            //------------------
            yield return(null);

            //then jump straight ahead to the world loading
            GUILoading.ActivityInfo = "Loading World";
            GUILoading.DetailsInfo  = "Loading mods from generated world";
            //during this section we report on what the world manager is doing
            //it accomplishes nothing but looks nice on the loading screen
            GUILoading.ActivityInfo = "Creating World";
            while (GameWorld.Get.LoadingGameWorld(out detailsInfo))              //report GameWorld progress as it loads the game
            {
                yield return(null);

                GUILoading.DetailsInfo = detailsInfo;
            }
            //wait for other mods as normal
            //------------------
            while (!Manager.FinishedLoadingMods)
            {
                //Debug.Log ("Waiting for mods to finish loading");
                yield return(null);
            }
            //this only happens once per game
            if (!Profile.Get.CurrentGame.HasLoadedOnce)
            {
                GUILoading.ActivityInfo = "Creating World for First Time";
                //Debug.Log ("Creating world for first time");
                //------------------
                Manager.GameLoadStartFirstTime();
                //------------------
            }
            yield return(null);

            //------------------
            Manager.GameLoadStart();
            //------------------
            //give managers a tick to figure out what they're doing
            yield return(null);

            //------------------
            Manager.GameLoadFinish();
            //------------------
            while (!Manager.FinishedLoading)
            {
                //Debug.Log ("Waiting to finish loading...");
                yield return(null);
            }
            //during this section we report on what the spawn manager is up to
            while (SpawnManager.Get.SpawningPlayer(out detailsInfo))
            {
                yield return(null);

                GUILoading.DetailsInfo = detailsInfo;
            }
            //start the game!
            gState = FGameState.GameStarting;
            //wait a tick
            yield return(null);

            //this only happens once per game
            if (!Profile.Get.CurrentGame.HasStarted)
            {
                //------------------
                Manager.GameStartFirstTime();
                //------------------
                Profile.Get.CurrentGame.HasStarted = true;
                yield return(null);
            }
            //------------------
            Manager.GameStart();
            //------------------
            yield return(null);

            if (NetworkManager.Instance.IsHost)
            {
                //if we're the host, then the game can begin here
                //HostState = NHostState.Started;
            }
            //we pause the game immediately while we wait for the player to spawn
            //------------------
            Manager.GamePause();
            //------------------
            yield return(null);

            //save the game so we know that we've started once
            Profile.Get.SaveCurrent(ProfileComponents.Profile);
            //wait for the player to finish spawning then turn off the loading screen
            while (!Player.Local.HasSpawned)
            {
                //Debug.Log("Waiting for player to spawn");
                yield return(null);
            }
            //turn off the loading screen
            GUILoading.Unlock(this);
            yield return(StartCoroutine(GUILoading.LoadFinish()));

            //now that the player has spawned continue the game
            //------------------
            Manager.GameContinue();
            //------------------
            //this will set the state to InGame
            yield break;
        }