Ejemplo 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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        private void RegenerateNewWaterRegions()
        {
            this.newRegions.Clear();
            List <IntVec3> cells = this.map.regionDirtyer.DirtyCells;

            foreach (IntVec3 c  in cells)
            {
                if (WaterGridsUtility.GetRegion(c, this.map, RegionType.Set_All) is null)
                {
                    WaterRegion region = MapExtensionUtility.GetExtensionToMap(map).getWaterRegionmaker.TryGenerateRegionFrom(c);
                    if (!(region is null))
                    {
                        this.newRegions.Add(region);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static bool TryFindRandomReachableCellNear(IntVec3 root, Map map, float radius, TraverseParms traverseParms, Predicate <IntVec3> validator, out IntVec3 result,
                                                          Predicate <WaterRegion> regionValidator, int maxRegions = 999999)
        {
            if (map is null)
            {
                Log.ErrorOnce("Tried to find reachable cell using SPExtended in a null map", 61037855, false);
                result = IntVec3.Invalid;
                return(false);
            }
            WaterRegion region = WaterGridsUtility.GetRegion(root, map, RegionType.Set_Passable);

            if (region is null)
            {
                result = IntVec3.Invalid;
                return(false);
            }
            result = CellFinderExtended.RandomEdgeCell(Find.World.CoastDirectionAt(map.Tile), map, (IntVec3 c) => GenGridShips.Standable(c, map, MapExtensionUtility.GetExtensionToMap(map)) && !c.Fogged(map));
            return(true);
        }