Esempio n. 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);
            }
        }
Esempio n. 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();
        }
Esempio n. 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
 }
Esempio n. 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);
        }
Esempio n. 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();
        }
Esempio n. 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();
        }
 protected bool TerminateHereCondition(ChunkStageData stageData)
 {
     return(!pipeline.TargetStageGreaterThanCurrent(StageID, stageData));
 }
 public abstract void Add(Vector3Int incoming, ChunkStageData stageData);
Esempio n. 9
0
 public bool TargetStageGreaterThanCurrent(int currentStage, ChunkStageData stageData)
 {
     return(stageData.targetStage > currentStage);
 }
Esempio n. 10
0
 private bool ChunkDataReadable(ChunkStageData stageData)
 {
     return(stageData.minStage >= FullyGeneratedStage);
 }