Example #1
0
        private void SortScenesByDistance()
        {
            currentSceneId = null;
            scenesSortedByDistance.Sort(SortScenesByDistanceMethod);

            using (var iterator = scenesSortedByDistance.GetEnumerator())
            {
                ParcelScene scene;
                bool        characterIsInsideScene;

                while (iterator.MoveNext())
                {
                    scene = iterator.Current;
                    characterIsInsideScene = scene.IsInsideSceneBoundaries(DCLCharacterController.i.characterPosition);

                    if (scene.sceneData.id != globalSceneId && characterIsInsideScene)
                    {
                        currentSceneId = scene.sceneData.id;
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty(currentSceneId))
            {
                if (TryGetScene(currentSceneId, out ParcelScene scene) && scene.isReady)
                {
                    CommonScriptableObjects.rendererState.RemoveLock(this);
                }
            }

            CommonScriptableObjects.sceneID.Set(currentSceneId);

            OnSortScenes?.Invoke();
        }
Example #2
0
        public void SortScenesByDistance()
        {
            if (DCLCharacterController.i == null)
            {
                return;
            }

            IWorldState worldState = Environment.i.world.state;

            worldState.currentSceneId = null;
            worldState.scenesSortedByDistance.Sort(SortScenesByDistanceMethod);

            using (var iterator = Environment.i.world.state.scenesSortedByDistance.GetEnumerator())
            {
                IParcelScene scene;
                bool         characterIsInsideScene;

                while (iterator.MoveNext())
                {
                    scene = iterator.Current;

                    if (scene == null)
                    {
                        continue;
                    }

                    characterIsInsideScene = WorldStateUtils.IsCharacterInsideScene(scene);

                    if (!worldState.globalSceneIds.Contains(scene.sceneData.id) && characterIsInsideScene)
                    {
                        worldState.currentSceneId = scene.sceneData.id;
                        break;
                    }
                }
            }

            if (!DataStore.i.debugConfig.isDebugMode && string.IsNullOrEmpty(worldState.currentSceneId))
            {
                // When we don't know the current scene yet, we must lock the rendering from enabling until it is set
                CommonScriptableObjects.rendererState.AddLock(this);
            }
            else
            {
                // 1. Set current scene id
                CommonScriptableObjects.sceneID.Set(worldState.currentSceneId);

                // 2. Attempt to remove SceneController's lock on rendering
                CommonScriptableObjects.rendererState.RemoveLock(this);
            }

            OnSortScenes?.Invoke();
        }
Example #3
0
        private void SortScenesByDistance()
        {
            if (DCLCharacterController.i == null)
            {
                return;
            }

            currentSceneId = null;
            scenesSortedByDistance.Sort(SortScenesByDistanceMethod);

            using (var iterator = scenesSortedByDistance.GetEnumerator())
            {
                ParcelScene scene;
                bool        characterIsInsideScene;

                while (iterator.MoveNext())
                {
                    scene = iterator.Current;

                    if (scene == null)
                    {
                        continue;
                    }

                    characterIsInsideScene = scene.IsInsideSceneBoundaries(DCLCharacterController.i.characterPosition);

                    if (scene.sceneData.id != globalSceneId && characterIsInsideScene)
                    {
                        currentSceneId = scene.sceneData.id;
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty(currentSceneId))
            {
                CommonScriptableObjects.sceneID.Set(currentSceneId);
            }

            OnSortScenes?.Invoke();
        }