/// <summary> /// Do things for different jobs /// </summary> /// <param name="chunkID"></param> /// <param name="finishedJobHandle"></param> protected override void handleFinishedJob(Chunk.ID chunkID, ref ApertureJobHandle finishedJobHandle) { Chunk newlyLoadedChunk = new Chunk(); switch (finishedJobHandle.job) { /// same for both, but they're structs so can't inherit. case LevelDAO.LoadChunkDataFromFileJob lcdffj: // if we didn't generate an empty chunk, copy the voxels over. if (lcdffj.solidVoxelCount[0] > 0) { newlyLoadedChunk.setVoxels( lcdffj.outVoxels, lcdffj.solidVoxelCount[0] ); } // also dispose of the native array lcdffj.outVoxels.Dispose(finishedJobHandle.jobHandle); lcdffj.solidVoxelCount.Dispose(finishedJobHandle.jobHandle); break; case BiomeMap.GenerateChunkDataFromSourceJob gcdfsj: if (gcdfsj.solidVoxelCount[0] > 0) { newlyLoadedChunk.setVoxels( gcdfsj.outVoxels, gcdfsj.solidVoxelCount[0] ); } gcdfsj.outVoxels.Dispose(finishedJobHandle.jobHandle); gcdfsj.solidVoxelCount.Dispose(finishedJobHandle.jobHandle); break; /// once the chunk data is saved, remove it from the level case LevelDAO.SaveChunkDataToFileJob scdtfj: level.chunks.Remove(scdtfj.chunkID); break; default: return; } // add chunk to the level newlyLoadedChunk.isLoaded = true; level.chunks.Add(chunkID, newlyLoadedChunk); }
/// <summary> /// Do nothing on job complete /// </summary> /// <param name="chunkID"></param> /// <param name="finishedJob"></param> protected override void handleFinishedJob(Chunk.ID chunkID, ref ApertureJobHandle finishedJob) { }
/// <summary> /// What to do with a job for this aperture when it's done /// </summary> /// <param name="key"></param> /// <param name="job"></param> protected abstract void handleFinishedJob(Chunk.ID chunkID, ref ApertureJobHandle finishedJobHandle);
/// <summary> /// Act on the job handle now that the job is complete /// </summary> /// <param name="key"></param> /// <param name="job"></param> public virtual void onJobComplete(Chunk.ID chunkID, ApertureJobHandle finishedJobHandle) { finishedJobHandle.markComplete(); handleFinishedJob(chunkID, ref finishedJobHandle); }