예제 #1
0
        /// <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));
        }
        /// <summary>
        /// Schedule the activate chunk job
        /// </summary>
        /// <param name="chunkID"></param>
        /// <returns></returns>
        public override ApertureJobHandle getJobFor(Chunk.ID chunkID, FocusAdjustmentType adjustmentType)
        {
            IJob job;

            if (adjustmentType == FocusAdjustmentType.InFocus)
            {
                job = new ActivateChunkObjectJob(chunkID);
            }
            else
            {
                job = new DeactivateChunkObjectJob(chunkID);
            }


            return(new ApertureJobHandle(job, this));
        }
 /// <summary>
 /// Schedule a mesh job. Can only be called from the main thread!
 /// </summary>
 /// <param name="chunkID"></param>
 /// <returns></returns>
 public override ApertureJobHandle getJobFor(Chunk.ID chunkID, FocusAdjustmentType adjustmentType) {
   IJob job;
   /// if it's an in focus job
   if (adjustmentType == FocusAdjustmentType.InFocus) {
     // get the prep'd data and send it to the job
     if (preparedVoxelData.TryGetValue(chunkID, out byte[] marchVoxelData)) {
        ///// PUBLIC FUNCTIONS

        /// <summary>
        /// Create and schedule the child job for this chunk using a unity IJob
        /// </summary>
        /// <param name="chunkID"></param>
        public abstract ApertureJobHandle getJobFor(Chunk.ID chunkID, FocusAdjustmentType adjustmentType);
 /// <summary>
 /// Make a new adjustment
 /// </summary>
 /// <param name="chunkID"></param>
 /// <param name="adjustmentType"></param>
 public ApetureChunkAdjustment(Chunk.ID chunkID, FocusAdjustmentType adjustmentType = FocusAdjustmentType.InFocus)
 {
     this.chunkID = chunkID;
     type         = adjustmentType;
 }