private List <int> PathableNeighborIndices(int index) { RegionCostCalculator.tmpPathableNeighborIndices.Clear(); PathGrid pathGrid = this.map.pathGrid; IntVec3 size = this.map.Size; int x = size.x; bool flag = index % x > 0; bool flag2 = index % x < x - 1; bool flag3 = index >= x; int num = index / x; IntVec3 size2 = this.map.Size; bool flag4 = num < size2.z - 1; if (flag3 && pathGrid.WalkableFast(index - x)) { RegionCostCalculator.tmpPathableNeighborIndices.Add(index - x); } if (flag2 && pathGrid.WalkableFast(index + 1)) { RegionCostCalculator.tmpPathableNeighborIndices.Add(index + 1); } if (flag && pathGrid.WalkableFast(index - 1)) { RegionCostCalculator.tmpPathableNeighborIndices.Add(index - 1); } if (flag4 && pathGrid.WalkableFast(index + x)) { RegionCostCalculator.tmpPathableNeighborIndices.Add(index + x); } bool flag5 = !flag || PathFinder.BlocksDiagonalMovement(index - 1, this.map); bool flag6 = !flag2 || PathFinder.BlocksDiagonalMovement(index + 1, this.map); if (flag3 && !PathFinder.BlocksDiagonalMovement(index - x, this.map)) { if (!flag6 && pathGrid.WalkableFast(index - x + 1)) { RegionCostCalculator.tmpPathableNeighborIndices.Add(index - x + 1); } if (!flag5 && pathGrid.WalkableFast(index - x - 1)) { RegionCostCalculator.tmpPathableNeighborIndices.Add(index - x - 1); } } if (flag4 && !PathFinder.BlocksDiagonalMovement(index + x, this.map)) { if (!flag6 && pathGrid.WalkableFast(index + x + 1)) { RegionCostCalculator.tmpPathableNeighborIndices.Add(index + x + 1); } if (!flag5 && pathGrid.WalkableFast(index + x - 1)) { RegionCostCalculator.tmpPathableNeighborIndices.Add(index + x - 1); } } return(RegionCostCalculator.tmpPathableNeighborIndices); }
private List <int> PathableNeighborIndices(int index) { tmpPathableNeighborIndices.Clear(); PathGrid pathGrid = map.pathGrid; int x = map.Size.x; bool num = index % x > 0; bool flag = index % x < x - 1; bool flag2 = index >= x; bool flag3 = index / x < map.Size.z - 1; if (flag2 && pathGrid.WalkableFast(index - x)) { tmpPathableNeighborIndices.Add(index - x); } if (flag && pathGrid.WalkableFast(index + 1)) { tmpPathableNeighborIndices.Add(index + 1); } if (num && pathGrid.WalkableFast(index - 1)) { tmpPathableNeighborIndices.Add(index - 1); } if (flag3 && pathGrid.WalkableFast(index + x)) { tmpPathableNeighborIndices.Add(index + x); } bool flag4 = !num || PathFinder.BlocksDiagonalMovement(index - 1, map); bool flag5 = !flag || PathFinder.BlocksDiagonalMovement(index + 1, map); if (flag2 && !PathFinder.BlocksDiagonalMovement(index - x, map)) { if (!flag5 && pathGrid.WalkableFast(index - x + 1)) { tmpPathableNeighborIndices.Add(index - x + 1); } if (!flag4 && pathGrid.WalkableFast(index - x - 1)) { tmpPathableNeighborIndices.Add(index - x - 1); } } if (flag3 && !PathFinder.BlocksDiagonalMovement(index + x, map)) { if (!flag5 && pathGrid.WalkableFast(index + x + 1)) { tmpPathableNeighborIndices.Add(index + x + 1); } if (!flag4 && pathGrid.WalkableFast(index + x - 1)) { tmpPathableNeighborIndices.Add(index + x - 1); } } return(tmpPathableNeighborIndices); }
private bool NeedNewPath() { if (!this.destination.IsValid || this.curPath == null || !this.curPath.Found || this.curPath.NodesLeftCount == 0) { return(true); } if (this.destination.HasThing && this.destination.Thing.Map != this.pawn.Map) { return(true); } if ((this.pawn.Position.InHorDistOf(this.curPath.LastNode, 15f) || this.pawn.Position.InHorDistOf(this.destination.Cell, 15f)) && !ReachabilityImmediate.CanReachImmediate(this.curPath.LastNode, this.destination, this.pawn.Map, this.peMode, this.pawn)) { return(true); } if (this.curPath.UsedRegionHeuristics && this.curPath.NodesConsumedCount >= 75) { return(true); } if (this.lastPathedTargetPosition != this.destination.Cell) { float num = (float)(this.pawn.Position - this.destination.Cell).LengthHorizontalSquared; float num2; if (num > 900f) { num2 = 10f; } else if (num > 289f) { num2 = 5f; } else if (num > 100f) { num2 = 3f; } else if (num > 49f) { num2 = 2f; } else { num2 = 0.5f; } if ((float)(this.lastPathedTargetPosition - this.destination.Cell).LengthHorizontalSquared > num2 * num2) { return(true); } } bool flag = PawnUtility.ShouldCollideWithPawns(this.pawn); bool flag2 = this.curPath.NodesLeftCount < 30; IntVec3 other = IntVec3.Invalid; int num3 = 0; while (num3 < 20 && num3 < this.curPath.NodesLeftCount) { IntVec3 intVec = this.curPath.Peek(num3); if (!intVec.Walkable(this.pawn.Map)) { return(true); } if (flag && !this.BestPathHadPawnsInTheWayRecently() && (PawnUtility.AnyPawnBlockingPathAt(intVec, this.pawn, false, true, false) || (flag2 && PawnUtility.AnyPawnBlockingPathAt(intVec, this.pawn, false, false, false)))) { return(true); } if (!this.BestPathHadDangerRecently() && PawnUtility.KnownDangerAt(intVec, this.pawn.Map, this.pawn)) { return(true); } Building_Door building_Door = intVec.GetEdifice(this.pawn.Map) as Building_Door; if (building_Door != null) { if (!building_Door.CanPhysicallyPass(this.pawn) && !this.pawn.HostileTo(building_Door)) { return(true); } if (building_Door.IsForbiddenToPass(this.pawn)) { return(true); } } if (num3 != 0 && intVec.AdjacentToDiagonal(other) && (PathFinder.BlocksDiagonalMovement(intVec.x, other.z, this.pawn.Map) || PathFinder.BlocksDiagonalMovement(other.x, intVec.z, this.pawn.Map))) { return(true); } other = intVec; num3++; } return(false); }
public static bool BlocksDiagonalMovement(int x, int z, Map map) { return(PathFinder.BlocksDiagonalMovement(map.cellIndices.CellToIndex(x, z), map)); }
private bool BlocksDiagonalMovement(int index) { return(PathFinder.BlocksDiagonalMovement(index, this.map)); }
private bool BlocksDiagonalMovement(int x, int z) { return(PathFinder.BlocksDiagonalMovement(x, z, this.map)); }