Beispiel #1
0
        public void OnContextInitialized <T>(T contextHolder)
        {
            QualitySettings.vSyncCount = -1;
//            Physics.autoSimulation = false;

            _enginesRoot = new EnginesRoot(new UnityEntitySubmissionScheduler());

            var context = contextHolder as SveltoContext;
            //add the engines we are going to use
            World world = World.Active;
            var   generateEntityFactory = _enginesRoot.GenerateEntityFactory();

            _enginesRoot.AddEngine(new PlaceFoodOnClickEngine(GameObjectConversionUtility.ConvertGameObjectHierarchy(
                                                                  context.food, world), generateEntityFactory));
            _enginesRoot.AddEngine(new SpawningDoofusEngine
                                       (GameObjectConversionUtility.ConvertGameObjectHierarchy(context.capsule,
                                                                                               world), generateEntityFactory));

            _enginesRoot.AddEngine(new LookingForFoodDoofusesEngine());
            //   _enginesRoot.AddEngine(new ConsumingFoodEngine(_enginesRoot.GenerateEntityFunctions()));
            _enginesRoot.AddEngine(new SpawnUnityEntityOnSveltoEntityEngine(world));
            _enginesRoot.AddEngine(new VelocityToPositionDoofusesEngine());
//            _enginesRoot.AddEngine(new DieOfHungerDoofusesEngine(_enginesRoot.GenerateEntityFunctions()));

            //one engine two ECS implementations :P
            var renderingDataSynchronizationEngine = new RenderingDataSynchronizationEngine(world);

            _enginesRoot.AddEngine(renderingDataSynchronizationEngine);
        }
        /// <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");

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

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, systems);
            _world.AddSystem(_renderingDataSynchronizationEngine);
            var simulationSystemGroup = _world.GetExistingSystem <SimulationSystemGroup>();

            simulationSystemGroup.AddSystemToUpdateList(_renderingDataSynchronizationEngine);
            simulationSystemGroup.SortSystemUpdateList();
            ScriptBehaviourUpdateOrder.UpdatePlayerLoop(_world);

            return(true);
        }