示例#1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var settings = GetSingleton <GameBoardSettingsComponent>();

            if (_positionsQuery.CalculateEntityCount() != settings.Width * settings.Height)
            {
                return(inputDeps);
            }

            var cachedEntities = new NativeArray <Entity>(settings.Width * settings.Height, Allocator.TempJob);

            var helper = new ArrayToCoordinatesConverter(settings.Width, settings.Height);

            var cacheJob = new CacheJob
            {
                CachedEntities = cachedEntities,
                Entities       = _positionsQuery.ToEntityArray(Allocator.TempJob),
                Positions      = _positionsQuery.ToComponentDataArray <CellPositionComponent>(Allocator.TempJob),
                Helper         = helper
            };

            var splitJob = new SplitJob
            {
                CachedEntities = cachedEntities,
                CellType       = GetComponentDataFromEntity <CellTypeComponent>(true),
                Helper         = helper
            };

            var jobHandle = cacheJob.Schedule(_positionsQuery.CalculateEntityCount(), 32, inputDeps);

            jobHandle = splitJob.Schedule(jobHandle);

            return(jobHandle);
        }
示例#2
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        // 计算准备
        var concurrent = bufferSystem.CreateCommandBuffer().ToConcurrent();
        // 新建句柄
        var    splitJob = new SplitJob();
        Entity entity;
        bool   result = ViewFactory.ViewMap.TryGetValue("Star".GetHashCode(), out entity);

        UnityEngine.Debug.Log("Star".GetHashCode());
        splitJob.smallStar  = entity;
        splitJob.concurrent = concurrent;
        // 挂载句柄
        inputDeps = splitJob.Schedule(this, inputDeps);
        return(inputDeps);
    }