protected override JobHandle OnUpdate(JobHandle inputDeps) { if (LimitUpdateRate) { // Some update speed limiting to make the simulation look a bit nicer for humans lastUpdateTime -= Time.deltaTime; if (lastUpdateTime > 0.0f) { return(inputDeps); } lastUpdateTime = WorldUpdateRate; } /*if (!shouldUpdate) * return inputDeps; */ shouldUpdate = false; // We need a command buffer to update the entities from inside a job var updateCommandBuffer = commandBufferSystem.CreateCommandBuffer(); var tileCount = GridSizeInTiles.x * GridSizeInTiles.y; var updateCells = new CellLifeProcessing { gridSize = WorldSize, gridSizeInTiles = GridSizeInTiles, cellState = stateSelection ? cellState0 : cellState1, newCellState = stateSelection ? cellState1 : cellState0, maxCellsPerTile = maxCellsPerTile };//.Schedule(tileCount, 1, inputDeps); for (int idx = 0; idx < tileCount; ++idx) { updateCells.Execute(idx); } var renderupdate = new CellRenderingUpdate { CommandBuffer = updateCommandBuffer.ToConcurrent(), newCellState = stateSelection ? cellState1 : cellState0, oldCellState = stateSelection ? cellState0 : cellState1, maxCellsPerTile = maxCellsPerTile, gridSizeInTiles = GridSizeInTiles }.Schedule(this, inputDeps); commandBufferSystem.AddJobHandleForProducer(renderupdate); stateSelection = !stateSelection; return(renderupdate); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { if (LimitUpdateRate) { // Some update speed limiting to make the simulation look a bit nicer for humans lastUpdateTime -= Time.deltaTime; if (lastUpdateTime > 0.0f) { return(inputDeps); } lastUpdateTime = WorldUpdateRate; } // We need a command buffer to update the entities from inside a job var updateCommandBuffer = commandBufferSystem.CreateCommandBuffer(); var cellCount = WorldSize.x * WorldSize.y; var updateCells = new CellLifeProcessing { gridSize = WorldSize, cellState = stateSelection ? cellState0 : cellState1, newCellState = stateSelection ? cellState1 : cellState0, offsetTable = offsetTable }.Schedule(cellCount, 64, inputDeps); var renderupdate = new CellRenderingUpdate { CommandBuffer = updateCommandBuffer.ToConcurrent(), newCellState = stateSelection ? cellState1 : cellState0, oldCellState = stateSelection ? cellState0 : cellState1, GridSize = WorldSize }.Schedule(this, updateCells); commandBufferSystem.AddJobHandleForProducer(renderupdate); stateSelection = !stateSelection; return(renderupdate); }