예제 #1
0
    /// <summary>
    /// General subscene loader
    /// </summary>
    /// <param name="sceneName"></param>
    /// <returns></returns>
    IEnumerator LoadSubScene(string sceneName, SubsceneLoadTimer loadTimer = null)
    {
        AsyncOperation AO = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);

        while (!AO.isDone)
        {
            if (loadTimer != null)
            {
                loadTimer.IncrementLoadBar();
            }
            yield return(WaitFor.EndOfFrame);
        }

        if (loadTimer != null)
        {
            loadTimer.IncrementLoadBar();
        }
        if (isServer)
        {
            NetworkServer.SpawnObjects();
        }
        else
        {
            ClientScene.PrepareToSpawnSceneObjects();
            yield return(WaitFor.Seconds(0.2f));

            RequestObserverRefresh.Send(sceneName);
        }
    }
    IEnumerator RoundStartServerLoadSequence()
    {
        var loadTimer = new SubsceneLoadTimer();

        //calculate load time:
        loadTimer.MaxLoadTime = 20f + (asteroidList.Asteroids.Count * 10f);
        loadTimer.IncrementLoadBar("Preparing..");

        //Choose and load a mainstation
        yield return(StartCoroutine(ServerLoadMainStation(loadTimer)));

        if (GameManager.Instance.QuickLoad == false)
        {
            //Load Asteroids:
            yield return(StartCoroutine(ServerLoadAsteroids(loadTimer)));

            //Load away site:
            yield return(StartCoroutine(ServerLoadAwaySite(loadTimer)));

            //Load CentCom Scene:
            yield return(StartCoroutine(ServerLoadCentCom(loadTimer)));

            //Load Additional Scenes:
            yield return(StartCoroutine(ServerLoadAdditionalScenes(loadTimer)));
        }

        netIdentity.isDirty = true;

        yield return(WaitFor.Seconds(0.1f));

        UIManager.Display.preRoundWindow.CloseMapLoadingPanel();

        Logger.Log($"Server has loaded {serverChosenAwaySite} away site", Category.SubScenes);
    }
    //Choose and load a main station on the server
    IEnumerator ServerLoadMainStation(SubsceneLoadTimer loadTimer)
    {
        MainStationLoaded = true;
        //Auto scene load stuff in editor:
        var prevEditorScene = GetEditorPrevScene();

        if (mainStationList.MainStations.Contains(prevEditorScene) && AdminForcedMainStation == "Random")
        {
            serverChosenMainStation = prevEditorScene;
        }
        else if (AdminForcedMainStation == "Random")
        {
            serverChosenMainStation = mainStationList.GetRandomMainStation();
        }
        else
        {
            serverChosenMainStation = AdminForcedMainStation;
        }

        //Reset map selector
        AdminForcedMainStation = "Random";

        loadTimer.IncrementLoadBar($"Loading {serverChosenMainStation}");
        //load main station
        yield return(StartCoroutine(LoadSubScene(serverChosenMainStation, loadTimer)));

        loadedScenesList.Add(new SceneInfo
        {
            SceneName = serverChosenMainStation,
            SceneType = SceneType.MainStation
        });
    }
    IEnumerator LoadClientSubScene(SceneInfo sceneInfo, bool HandlSynchronising = true,
        SubsceneLoadTimer SubsceneLoadTimer = null, bool OverrideclientIsLoadingSubscene = false)
    {
        if (sceneInfo.SceneType == SceneType.MainStation)
        {
            if (SubsceneLoadTimer == null)
            {
                SubsceneLoadTimer = new SubsceneLoadTimer();
                //calculate load time:
                SubsceneLoadTimer.MaxLoadTime = 10f;
            }

            SubsceneLoadTimer.IncrementLoadBar($"Loading {sceneInfo.SceneName}");
            yield return StartCoroutine(LoadSubScene(sceneInfo.SceneName, SubsceneLoadTimer, HandlSynchronising));
            MainStationLoaded = true;

        }
        else
        {
            if (SubsceneLoadTimer != null)
            {
                SubsceneLoadTimer.IncrementLoadBar(sceneInfo.SceneType != SceneType.HiddenScene ?
                    $"Loading {sceneInfo.SceneName}" : "");
            }

            yield return StartCoroutine(LoadSubScene(sceneInfo.SceneName, HandlSynchronising  :HandlSynchronising ));
        }

        if (OverrideclientIsLoadingSubscene == false)
        {
            clientIsLoadingSubscene = false;
        }
    }
예제 #5
0
    //Load the away site on the server
    IEnumerator ServerLoadAwaySite(SubsceneLoadTimer loadTimer)
    {
        var prevEditorScene = GetEditorPrevScene();

        //Load the away site
        if (awayWorldList.AwayWorlds.Contains(prevEditorScene) && AdminForcedAwaySite == "Random")
        {
            serverChosenAwaySite = prevEditorScene;
        }
        else if (AdminForcedAwaySite == "Random")
        {
            serverChosenAwaySite = awayWorldList.GetRandomAwaySite();
        }
        else
        {
            serverChosenAwaySite = AdminForcedAwaySite;
        }

        AdminForcedAwaySite = "Random";

        loadTimer.IncrementLoadBar("Loading Away Site");
        if (serverChosenAwaySite.IsNullOrEmpty() == false)
        {
            yield return(StartCoroutine(LoadSubScene(serverChosenAwaySite, loadTimer)));

            AwaySiteLoaded = true;
            loadedScenesList.Add(new SceneInfo
            {
                SceneName = serverChosenAwaySite,
                SceneType = SceneType.AwaySite
            });
        }
    }
    //Choose and load a ship on the server
    IEnumerator ServerLoadShip(SubsceneLoadTimer loadTimer)
    {
        ShipLoaded = true;
        //Auto scene load stuff in editor:
        var prevEditorScene = GetEditorPrevScene();

        if (shipList.Ships.Contains(prevEditorScene) && AdminForcedShip == "Random")
        {
            serverChosenShip = prevEditorScene;
        }
        else if (AdminForcedShip == "Random")
        {
            serverChosenShip = shipList.GetRandomShip();
        }
        else
        {
            serverChosenShip = AdminForcedShip;
        }

        //Reset map selector
        AdminForcedShip = "Random";

        loadTimer.IncrementLoadBar($"Loading {serverChosenShip}");
        //load ship
        yield return(StartCoroutine(LoadSubScene(serverChosenShip, loadTimer)));

        loadedScenesList.Add(new SceneInfo
        {
            SceneName = serverChosenShip,
            SceneType = SceneType.Ship
        });
    }
    //Load the space scene on the server
    IEnumerator ServerLoadSpaceScene(SubsceneLoadTimer loadTimer)
    {
        loadTimer.IncrementLoadBar($"Loading the void of time and space");
        yield return(StartCoroutine(LoadSubScene("SpaceScene", loadTimer)));

        loadedScenesList.Add(new SceneInfo
        {
            SceneName = "SpaceScene",
            SceneType = SceneType.Space
        });
        netIdentity.isDirty = true;
    }
    //Load all the asteroids on the server
    IEnumerator ServerLoadAsteroids(SubsceneLoadTimer loadTimer)
    {
        loadTimer.IncrementLoadBar("Loading Asteroids");
        foreach (var asteroid in asteroidList.Asteroids)
        {
            yield return(StartCoroutine(LoadSubScene(asteroid, loadTimer)));

            loadedScenesList.Add(new SceneInfo
            {
                SceneName = asteroid,
                SceneType = SceneType.Asteroid
            });
        }
    }
예제 #9
0
    IEnumerator ServerLoadCentCom(SubsceneLoadTimer loadTimer)
    {
        if (GameManager.Instance.QuickLoad)
        {
            yield return(null);
        }
        loadTimer.IncrementLoadBar("Loading CentCom");

        //CENTCOM
        foreach (var centComData in additionalSceneList.CentComScenes)
        {
            if (centComData.DependentScene == null || centComData.CentComSceneName == null)
            {
                continue;
            }

            if (centComData.DependentScene != serverChosenMainStation)
            {
                continue;
            }

            yield return(StartCoroutine(LoadSubScene(centComData.CentComSceneName, loadTimer)));

            loadedScenesList.Add(new SceneInfo
            {
                SceneName = centComData.CentComSceneName,
                SceneType = SceneType.AdditionalScenes
            });
            netIdentity.isDirty = true;
            yield break;
        }

        var pickedMap = additionalSceneList.defaultCentComScenes.PickRandom();

        if (string.IsNullOrEmpty(pickedMap))
        {
            yield break;
        }

        //If no special CentCom load default.
        yield return(StartCoroutine(LoadSubScene(pickedMap, loadTimer)));

        loadedScenesList.Add(new SceneInfo
        {
            SceneName = pickedMap,
            SceneType = SceneType.AdditionalScenes
        });
        netIdentity.isDirty = true;
    }
    IEnumerator LoadClientScenesFromServer(List<SceneInfo> Scenes, string OriginalScene, Action OnFinish)
    {
        ClientSideFinishAction = OnFinish;
        var SubsceneLoadTimer = new SubsceneLoadTimer();
        //calculate load time:
        SubsceneLoadTimer.MaxLoadTime = Scenes.Count;

        clientIsLoadingSubscene = true;
        foreach (var Scene in Scenes)
        {
            yield return LoadClientSubScene(Scene, false, SubsceneLoadTimer, true );
            if (KillClientLoadingCoroutine)
            {
                yield return SceneManager.UnloadSceneAsync(Scene.SceneName);
                KillClientLoadingCoroutine = false;
                clientIsLoadingSubscene = false;
                yield break;
            }
            clientLoadedSubScenes.Add(Scene);
        }

        NetworkClient.PrepareToSpawnSceneObjects();
        RequestObserverRefresh.Send(OriginalScene);

        foreach (var Scene in Scenes)
        {
            yield return WaitFor.Seconds(0.1f); //For smooth FPS not necessary technically, but causes freeze For a little bit
            if (KillClientLoadingCoroutine)
            {
                KillClientLoadingCoroutine = false;
                clientIsLoadingSubscene = false;
                yield break;
            }
            RequestObserverRefresh.Send(Scene.SceneName);
        }

        clientIsLoadingSubscene = false;
        yield return WaitFor.Seconds(0.1f); //For smooth FPS not necessary technically, but causes freeze For a little bit
        if (KillClientLoadingCoroutine)
        {
            KillClientLoadingCoroutine = false;
            yield break;
        }
        UIManager.Display.preRoundWindow.CloseMapLoadingPanel();
        OnFinish.Invoke();
    }
    IEnumerator RoundStartServerLoadSequence()
    {
        var loadTimer = new SubsceneLoadTimer();

        //calculate load time:
        loadTimer.MaxLoadTime = 20f;
        loadTimer.IncrementLoadBar("Preparing..");

        while (AddressableCatalogueManager.FinishLoaded == false)
        {
            yield return(null);
        }

        yield return(StartCoroutine(ServerLoadSpaceScene(loadTimer)));

        //Choose and load a mainstation
        yield return(StartCoroutine(ServerLoadShip(loadTimer)));

        yield return(StartCoroutine(ServerLoadMainStation(loadTimer)));

        if (GameManager.Instance.QuickLoad == false)
        {
            //Load away site:
            yield return(StartCoroutine(ServerLoadAwaySite(loadTimer)));

            //Load CentCom Scene:
            yield return(StartCoroutine(ServerLoadCentCom(loadTimer)));

            //Load Additional Scenes:
            yield return(StartCoroutine(ServerLoadAdditionalScenes(loadTimer)));
        }

        netIdentity.isDirty = true;

        yield return(WaitFor.Seconds(0.1f));

        UIManager.Display.preRoundWindow.CloseMapLoadingPanel();
        EventManager.Broadcast(Event.ScenesLoadedServer, false);
        Logger.Log($"Server has loaded {serverChosenAwaySite} away site", Category.Round);
    }
예제 #12
0
    IEnumerator LoadClientSubScene(SceneInfo sceneInfo)
    {
        if (sceneInfo.SceneType == SceneType.MainStation)
        {
            var clientLoadTimer = new SubsceneLoadTimer();
            //calculate load time:
            clientLoadTimer.MaxLoadTime = 10f;
            clientLoadTimer.IncrementLoadBar($"Loading {sceneInfo.SceneName}");
            yield return(StartCoroutine(LoadSubScene(sceneInfo.SceneName, clientLoadTimer)));

            MainStationLoaded = true;
            yield return(WaitFor.Seconds(0.1f));

            UIManager.Display.preRoundWindow.CloseMapLoadingPanel();
        }
        else
        {
            yield return(StartCoroutine(LoadSubScene(sceneInfo.SceneName)));
        }

        clientIsLoadingSubscene = false;
    }
예제 #13
0
    //Load all the asteroids on the server
    IEnumerator ServerLoadAdditionalScenes(SubsceneLoadTimer loadTimer)
    {
        if (GameManager.Instance.QuickLoad)
        {
            yield return(null);
        }

        loadTimer.IncrementLoadBar("Loading Additional Scenes");
        foreach (var additionalScene in additionalSceneList.AdditionalScenes)
        {
            //LAVALAND
            //only spawn if game config allows
            if (additionalScene == "LavaLand" && !GameConfig.GameConfigManager.GameConfig.SpawnLavaLand && !AdminAllowLavaland)
            {
                continue;
            }

            if (additionalScene == "LavaLand" && !GameConfig.GameConfigManager.GameConfig.SpawnLavaLand)
            {
                //reset back to false for the next round if false before.
                AdminAllowLavaland = false;
            }
            else if (additionalScene == "LavaLand")
            {
                AdminAllowLavaland = true;
            }

            yield return(StartCoroutine(LoadSubScene(additionalScene, loadTimer)));

            loadedScenesList.Add(new SceneInfo
            {
                SceneName = additionalScene,
                SceneType = SceneType.AdditionalScenes
            });
            netIdentity.isDirty = true;
        }
    }
예제 #14
0
    /// <summary>
    /// General subscene loader
    /// </summary>
    /// <param name="sceneName"></param>
    /// <returns></returns>
    IEnumerator LoadSubScene(string sceneName, SubsceneLoadTimer loadTimer = null, bool HandlSynchronising = true)
    {
        AsyncOperation AO = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);

        if (AO == null)
        {
            yield break;                     // Null if scene not found.
        }
        while (AO.isDone == false)
        {
            if (loadTimer != null)
            {
                loadTimer.IncrementLoadBar();
            }
            yield return(WaitFor.EndOfFrame);
        }

        if (loadTimer != null)
        {
            loadTimer.IncrementLoadBar();
        }
        if (isServer)
        {
            NetworkServer.SpawnObjects();
        }
        else
        {
            if (HandlSynchronising)
            {
                NetworkClient.PrepareToSpawnSceneObjects();
                yield return(WaitFor.Seconds(0.2f));

                RequestObserverRefresh.Send(sceneName);
            }
        }
    }
예제 #15
0
    IEnumerator RoundStartServerLoadSequence()
    {
        var loadTimer = new SubsceneLoadTimer();

        //calculate load time:
        loadTimer.MaxLoadTime = 20f + (asteroidList.Asteroids.Count * 10f);
        loadTimer.IncrementLoadBar("Preparing..");
        yield return(WaitFor.Seconds(0.1f));

        MainStationLoaded = true;

        //Auto scene load stuff in editor:
        var prevEditorScene = "";

#if UNITY_EDITOR
        if (EditorPrefs.HasKey("prevEditorScene"))
        {
            if (!string.IsNullOrEmpty(EditorPrefs.GetString("prevEditorScene")))
            {
                prevEditorScene = EditorPrefs.GetString("prevEditorScene");
            }
        }
#endif

        if (mainStationList.MainStations.Contains(prevEditorScene))
        {
            serverChosenMainStation = prevEditorScene;
        }
        else
        {
            serverChosenMainStation = mainStationList.GetRandomMainStation();
        }

        loadTimer.IncrementLoadBar($"Loading {serverChosenMainStation}");
        //load main station
        yield return(StartCoroutine(LoadSubScene(serverChosenMainStation, loadTimer)));

        loadedScenesList.Add(new SceneInfo
        {
            SceneName = serverChosenMainStation,
            SceneType = SceneType.MainStation
        });

        yield return(WaitFor.Seconds(0.1f));

        loadTimer.IncrementLoadBar("Loading Asteroids");

        foreach (var asteroid in asteroidList.Asteroids)
        {
            yield return(StartCoroutine(LoadSubScene(asteroid, loadTimer)));

            loadedScenesList.Add(new SceneInfo
            {
                SceneName = asteroid,
                SceneType = SceneType.Asteroid
            });

            yield return(WaitFor.Seconds(0.1f));
        }

        //Load the away site
        if (awayWorldList.AwayWorlds.Contains(prevEditorScene))
        {
            serverChosenAwaySite = prevEditorScene;
        }
        else
        {
            serverChosenAwaySite = awayWorldList.GetRandomAwaySite();
        }
        loadTimer.IncrementLoadBar("Loading Away Site");
        yield return(StartCoroutine(LoadSubScene(serverChosenAwaySite, loadTimer)));

        AwaySiteLoaded = true;
        loadedScenesList.Add(new SceneInfo
        {
            SceneName = serverChosenAwaySite,
            SceneType = SceneType.AwaySite
        });

        yield return(WaitFor.Seconds(0.1f));

        UIManager.Display.preRoundWindow.CloseMapLoadingPanel();

        Logger.Log($"Server has loaded {serverChosenAwaySite} away site", Category.SubScenes);
    }