Esempio n. 1
0
        private void UpdateBooting()
        {
            // Destroy current config entity
            if (m_EntityManager.Exists(m_Environment.configEntity))
            {
                m_EntityManager.DestroyEntity(m_Environment.configEntity);
                m_Environment.configEntity = Entity.Null;
            }

            m_ConfigScene = SceneService.LoadConfigAsync(m_World);

            m_BootPhase = BootPhase.LoadingConfig;
        }
Esempio n. 2
0
        private static bool MainLoop()
        {
            if (m_BootPhase == BootPhase.Running)
            {
                m_World.Update();
            }
            else if (m_BootPhase == BootPhase.Booting)
            {
                var em = m_World.EntityManager;

                // Destroy current config entity
                if (em.Exists(m_Environment.configEntity))
                {
                    em.DestroyEntity(m_Environment.configEntity);
                    m_Environment.configEntity = Entity.Null;
                }

                m_ConfigScene = SceneService.LoadConfigAsync();

                m_BootPhase = BootPhase.LoadingConfig;
            }
            else if (m_BootPhase == BootPhase.LoadingConfig)
            {
                var em = m_World.EntityManager;
                var sceneStreamingSystem = m_World.GetOrCreateSystem <SceneStreamingSystem>();

                // Tick this world specifically to ensure our request is handled
                sceneStreamingSystem.Update();

                var sceneStatus = SceneService.GetSceneStatus(m_ConfigScene);
                if (sceneStatus == SceneStatus.Loaded)
                {
                    using (var configurationQuery = em.CreateEntityQuery(typeof(ConfigurationTag)))
                    {
                        if (configurationQuery.CalculateLength() == 0)
                        {
                            throw new Exception($"Failed to load boot configuration scene.");
                        }

                        using (var configEntityList = configurationQuery.ToEntityArray(Allocator.Temp))
                        {
                            // Set new config entity
                            if (configEntityList.Length > 1)
                            {
                                throw new Exception($"More than one configuration entity found in boot configuration scene.");
                            }
                            m_Environment.configEntity = configEntityList[0];
                        }
                    }

                    LoadStartupScenes();

                    m_BootPhase = BootPhase.Running;
                }
                else if (sceneStatus == SceneStatus.FailedToLoad)
                {
                    throw new Exception($"Failed to load the boot configuration scene.");
                }
            }
            else
            {
                throw new Exception("Invalid BootPhase specified");
            }

            return(!m_World.QuitUpdate);
        }