コード例 #1
0
        public override void Add(Vector3Int incoming, ChunkStageData stageData)
        {
            if (!TerminateHereCondition(stageData))
            {
                Assert.IsFalse(jobs.ContainsKey(incoming), $"Job stages do not support duplicates," +
                               $" tried to add {incoming} when it already existed in stage {Name}");

                AddJob(incoming);
            }
        }
コード例 #2
0
        private void SetNewMinimumIfSmallerThanCurrent(Vector3Int chunkId, ChunkStageData stageData, int proposedMinimum)
        {
            if (stageData.minStage <= proposedMinimum)
            {
                return;
            }
            //minimum stage is decreasing
            stageData.minStage = proposedMinimum;

            Profiler.BeginSample("ChunkMinStageDecreasedEvent");
            OnChunkMinStageDecreased(chunkId, stageData.minStage);
            Profiler.EndSample();
        }
コード例 #3
0
 public override void Add(Vector3Int incoming, ChunkStageData stageData)
 {
     if (!TerminateHereCondition(stageData))
     {
         if (queue.Contains(incoming))//Update priority if item existed
         {
             queue.UpdatePriority(incoming, getPriority(incoming));
         }
         else
         {//Add to queue otherwise
             queue.Enqueue(incoming, getPriority(incoming));
         }
     }
     //incoming terminates here and so does not need to be added to the queue
 }
コード例 #4
0
        /// <summary>
        /// Private version of above
        /// </summary>
        /// <param name="chunkId"></param>
        /// <param name="stage"></param>
        /// <param name="stageData"></param>
        private void ReenterAtStage(Vector3Int chunkId, int stage, ChunkStageData stageData)
        {
            if (stage > stageData.maxStage)
            {
                throw new ArgumentOutOfRangeException($"Cannot reenter chunk id {chunkId} at stage {stage} because it has " +
                                                      $"never previously reached that stage. The current max stage is {stageData.maxStage}");
            }

            var stageToEnter = stages[stage];

            //Potentially update min
            SetNewMinimumIfSmallerThanCurrent(chunkId, stageData, stage);

            stageToEnter.Add(chunkId, stageData);
        }
コード例 #5
0
        public void Add(Vector3Int chunkId, int targetStage)
        {
            CheckLockBeforeExternalOperation();

            Assert.IsFalse(chunkStageMap.ContainsKey(chunkId));
            var stageData = new ChunkStageData()
            {
                targetStage = targetStage, minStage = 0, maxStage = 0
            };

            chunkStageMap.Add(chunkId, stageData);
            //Add to first stage
            stages[0].Add(chunkId, stageData);

            Profiler.BeginSample("ChunkAddedToPipelineEvent");
            OnChunkAddedToPipeline(chunkId, 0);
            Profiler.EndSample();
        }
コード例 #6
0
        /// <summary>
        /// Add a chunk to the pipeline that already has data (e.g it was loaded from storage)
        /// Therefore it skips the usual generation stages. (but still goes through the light
        /// generation)
        /// </summary>
        /// <param name="chunkId"></param>
        public void AddWithData(Vector3Int chunkId, int targetStage, bool generateLights = false)
        {
            CheckLockBeforeExternalOperation();

            Assert.IsFalse(chunkStageMap.ContainsKey(chunkId));

            var EnterAtStageId = generateLights ? PreLightGenWaitStage : FullyGeneratedStage;

            var stageData = new ChunkStageData()
            {
                targetStage = targetStage,
                minStage    = EnterAtStageId,
                maxStage    = EnterAtStageId
            };

            chunkStageMap.Add(chunkId, stageData);

            //Add to stage
            stages[EnterAtStageId].Add(chunkId, stageData);

            Profiler.BeginSample("ChunkAddedToPipelineEvent");
            OnChunkAddedToPipeline(chunkId, EnterAtStageId);
            Profiler.EndSample();
        }
コード例 #7
0
 protected bool TerminateHereCondition(ChunkStageData stageData)
 {
     return(!pipeline.TargetStageGreaterThanCurrent(StageID, stageData));
 }
コード例 #8
0
 public abstract void Add(Vector3Int incoming, ChunkStageData stageData);
コード例 #9
0
 public bool TargetStageGreaterThanCurrent(int currentStage, ChunkStageData stageData)
 {
     return(stageData.targetStage > currentStage);
 }
コード例 #10
0
 private bool ChunkDataReadable(ChunkStageData stageData)
 {
     return(stageData.minStage >= FullyGeneratedStage);
 }