Ejemplo n.º 1
0
        public static void ReloadLocationObjects()
        {
            _logger.Info($"Reloading location objects for world location {WorldData.WorldLocationId}");
            ParentManager.Instance.ParentCommand = ParentCommand.None;
            GameStateData.ClearObjects();
            WorldData.ObjectsAreChanged = false;
            WorldLocation location      = WorldData.WorldStructure.WorldLocations.GetWorldLocation(WorldData.WorldLocationId);
            LogicInstance logicInstance = new LogicInstance(WorldData.WorldLocationId);

            GameStateData.RefreshLogic(logicInstance, WorldData.LogicCode);
            CreateSpawnEntities(location.WorldLocationObjects, WorldData.WorldLocationId);
            WorldDataListener.Instance.ReadyToGetNewMessages();
        }
Ejemplo n.º 2
0
        public static void LoadLocationObjects(int newWorldLocationId, int oldWorldLocationId)
        {
            _logger.Info($"Loading location objects for world location {newWorldLocationId}");
            ParentManager.Instance.ParentCommand = ParentCommand.None;

            GameStateData.ClearObjects();
            WorldData.ObjectsAreChanged = false;
            WorldLocation location      = WorldData.WorldStructure.WorldLocations.GetWorldLocation(newWorldLocationId);
            LogicInstance logicInstance = new LogicInstance(newWorldLocationId);

            GameStateData.RefreshLogic(logicInstance, WorldData.LogicCode);
            CreateSpawnEntities(location.WorldLocationObjects, newWorldLocationId);
        }
Ejemplo n.º 3
0
        public void LoadWorldConfiguration(int worldConfigurationId, out int worldLocationId)
        {
            _logger.Info($"Loading world configuration {worldConfigurationId}...");
            GameStateData.ClearObjects();
            worldLocationId = 0;

            foreach (WorldConfiguration worldConfiguration in WorldData.WorldStructure.WorldConfigurations)
            {
                if (worldConfiguration.Id != worldConfigurationId)
                {
                    continue;
                }

                worldLocationId = GetStartLocation(worldConfigurationId);
            }

            if (worldLocationId == 0)
            {
                _logger.Error($"World configuration id = {worldConfigurationId} not found!");
            }

            int newWorldLocationId = worldLocationId;
            int oldWorldLocationId = WorldData.WorldLocationId;

            WorldData.Update(WorldData.WorldId, newWorldLocationId, worldConfigurationId);

            WorldData.OnLoadObjects    = null;
            WorldData.ObjectsAreLoaded = false;

            WorldData.OnLoadObjects = delegate
            {
                WorldData.OnLoadLocation = delegate
                {
                    Helper.LoadLocationObjects(newWorldLocationId, oldWorldLocationId);
                    WorldData.OnLoadObjects = null;
                };
            };
        }
Ejemplo n.º 4
0
        private IEnumerator StopLogicAndLoadSceneCoroutine(int newWorldLocationId, int oldWorldLocationId)
        {
            GameStateData.ClearLogic();

            yield return(new WaitForEndOfFrame());

            GameStateData.ClearObjects();

            if (newWorldLocationId == oldWorldLocationId)
            {
                //Hide everything

                Helper.LoadLocationObjects(newWorldLocationId, oldWorldLocationId);

                LoadWorldDescriptor();

                yield return(new WaitForSeconds(1.0f));

                yield break;
            }

            Debug.Log("Loading loading Scene");

            AsyncOperation loadLoading = SceneManager.LoadSceneAsync("Loading", LoadSceneMode.Additive);

            while (!loadLoading.isDone)
            {
                yield return(null);
            }

            Debug.Log("Unloading old Scene");
            //Hide everything
            // GameStateData.ClearObjects();

            AsyncOperation unloadSceneOperation = SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(0));

            while (!unloadSceneOperation.isDone)
            {
                yield return(null);
            }

            Resources.UnloadUnusedAssets();

            Debug.Log("Preparing everything");

            GameObjects.Instance.PlayerRig.GetComponentInChildren <VRTK_SDKSetup>().actualBoundaries.transform.position = Vector3.zero;

            WorldData.Update(WorldData.WorldId, newWorldLocationId, WorldData.WorldConfigurationId);
            WorldData.OnLoadObjects    = null;
            WorldData.ObjectsAreLoaded = false;
            Debug.Log("WorldDataListener.StopLogicAndLoadSceneCoroutine()");

            WorldData.OnLoadObjects = delegate
            {
                WorldData.OnLoadLocation = delegate
                {
                    Helper.LoadLocationObjects(newWorldLocationId, oldWorldLocationId);
                };
            };

            int locationId = WorldData.WorldStructure.WorldLocations.GetWorldLocation(newWorldLocationId).LocationId;

            SceneLoaderSystem
                sceneLoader =
                new SceneLoaderSystem(Contexts.sharedInstance,
                                      null,
                                      locationId);

            sceneLoader.Initialize();



            yield return(true);
        }