Exemplo n.º 1
0
        //FloodAndSetRooms

        //FloodAndSetNewRegionIndex

        public static bool WithinRegions(this IntVec3 A, IntVec3 B, Map map, int regionLookCount, TraverseParms traverseParams, RegionType traversableRegionTypes = RegionType.Set_Passable)
        {
            WaterRegion region = WaterGridsUtility.GetRegion(A, map, traversableRegionTypes);

            if (region is null)
            {
                return(false);
            }
            WaterRegion regB = WaterGridsUtility.GetRegion(B, map, traversableRegionTypes);

            if (regB is null)
            {
                return(false);
            }
            if (region == regB)
            {
                return(true);
            }
            WaterRegionEntryPredicate entryCondition = (WaterRegion from, WaterRegion r) => r.Allows(traverseParams, false);
            bool found = false;
            WaterRegionProcessor regionProcessor = delegate(WaterRegion r)
            {
                if (r == regB)
                {
                    found = true;
                    return(true);
                }
                return(false);
            };

            WaterRegionTraverser.BreadthFirstTraverse(region, entryCondition, regionProcessor, regionLookCount, traversableRegionTypes);
            return(found);
        }
Exemplo n.º 2
0
 public static void MarkRegionsBFS(WaterRegion root, WaterRegionEntryPredicate entryCondition, int maxRegions, int inRadiusMark, RegionType traversableRegionTypes = RegionType.Set_Passable)
 {
     WaterRegionTraverser.BreadthFirstTraverse(root, entryCondition, delegate(WaterRegion r)
     {
         r.mark = inRadiusMark;
         return(false);
     }, maxRegions, traversableRegionTypes);
 }
Exemplo n.º 3
0
        public static void BreadthFirstTraverse(IntVec3 start, Map map, WaterRegionEntryPredicate entryCondition, WaterRegionProcessor regionProcessor, int maxRegions = 999999, RegionType traversableRegionTypes = RegionType.Set_Passable)
        {
            WaterRegion region = WaterGridsUtility.GetRegion(start, map, traversableRegionTypes);

            if (region is null)
            {
                return;
            }
            WaterRegionTraverser.BreadthFirstTraverse(region, entryCondition, regionProcessor, maxRegions, traversableRegionTypes);
        }
Exemplo n.º 4
0
 public void BreadthFirstTraverseWork(WaterRegion root, WaterRegionEntryPredicate entryCondition, WaterRegionProcessor regionProcessor, int maxRegions, RegionType traversableRegionTypes)
 {
     if ((root.type & traversableRegionTypes) == RegionType.None)
     {
         return;
     }
     this.closedIndex += 1u;
     this.open.Clear();
     this.numRegionsProcessed = 0;
     this.QueueNewOpenRegion(root);
     while (this.open.Count > 0)
     {
         WaterRegion region = this.open.Dequeue();
         if (ShipHarmony.debug)
         {
             region.Debug_Notify_Traversed();
         }
         if (!(regionProcessor is null) && regionProcessor(region))
         {
             this.FinalizeSearch();
             return;
         }
         if (WaterRegionTraverser.ShouldCountRegion(region))
         {
             this.numRegionsProcessed++;
         }
         if (this.numRegionsProcessed >= maxRegions)
         {
             this.FinalizeSearch();
             return;
         }
         for (int i = 0; i < region.links.Count; i++)
         {
             WaterRegionLink regionLink = region.links[i];
             for (int j = 0; j < 2; j++)
             {
                 WaterRegion region2 = regionLink.regions[j];
                 if (!(region2 is null) && region2.closedIndex[this.closedArrayPos] != this.closedIndex && (region2.type & traversableRegionTypes) != RegionType.None &&
                     (entryCondition is null || entryCondition(region, region2)))
                 {
                     this.QueueNewOpenRegion(region2);
                 }
             }
         }
     }
     this.FinalizeSearch();
 }
Exemplo n.º 5
0
 static WaterRegionTraverser()
 {
     WaterRegionTraverser.RecreateWorkers();
 }