bool ValidFloodCell(Map map, IntVec3 cell, IntVec3 from, bool ignoreBuildings) { if (cell.x < 0 || cell.x >= mapSizeX || cell.z < 0 || cell.z >= mapSizeZ) { return(false); } if (GetDirectInternal(cell, ignoreBuildings, false) != 0) { return(false); } // wrap things in try/catch because of concurrent access to data structures // used by the main thread try { if (pathGrid.WalkableFast(cell) == false) { if (ignoreBuildings) { return(edificeGrid != null && edificeGrid[cell] is Building building && (building as Mineable) == null); } return(false); } // walking diagonal works only when not across a diagonal gap in a wall // so lets check for that case if (ignoreBuildings == false && from.AdjacentToDiagonal(cell)) { if (BlocksDiagonalMovement(from.x, cell.z) || BlocksDiagonalMovement(cell.x, from.z)) { return(false); } } // For now, we disable this to gain execution speed //if (terrainGrid.TerrainAt(cell).DoesRepellZombies()) return false; return(true); } catch { return(false); } }
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 NeedNewPath(LocalTargetInfo destination, PawnPath curPath, Pawn pawn, PathEndMode peMode, IntVec3 lastPathedTargetPosition) { if (!destination.IsValid || curPath is null || !curPath.Found || curPath.NodesLeftCount == 0) { return(true); } if (destination.HasThing && destination.Thing.Map != pawn.Map) { return(true); } if ((pawn.Position.InHorDistOf(curPath.LastNode, 15f) || pawn.Position.InHorDistOf(destination.Cell, 15f)) && !ShipReachabilityImmediate.CanReachImmediateShip( curPath.LastNode, destination, pawn.Map, peMode, pawn)) { return(true); } if (curPath.UsedRegionHeuristics && curPath.NodesConsumedCount >= 75) { return(true); } if (lastPathedTargetPosition != destination.Cell) { float num = (float)(pawn.Position - 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)(lastPathedTargetPosition - destination.Cell).LengthHorizontalSquared > (num2 * num2)) { return(true); } } bool flag = curPath.NodesLeftCount < 30; IntVec3 other = IntVec3.Invalid; IntVec3 intVec = IntVec3.Invalid; int num3 = 0; while (num3 < 20 && num3 < curPath.NodesLeftCount) { intVec = curPath.Peek(num3); if (!GenGridShips.Walkable(intVec, MapExtensionUtility.GetExtensionToMap(pawn.Map))) { return(true); } if (num3 != 0 && intVec.AdjacentToDiagonal(other) && (ShipPathFinder.BlocksDiagonalMovement(pawn.Map.cellIndices.CellToIndex(intVec.x, other.z), pawn.Map, MapExtensionUtility.GetExtensionToMap(pawn.Map)) || ShipPathFinder.BlocksDiagonalMovement(pawn.Map.cellIndices.CellToIndex(other.x, intVec.z), pawn.Map, MapExtensionUtility.GetExtensionToMap(pawn.Map)))) { return(true); } other = intVec; num3++; } return(false); }