public void BreadthFirstTraverseWork(Region root, RegionEntryPredicate entryCondition, RegionProcessor regionProcessor, int maxRegions, RegionType traversableRegionTypes)
 {
     if ((root.type & traversableRegionTypes) == 0)
     {
         return;
     }
     closedIndex++;
     open.Clear();
     numRegionsProcessed = 0;
     QueueNewOpenRegion(root);
     while (open.Count > 0)
     {
         Region region = open.Dequeue();
         if (DebugViewSettings.drawRegionTraversal)
         {
             region.Debug_Notify_Traversed();
         }
         if (regionProcessor != null && regionProcessor(region))
         {
             FinalizeSearch();
             return;
         }
         if (ShouldCountRegion(region))
         {
             numRegionsProcessed++;
         }
         if (numRegionsProcessed >= maxRegions)
         {
             FinalizeSearch();
             return;
         }
         for (int i = 0; i < region.links.Count; i++)
         {
             RegionLink regionLink = region.links[i];
             for (int j = 0; j < 2; j++)
             {
                 Region region2 = regionLink.regions[j];
                 if (region2 != null && region2.closedIndex[closedArrayPos] != closedIndex && (region2.type & traversableRegionTypes) != 0 && (entryCondition == null || entryCondition(region, region2)))
                 {
                     QueueNewOpenRegion(region2);
                 }
             }
         }
     }
     FinalizeSearch();
 }
示例#2
0
 public void BreadthFirstTraverseWork(Region root, RegionEntryPredicate entryCondition, RegionProcessor regionProcessor, int maxRegions, RegionType traversableRegionTypes)
 {
     if ((root.type & traversableRegionTypes) != RegionType.None)
     {
         this.closedIndex += 1u;
         this.open.Clear();
         this.numRegionsProcessed = 0;
         this.QueueNewOpenRegion(root);
         while (!this.open.Empty)
         {
             Region region = this.open.PopFront();
             if (DebugViewSettings.drawRegionTraversal)
             {
                 region.Debug_Notify_Traversed();
             }
             if (regionProcessor != null)
             {
                 if (regionProcessor(region))
                 {
                     this.FinalizeSearch();
                     return;
                 }
             }
             this.numRegionsProcessed++;
             if (this.numRegionsProcessed >= maxRegions)
             {
                 this.FinalizeSearch();
                 return;
             }
             for (int i = 0; i < region.links.Count; i++)
             {
                 RegionLink regionLink = region.links[i];
                 for (int j = 0; j < 2; j++)
                 {
                     Region region2 = regionLink.regions[j];
                     if (region2 != null && region2.closedIndex[this.closedArrayPos] != this.closedIndex && (region2.type & traversableRegionTypes) != RegionType.None && (entryCondition == null || entryCondition(region, region2)))
                     {
                         this.QueueNewOpenRegion(region2);
                     }
                 }
             }
         }
         this.FinalizeSearch();
     }
 }