Ejemplo n.º 1
0
        public static bool CanReachImmediateShip(IntVec3 start, CellRect rect, Map map, PathEndMode peMode, Pawn pawn)
        {
            IntVec3 c = rect.ClosestCellTo(start);

            return(ShipReachabilityImmediate.CanReachImmediateShip(start, c, map, peMode, pawn));
        }
Ejemplo n.º 2
0
        private bool CheckCellBasedReachability(IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParms)
        {
            IntVec3 foundCell = IntVec3.Invalid;

            WaterRegion[] directionRegionGrid = this.regionGrid.DirectGrid;
            ShipPathGrid  pathGrid            = mapExt.getShipPathGrid;
            CellIndices   cellIndices         = this.map.cellIndices;

            this.map.floodFiller.FloodFill(start, delegate(IntVec3 c)
            {
                int num = cellIndices.CellToIndex(c);
                if ((traverseParms.mode == TraverseMode.PassAllDestroyableThingsNotWater || traverseParms.mode == TraverseMode.NoPassClosedDoorsOrWater) &&
                    c.GetTerrain(this.map).IsWater)
                {
                    return(false);
                }
                if (traverseParms.mode == TraverseMode.PassAllDestroyableThings || traverseParms.mode == TraverseMode.PassAllDestroyableThingsNotWater)
                {
                    if (!pathGrid.WalkableFast(num))
                    {
                        Building edifice = c.GetEdifice(this.map);
                        if (edifice is null || !ShipPathFinder.IsDestroyable(edifice))
                        {
                            return(false);
                        }
                    }
                }
                else if (traverseParms.mode != TraverseMode.NoPassClosedDoorsOrWater)
                {
                    //Log.ErrorOnce("Do not use this method for non-cell based modes!", 938476762, false);
                    if (!pathGrid.WalkableFast(num))
                    {
                        return(false);
                    }
                }
                WaterRegion region = directionRegionGrid[num];
                return(region is null || region.Allows(traverseParms, false));
            }, delegate(IntVec3 c)
            {
                if (ShipReachabilityImmediate.CanReachImmediateShip(c, dest, this.map, peMode, traverseParms.pawn))
                {
                    foundCell = c;
                    return(true);
                }
                return(false);
            }, int.MaxValue, false, null);

            if (foundCell.IsValid)
            {
                if (this.CanUseCache(traverseParms.mode))
                {
                    WaterRegion validRegionAt = this.regionGrid.GetValidRegionAt(foundCell);
                    if (!(validRegionAt is null))
                    {
                        foreach (WaterRegion startRegion in this.startingRegions)
                        {
                            this.cache.AddCachedResult(startRegion.Room, validRegionAt.Room, traverseParms, true);
                        }
                    }
                }
                return(true);
            }
            if (this.CanUseCache(traverseParms.mode))
            {
                foreach (WaterRegion startRegion in this.startingRegions)
                {
                    foreach (WaterRegion destRegion in this.destRegions)
                    {
                        this.cache.AddCachedResult(startRegion.Room, destRegion.Room, traverseParms, false);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
 public static bool CanReachImmediateShip(this Pawn pawn, LocalTargetInfo target, PathEndMode peMode)
 {
     return(pawn.Spawned && ShipReachabilityImmediate.CanReachImmediateShip(pawn.Position, target, pawn.Map, peMode, pawn));
 }