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)
        {
            VehicleRegion region = VehicleGridsUtility.GetRegion(A, map, traversableRegionTypes);

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

            if (regB is null)
            {
                return(false);
            }
            if (region == regB)
            {
                return(true);
            }
            bool entryCondition(VehicleRegion from, VehicleRegion r) => r.Allows(traverseParams, false);

            bool found = false;

            bool regionProcessor(VehicleRegion r)
            {
                if (r == regB)
                {
                    found = true;
                    return(true);
                }
                return(false);
            }

            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)
        {
            VehicleRegion region = VehicleGridsUtility.GetRegion(start, map, traversableRegionTypes);

            if (region is null)
            {
                return;
            }
            BreadthFirstTraverse(region, entryCondition, regionProcessor, maxRegions, traversableRegionTypes);
        }
        private void RegenerateNewWaterRegions()
        {
            newRegions.Clear();
            List <IntVec3> cells = map.GetCachedMapComponent <VehicleMapping>().VehicleRegionDirtyer.DirtyCells;

            foreach (IntVec3 c  in cells)
            {
                if (VehicleGridsUtility.GetRegion(c, map, RegionType.Set_All) is null)
                {
                    VehicleRegion region = map.GetCachedMapComponent <VehicleMapping>().VehicleRegionMaker.TryGenerateRegionFrom(c);

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

            if (region is null)
            {
                result = IntVec3.Invalid;
                return(false);
            }
            Rot4 dir = Find.World.CoastDirectionAt(map.Tile).IsValid ? Find.World.CoastDirectionAt(map.Tile) : !Find.WorldGrid[map.Tile].Rivers.NullOrEmpty() ? Ext_Map.RiverDirection(map) : Rot4.Invalid;

            result = RandomEdgeCell(dir, map, (IntVec3 c) => GenGridVehicles.Standable(c, map) && !c.Fogged(map), 0);
            return(true);
        }