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); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var settings = GetSingleton <GameBoardSettingsComponent>(); 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 destroyJob = new DestroyJob { CachedEntities = cachedEntities, CommandBuffer = _commandBuffer.CreateCommandBuffer(), ClickedComponents = _clickedQuery.ToComponentDataArray <UserClickComponent>(Allocator.TempJob), Helper = helper, MinGroupSize = settings.MinGroupSize }; var jobHandle = cacheJob.Schedule(_positionsQuery.CalculateEntityCount(), 32, inputDeps); jobHandle = destroyJob.Schedule(jobHandle); _commandBuffer.AddJobHandleForProducer(jobHandle); return(jobHandle); }