public static void ClearCacheFor(Pawn p) { List <Map> maps = Find.Maps; for (int i = 0; i < maps.Count; i++) { maps[i].reachability.ClearCacheFor(p); MapExtensionUtility.GetExtensionToMap(maps[i]).getShipReachability.ClearCacheFor(p); } }
public static bool IsCornerTouchAllowed(int cornerX, int cornerZ, int adjCardinal1X, int adjCardinal1Z, int adjCardinal2X, int adjCardinal2Z, Map map) { Building building = map.edificeGrid[new IntVec3(cornerX, 0, cornerZ)]; if (!(building is null) && TouchPathEndModeUtilityShips.MakesOccupiedCellsAlwaysReachableDiagonally(building.def)) return true; IntVec3 intVec = new IntVec3(adjCardinal1X, 0, adjCardinal1Z); IntVec3 intVec2 = new IntVec3(adjCardinal2X, 0, adjCardinal2Z); MapExtension mapE = MapExtensionUtility.GetExtensionToMap(map); return (mapE.getShipPathGrid.Walkable(intVec) && intVec.GetDoor(map) is null) || (mapE.getShipPathGrid.Walkable(intVec2) && intVec2.GetDoor(map) is null); }
public ShipPathFinder(Map map) { this.map = map; this.mapE = MapExtensionUtility.GetExtensionToMap(map); this.mapSizeX = map.Size.x; this.mapSizeZ = map.Size.z; this.calcGrid = new ShipPathFinder.ShipPathFinderNodeFast[this.mapSizeX * this.mapSizeZ]; this.openList = new FastPriorityQueue <ShipPathFinder.CostNode>(new ShipPathFinder.CostNodeComparer()); this.regionCostCalculator = new RegionCostCalculatorWrapperShips(map); }
public void RecalculatePerceivedPathCostAt(IntVec3 c) { if (!c.InBoundsShip(this.map)) { return; } bool flag = this.WalkableFast(c); this.pathGrid[this.map.cellIndices.CellToIndex(c)] = this.CalculatedCostAt(c); if (this.WalkableFast(c) != flag) { MapExtensionUtility.GetExtensionToMap(this.map).getShipReachability.ClearCache(); AccessTools.Method(type: typeof(RegionDirtyer), name: "Notify_WalkabilityChanged").Invoke(this.map.regionDirtyer, new object[] { c }); } }
public void Init(CellRect end, TraverseParms traverseParms, int moveTicksCardinal, int moveTicksDiagonal, ByteGrid avoidGrid, Area allowedArea, bool drafted, List <int> disallowedCorners) { this.moveTicksCardinal = moveTicksCardinal; this.moveTicksDiagonal = moveTicksDiagonal; this.endCell = end.CenterCell; this.cachedRegion = null; this.cachedBestLink = null; this.cachedSecondBestLink = null; this.cachedBestLinkCost = 0; this.cachedSecondBestLinkCost = 0; this.cachedRegionIsDestination = false; this.regionGrid = MapExtensionUtility.GetExtensionToMap(this.map).getWaterRegionGrid.DirectGrid; this.destRegions.Clear(); if (end.Width == 1 && end.Height == 1) { WaterRegion region = WaterGridsUtility.GetRegion(this.endCell, this.map, RegionType.Set_Passable); if (region != null) { this.destRegions.Add(region); } } else { CellRect.CellRectIterator iterator = end.GetIterator(); while (!iterator.Done()) { IntVec3 intVec = iterator.Current; if (intVec.InBoundsShip(this.map) && !disallowedCorners.Contains(this.map.cellIndices.CellToIndex(intVec))) { WaterRegion region2 = WaterGridsUtility.GetRegion(intVec, this.map, RegionType.Set_Passable); if (region2 != null) { if (region2.Allows(traverseParms, true)) { this.destRegions.Add(region2); } } } iterator.MoveNext(); } } if (this.destRegions.Count == 0) { Log.Error("Couldn't find any destination regions. This shouldn't ever happen because we've checked reachability.", false); } this.regionCostCalculatorShips.Init(end, this.destRegions, traverseParms, moveTicksCardinal, moveTicksDiagonal, avoidGrid, allowedArea, drafted); }
public static bool CanReachShipMapEdge(this Pawn p) { return(p.Spawned && MapExtensionUtility.GetExtensionToMap(p.Map).getShipReachability.CanReachMapEdge(p.Position, TraverseParms.For(p, Danger.Deadly, TraverseMode.ByPawn, false))); }
public static bool CanReachShipNonLocal(this Pawn pawn, TargetInfo dest, PathEndMode peMode, Danger maxDanger, bool canBash = false, TraverseMode mode = TraverseMode.ByPawn) { return(pawn.Spawned && MapExtensionUtility.GetExtensionToMap(pawn.Map).getShipReachability.CanReachShipNonLocal(pawn.Position, dest, peMode, TraverseParms.For(pawn, maxDanger, mode, canBash))); }
public ShipReachability(Map map) { this.map = map; this.mapExt = MapExtensionUtility.GetExtensionToMap(map); }
public RegionCostCalculatorShips(Map map) { this.map = map; this.mapE = MapExtensionUtility.GetExtensionToMap(map); this.preciseRegionLinkDistancesDistanceGetter = new Func <int, int, float>(this.PreciseRegionLinkDistancesDistanceGetter); }
public static bool CanReachImmediateShip(IntVec3 start, LocalTargetInfo target, Map map, PathEndMode peMode, Pawn pawn) { if (!target.IsValid) { return(false); } target = (LocalTargetInfo)GenPathShip.ResolvePathMode(pawn, target.ToTargetInfo(map), ref peMode, MapExtensionUtility.GetExtensionToMap(map)); if (target.HasThing) { Thing thing = target.Thing; if (!thing.Spawned) { if (!(pawn is null)) { if (pawn.carryTracker.innerContainer.Contains(thing)) { return(true); } if (pawn.inventory.innerContainer.Contains(thing)) { return(true); } if (pawn.apparel != null && pawn.apparel.Contains(thing)) { return(true); } if (pawn.equipment != null && pawn.equipment.Contains(thing)) { return(true); } } return(false); } if (thing.Map != map) { return(false); } } if (!target.HasThing || target.Thing.def.size.x == 1 && target.Thing.def.size.z == 1) { if (start == target.Cell) { return(true); } } else if (start.IsInside(target.Thing)) { return(true); } return(peMode == PathEndMode.Touch && TouchPathEndModeUtilityShips.IsAdjacentOrInsideAndAllowedToTouch(start, target, map)); }