public static void Optimize(World world)
        {
            var entityManager = world.EntityManager;

            var group = world.GetOrCreateSystem <OptimizationGroup>();

            var systemTypes = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.EntitySceneOptimizations);

            foreach (var systemType in systemTypes)
            {
                AddSystemAndLogException(world, group, systemType);
            }
            group.SortSystems();

            // foreach (var system in group.Systems)
            //    Debug.Log(system.GetType());

            // Run first pass (This might add / remove a bunch of components and thus invalidate some of chunk component data caches)
            group.Update();

            // Run all systems again (For example chunk bounding volumes might be out of sync after various remove / add from previous pass)
            // But now we are sure that no more re-ordering will happen.
            group.Update();

            RemoveSystemState(entityManager);
            MarkStaticFrozen(entityManager);
        }
Exemple #2
0
        public void Initialize(bool createClientWorld, bool createServerWorld)
        {
            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

            GenerateSystemLists(systems);

            var world = new World("DefaultWorld");

            World.DefaultGameObjectInjectionWorld = world;

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, ExplicitDefaultWorldSystems);

            var currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop();

            ScriptBehaviourUpdateOrder.AddWorldToPlayerLoop(world, ref currentPlayerLoop);
            PlayerLoop.SetPlayerLoop(currentPlayerLoop);

            if (createClientWorld)
            {
                CreateClientWorld(world, "ClientWorld");
            }

            if (createServerWorld)
            {
                CreateServerWorld(world, "ServerWorld");
            }

            EntityWorldManager.Instance.Initialize();
        }
    public override bool Initialize(string defaultWorldName)
    {
        var sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;

        if (sceneName == "Asteroids" ||
            sceneName == "NetCube" ||
            sceneName == "LagCompensation" ||
            sceneName.StartsWith("BasicPrespawnTest") ||
            sceneName.StartsWith("Test"))
        {
            return(base.Initialize(defaultWorldName));
        }

        var world = new World(defaultWorldName);

        World.DefaultGameObjectInjectionWorld = world;

        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

        GenerateSystemLists(systems);

        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, DefaultWorldSystems);
        ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world);
        return(true);
    }
    private void Start()
    {
#if UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP_RUNTIME_WORLD
        //DefaultWorldInitialization.Initialize("Default World", false);
        //world = World.DefaultGameObjectInjectionWorld;
        world = new World("AAA");

        World.DefaultGameObjectInjectionWorld = world;

        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default, false);
        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, systems);
        ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world);

        var types = world.EntityManager.CreateArchetype(typeof(Translation), typeof(Rotation), typeof(Scale), typeof(LocalToWorld));

        var entity = world.EntityManager.CreateEntity(types);
        var scale  = world.EntityManager.GetComponentData <Scale>(entity);
        scale.Value = 1;
        world.EntityManager.SetComponentData(entity, scale);


        world.CreateSystem <ECSInputSystem>();
        world.CreateSystem <ECSGpuInstancedAnimationSystem>();

        Init(entity, world.EntityManager);
#endif
    }
        public void Bootstrap(bool includeNetCodeSystems, params Type[] userSystems)
        {
            var systems = new List <Type>();

            if (includeNetCodeSystems)
            {
                if (s_NetCodeSystems == null)
                {
                    s_NetCodeSystems = new List <Type>();
                    var sysList = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
                    foreach (var sys in sysList)
                    {
                        if (sys.Assembly.FullName.StartsWith("Unity.NetCode,") ||
                            sys.Assembly.FullName.StartsWith("Unity.Entities,") ||
                            sys.Assembly.FullName.StartsWith("Unity.Transforms,"))
                        {
                            s_NetCodeSystems.Add(sys);
                        }
                    }
                }
                systems.AddRange(s_NetCodeSystems);
            }
            systems.AddRange(userSystems);
            ClientServerBootstrap.GenerateSystemLists(systems);
        }
    public override bool Initialize(string defaultWorldName)
    {
#if UNITY_EDITOR
        // TODO (timj) make this check more generic
        if (UnityEditor.SceneManagement.EditorSceneManager.GetSceneAt(0).name.ToLower() != "bootstrapper")
        {
            IsSingleLevelPlaymode = true;
            if (!GameApp.IsInitialized)
            {
                //SceneManager.LoadScene(0);
                var go = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Game", typeof(GameObject)));
                GameDebug.Assert(GameApp.IsInitialized, "Failed to load Game prefab");
            }
            return(base.Initialize(defaultWorldName));
        }
        IsSingleLevelPlaymode = false;
#endif
        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
        GenerateSystemLists(systems);

        DefaultWorld = new World(defaultWorldName);
        World.DefaultGameObjectInjectionWorld = DefaultWorld;

        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(DefaultWorld, ExplicitDefaultWorldSystems);
        ScriptBehaviourUpdateOrder.UpdatePlayerLoop(DefaultWorld);

        return(true);
    }
Exemple #7
0
        static unsafe void RegisterConversionSystems()
        {
            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.GameObjectConversion |
                                                                   WorldSystemFilterFlags.EntitySceneOptimizations);
            var nameAndVersion = new NameAndVersion[systems.Count];

            for (int i = 0; i != nameAndVersion.Length; i++)
            {
                nameAndVersion[i].FullName = systems[i].FullName;

                var systemVersionAttribute = systems[i].GetCustomAttribute <ConverterVersionAttribute>();
                if (systemVersionAttribute != null)
                {
                    nameAndVersion[i].Version = systemVersionAttribute.Version;
                }
            }

            Array.Sort(nameAndVersion);

            UnityEngine.Hash128 hash = default;
            for (int i = 0; i != nameAndVersion.Length; i++)
            {
                var fullName = nameAndVersion[i].FullName;
                fixed(char *str = fullName)
                {
                    HashUnsafeUtilities.ComputeHash128(str, (ulong)(sizeof(char) * fullName.Length), &hash);
                }

                int version = nameAndVersion[i].Version;
                HashUnsafeUtilities.ComputeHash128(&version, sizeof(int), &hash);
            }

            UnityEditor.Experimental.AssetDatabaseExperimental.RegisterCustomDependency(SystemsVersion, hash);
        }
Exemple #8
0
        public void OnContextInitialized <T>(T contextHolder)
        {
            // Create engine root.
            _submissionScheduler = new SimpleEntitiesSubmissionScheduler();
            _enginesRoot         = new EnginesRoot(_submissionScheduler);

            // Initialize UECS.
            _world = new World("SveltoWorld");
            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, systems);
            World.DefaultGameObjectInjectionWorld = _world;

            var syncGroup = new SyncSveltoToUECSGroup();

            _world.AddSystem(syncGroup);
            AddTickEngine(syncGroup);

            var uecsTickGroup = new PureUECSSystemsGroup(_world);

            AddTickEngine(uecsTickGroup);

            // Initialize SECS
            var entityFactory = _enginesRoot.GenerateEntityFactory();
        }
        public virtual bool Initialize(string defaultWorldName)
        {
            World defaultWorld = new World(defaultWorldName);

            World.DefaultGameObjectInjectionWorld = defaultWorld;

            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

            GenerateSystemList(systems);

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(defaultWorld,
                                                                         SystemStates.ExplicitDefaultWorldSystems);
            ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(defaultWorld);

            Config = GetBootstrapConfig();

#if !UNITY_SERVER || UNITY_EDITOR
            if (Config.StartupWorld.HasFlag(TargetWorld.Client))
            {
                for (int i = 0; i < Config.ClientNum; i++)
                {
                    CreateClientWorld(defaultWorld, "ClientWorld" + i);
                }
            }
#endif


#if UNITY_SERVER || UNITY_EDITOR
            if (Config.StartupWorld.HasFlag(TargetWorld.Server))
            {
                CreateServerWorld(defaultWorld, "ServerWorld");
            }
#endif
            return(true);
        }
        void CreateUnityECSWorldForSvelto(SimpleEntitiesSubmissionScheduler scheduler, EnginesRoot enginesRoot)
        {
            world = new World("Svelto<>UECS world");

            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, systems);
            World.DefaultGameObjectInjectionWorld = world;

            //This is the UECS group that takes care of all the UECS systems that creates entities
            //it also submits Svelto entities
            _sveltoUecsEntitiesSubmissionGroup = new SveltoUECSEntitiesSubmissionGroup(scheduler);
            //This is the group that handles the UECS sync systems that copy the svelto entities values to UECS entities
            enginesRoot.AddEngine(_sveltoUecsEntitiesSubmissionGroup);
            world.AddSystem(_sveltoUecsEntitiesSubmissionGroup);
            _syncSveltoToUecsGroup = new SyncSveltoToUECSGroup();
            enginesRoot.AddEngine(_syncSveltoToUecsGroup);
            _syncUecsToSveltoGroup = new SyncUECSToSveltoGroup();
            enginesRoot.AddEngine(_syncUecsToSveltoGroup);
            //This is the group that handles the UECS sync systems that copy the UECS entities values to svelto entities
            //enginesRoot.AddEngine(new SveltoUECSEntitiesSubmissionGroup(scheduler, world));
            enginesRoot.AddEngine(this);

            _enginesRoot = enginesRoot;
        }
Exemple #11
0
    public override bool Initialize(string defaultWorldName)
    {
        var  sceneName     = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
        bool isSampleScene = (sceneName == "Asteroids" || sceneName == "NetCube" || sceneName == "LagCompensation");
        bool isTestScene   = (sceneName.StartsWith("BasicPrespawnTest") || sceneName.StartsWith("Test"));

        if (isSampleScene || isTestScene)
        {
            // For the sample scenes we use a dynamic assembly list so we can build a server with a subset of the assemblies
            // (only including one of the samples instead of all)
            RpcSystem.DynamicAssemblyList = isSampleScene;
            var success = base.Initialize(defaultWorldName);
            RpcSystem.DynamicAssemblyList = false;
            return(success);
        }

        var world = new World(defaultWorldName, WorldFlags.Game);

        World.DefaultGameObjectInjectionWorld = world;

        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

        GenerateSystemLists(systems);

        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, DefaultWorldSystems);
#if !UNITY_DOTSRUNTIME
        ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(world);
#endif
        return(true);
    }
Exemple #12
0
    public bool Initialize(string defaultWorldName)
    {
        var world = new LatiosWorld(defaultWorldName);

        World.DefaultGameObjectInjectionWorld = world;

        var initializationSystemGroup = world.GetExistingSystem <InitializationSystemGroup>();
        var simulationSystemGroup     = world.GetExistingSystem <SimulationSystemGroup>();
        var presentationSystemGroup   = world.GetExistingSystem <PresentationSystemGroup>();
        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

        systems.RemoveSwapBack(typeof(InitializationSystemGroup));
        systems.RemoveSwapBack(typeof(SimulationSystemGroup));
        systems.RemoveSwapBack(typeof(PresentationSystemGroup));

        BootstrapTools.InjectSystemsFromNamespace(systems, "Unity", world, simulationSystemGroup);
        BootstrapTools.InjectRootSuperSystems(systems, world, simulationSystemGroup);

        initializationSystemGroup.SortSystemUpdateList();
        simulationSystemGroup.SortSystemUpdateList();
        presentationSystemGroup.SortSystemUpdateList();

        ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world);
        return(true);
    }
Exemple #13
0
    public bool Initialize(string defaultWorldName)
    {
        var world = new LatiosWorld(defaultWorldName);

        World.DefaultGameObjectInjectionWorld = world;

        var initializationSystemGroup = world.GetExistingSystem <InitializationSystemGroup>();
        var simulationSystemGroup     = world.GetExistingSystem <SimulationSystemGroup>();
        var presentationSystemGroup   = world.GetExistingSystem <PresentationSystemGroup>();
        var systems = new List <Type>(DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default));

        systems.RemoveSwapBack(typeof(InitializationSystemGroup));
        systems.RemoveSwapBack(typeof(SimulationSystemGroup));
        systems.RemoveSwapBack(typeof(PresentationSystemGroup));

        BootstrapTools.InjectUnitySystems(systems, world, simulationSystemGroup);
        BootstrapTools.InjectRootSuperSystems(systems, world, simulationSystemGroup);

        initializationSystemGroup.SortSystems();
        simulationSystemGroup.SortSystems();
        presentationSystemGroup.SortSystems();

        BootstrapTools.UpdatePlayerLoopWithDelayedSimulation(world);
        return(true);
    }
Exemple #14
0
        private void SetUpWorld()
        {
            var allSystems =
                DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default, requireExecuteAlways: false);

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(w,
                                                                         allSystems.Concat(new[] { typeof(ConstantDeltaTimeSystem) }));
        }
Exemple #15
0
        protected virtual void Setup()
        {
            World = DefaultWorldInitialization.Initialize("Test World");
            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(World,
                                                                         DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Editor));

            BlobStore = new BlobAssetStore();
        }
Exemple #16
0
        public static World CreateEntityWorld(string name, bool isEditor)
        {
            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default, true);;
            var world   = new World(name, isEditor ? WorldFlags.Editor : WorldFlags.Game);

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, FilterSystemsToPackages(systems, EntitiesPackage));
            return(world);
        }
        static unsafe void RegisterConversionSystems()
        {
            var systems        = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.GameObjectConversion | WorldSystemFilterFlags.EntitySceneOptimizations);
            var behaviours     = TypeCache.GetTypesDerivedFrom <IConvertGameObjectToEntity>();
            var nameAndVersion = new NameAndVersion[systems.Count + behaviours.Count];

            int count = 0;

            // System versions
            for (int i = 0; i != systems.Count; i++)
            {
                var fullName = systems[i].FullName;
                if (fullName == null)
                {
                    continue;
                }

                nameAndVersion[count++].Init(systems[i], fullName);
            }

            // IConvertGameObjectToEntity versions
            for (int i = 0; i != behaviours.Count; i++)
            {
                var fullName = behaviours[i].FullName;
                if (fullName == null)
                {
                    continue;
                }

                nameAndVersion[count++].Init(behaviours[i], fullName);
            }

            Array.Sort(nameAndVersion, 0, count);

            UnityEngine.Hash128 hash = default;
            for (int i = 0; i != count; i++)
            {
                var fullName = nameAndVersion[i].FullName;
                fixed(char *str = fullName)
                {
                    HashUnsafeUtilities.ComputeHash128(str, (ulong)(sizeof(char) * fullName.Length), &hash);
                }

                var userName = nameAndVersion[i].UserName;
                if (userName != null)
                {
                    fixed(char *str = userName)
                    {
                        HashUnsafeUtilities.ComputeHash128(str, (ulong)(sizeof(char) * userName.Length), &hash);
                    }
                }

                int version = nameAndVersion[i].Version;
                HashUnsafeUtilities.ComputeHash128(&version, sizeof(int), &hash);
            }

            AssetDatabaseCompatibility.RegisterCustomDependency(SystemsVersion, hash);
        }
Exemple #18
0
    void LoadScene(Switch sceneSwitch)
    {
        PlayType playModeType = RequestedPlayType;

        if (sceneSwitch.switchClientorServer == "server")
        {
            playModeType = PlayType.ClientAndServer;
        }
        if (sceneSwitch.switchClientorServer == "client")
        {
            playModeType = PlayType.Client;
        }

        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

        GenerateSystemLists(systems);

        var world = new World("Default World");

        World.DefaultGameObjectInjectionWorld = world;

        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, ExplicitDefaultWorldSystems);
        ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world);


        int numClientWorlds = RequestedNumClients;

        int totalNumClients = numClientWorlds;

        if (playModeType != PlayType.Server)
        {
#if UNITY_EDITOR
            int numThinClients = RequestedNumThinClients;
            totalNumClients += numThinClients;
#endif
            for (int i = 0; i < numClientWorlds; ++i)
            {
                CreateClientWorld(world, "ClientWorld" + i);
            }
#if UNITY_EDITOR
            for (int i = numClientWorlds; i < totalNumClients; ++i)
            {
                var clientWorld = CreateClientWorld(world, "ClientWorld" + i);
                clientWorld.EntityManager.CreateEntity(typeof(ThinClientComponent));
            }
#endif
        }

        if (playModeType != PlayType.Client)
        {
            CreateServerWorld(world, "ServerWorld");
        }


        var sceneName = sceneSwitch.switchName.ToString();
        var async     = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);
        async.allowSceneActivation = true;
    }
Exemple #19
0
        protected virtual void SetUp()
        {
            World         = new World("TestWorld");
            EntityManager = World.EntityManager;

            IReadOnlyList <Type> defaultSystems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(World, defaultSystems);
            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(World, typeof(OverrideTimeSystem));
        }
Exemple #20
0
        protected void SetUpBase()
        {
            w   = new World("Test World");
            em  = w.EntityManager;
            emu = new EntityManagerUtility(w);
            var allSystems =
                DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default, requireExecuteAlways: false);

            allSystems.Add(typeof(ConstantDeltaTimeSystem)); //this has disable auto creation on it.
            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(w, allSystems);
        }
Exemple #21
0
    public bool Initialize(string defaultWorldName)
    {
        World.DefaultGameObjectInjectionWorld = new World(defaultWorldName);
        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(World.DefaultGameObjectInjectionWorld, systems);
        ScriptBehaviourUpdateOrder.UpdatePlayerLoop(World.DefaultGameObjectInjectionWorld);

        LoadWorld();
        return(true);
    }
Exemple #22
0
        public void SetUp()
        {
            W  = new World("Test World");
            EM = W.EntityManager;

            var allSystems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default)
                             .Where(s => s != typeof(GLFWWindowSystem));

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(W, allSystems);

            EM.AddComponent <DisplayInfo>(EM.CreateEntity());
        }
Exemple #23
0
    public static World CreateDefaultWorld(string name)
    {
        var defaultWorld = new World(name);

        World.DefaultGameObjectInjectionWorld = defaultWorld;
        GenerateSystemLists(DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default));
        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(defaultWorld, ExplicitDefaultWorldSystems);
    #if !UNITY_DOTSRUNTIME
        ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(defaultWorld);
    #endif
        return(defaultWorld);
    }
Exemple #24
0
        static void AddStreamingWorldSystems(World world)
        {
            var group       = world.GetOrCreateSystem <ProcessAfterLoadGroup>();
            var systemTypes = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.ProcessAfterLoad);

            foreach (var systemType in systemTypes)
            {
                AddSystemAndLogException(world, group, systemType);
            }

            group.SortSystems();
        }
        /// <summary>
        /// A bit messy, it's not from UnityECS 0.2.0 and I will need to study it better
        /// </summary>
        /// <param name="defaultWorldName"></param>
        /// <returns></returns>
        public bool Initialize(string defaultWorldName)
        {
//            Physics.autoSimulation = false;
            _world = new World("Custom world");

            World.DefaultGameObjectInjectionWorld = _world;
            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, systems);
            ScriptBehaviourUpdateOrder.UpdatePlayerLoop(_world);

            return(true);
        }
Exemple #26
0
    // 自定义引导实现内容  使其不自动创建客户端和服务端世界
    private void CustomInitialize(string defaultWorldName)
    {
        // 为了拥有一个有效的TypeManager实例,必须在生成系统列表之前创建默认的世界。
        // 当我们第一次创建一个世界时,TypeManage被初始化。
        var world = new World(defaultWorldName, WorldFlags.Game);

        World.DefaultGameObjectInjectionWorld = world;
        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

        GenerateSystemLists(systems);
        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, ExplicitDefaultWorldSystems);
#pragma warning disable 0618
        ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world);
    }
    public virtual void Setup()
    {
        // Ensure we have full stack traces when running tests.
        OldLeakMode = NativeLeakDetection.Mode;
        NativeLeakDetection.Mode = NativeLeakDetectionMode.EnabledWithStackTrace;

        if (World != null)
        {
            return;
        }

        World = DefaultWorldInitialization.Initialize("Test World");
        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(World, DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default));
    }
Exemple #28
0
    public override bool Initialize(string defaultWorldName)
    {
        TypeManager.Initialize();
        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

        GenerateSystemLists(systems);

        var world = new World(defaultWorldName);

        World.DefaultGameObjectInjectionWorld = world;

        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, ExplicitDefaultWorldSystems);
        ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world);
        return(true);
    }
Exemple #29
0
    private (World, HybridRendererSystem) CreateWorld(string n)
    {
        var world = new World(n);

        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

        var list = systems.ToList();

        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, list);

        SetStuff(world);
        var hybrid = world.GetOrCreateSystem <HybridRendererSystem>();

        return(world, hybrid);
    }
Exemple #30
0
    protected override void OnStartRunning()
    {
        m_BuildPhysicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld>();

        defaultWorld = World;

        predictiveWorld = new World("predictionWorld", WorldFlags.Simulation);

        var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

        DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(predictiveWorld, systems);

        FixedStepSimulationSystemGroup fixGroup = predictiveWorld.GetExistingSystem <FixedStepSimulationSystemGroup>();

        fixGroup.FixedRateManager = new FixedRateUtils.FixedRateSimpleManager(Time.DeltaTime);
    }