protected override JobHandle OnUpdate(JobHandle inputDeps) { var queryLength = _explosionQuery.CalculateLength(); var explosions = new NativeArray <ExplosionData>(queryLength, Allocator.TempJob); var collectDataJob = new ExplosionDataCollectionJob { positions = _explosionQuery.ToComponentDataArray <Translation>(Allocator.TempJob), shells = _explosionQuery.ToComponentDataArray <ExplosiveShell>(Allocator.TempJob), explosions = explosions }; var explosionJob = new ExplosionJob { explosions = explosions, }; var commandBuffer = _commandBufferSystem.CreateCommandBuffer(); var shellDisposalJob = new ShellDisposeJob { commandBuffer = commandBuffer.ToConcurrent() }; inputDeps = collectDataJob.Schedule(queryLength, 10, inputDeps); inputDeps = explosionJob.Schedule(this, inputDeps); inputDeps = shellDisposalJob.Schedule(this, inputDeps); _commandBufferSystem.AddJobHandleForProducer(inputDeps); return(inputDeps); }
protected override JobHandle OnUpdate(JobHandle handle) { var sm = GetSingleton <SpawnerRndAreaComp>(); handle = new ExplosionJob { ecb = _ecbs.CreateCommandBuffer().ToConcurrent(), t = Time.DeltaTime, emitColor = sm.colorEmitSuperMassive }.Schedule(this, handle); _ecbs.AddJobHandleForProducer(handle); return(handle); }