/// <summary> /// Get the job. There's 3 types. Load from file, from noise, and save to file /// </summary> /// <param name="adjustment"></param> /// <returns></returns> protected override ApetureJobHandle getJob(Adjustment adjustment) { IAdjustmentJob job; if (adjustment.type == FocusAdjustmentType.InFocus) { if (LevelDAO.ChunkFileExists(adjustment.chunkID, lens.level)) { job = new LevelDAO.LoadChunkDataFromFileJob(adjustment, lens.level); // if there's no file, we need to generate the chunk data from scratch } else { job = StaticBiomeMap.GetTerrainGenerationJob(adjustment, lens.level); } /// if it's out of focus, we want to save the chunk to file } else { Chunk chunkToSave = lens.level.getChunk(adjustment.chunkID); if (chunkToSave.currentResolution != Chunk.Resolution.UnLoaded) { job = new LevelDAO.SaveChunkDataToFileJob(adjustment, lens.level); } else { throw new System.MissingMemberException( $"VoxelDataAperture is trying to save chunk data for {adjustment.chunkID} but could not find the chunk data in the level" ); } } return(new ApetureJobHandle(job, onJobComplete)); }
/// <summary> /// Schedule the job for loading new data from file /// </summary> /// <param name="chunkID"></param> /// <returns></returns> public override ApertureJobHandle getJobFor(Chunk.ID chunkID, FocusAdjustmentType adjustmentType) { IJob job; if (adjustmentType == FocusAdjustmentType.InFocus) { if (LevelDAO.ChunkFileExists(chunkID, level)) { job = new LevelDAO.LoadChunkDataFromFileJob(chunkID, level.name); // if there's no file, we need to generate the chunk data from scratch } else { job = BiomeMap.GetTerrainGenerationJob(chunkID, level); } /// if it's out of focus, we want to save the chunk to file } else if (level.chunks.TryGetValue(chunkID, out Chunk chunkToSave)) { job = new LevelDAO.SaveChunkDataToFileJob(chunkID, level.name, chunkToSave.getVoxels(), chunkToSave.solidVoxelCount); } else { throw new System.MissingMemberException( $"VoxelDataAperture is trying to save chunk data for {chunkID} but could not find the chunk data in the level" ); } return(new ApertureJobHandle(job, this)); }