Changed the heuristic to be applicable to any unit and to use canPassThrough() (#11383)

This commit is contained in:
Oskar Niesen
2024-04-04 15:40:56 -05:00
committed by GitHub
parent 455afcee75
commit a743c4d8ff

View File

@ -96,10 +96,9 @@ class UnitMovement(val unit: MapUnit) {
val damageFreePath = getShortestPath(destination, true)
if (damageFreePath.isNotEmpty()) return damageFreePath
}
if (unit.baseUnit.isWaterUnit()
&& destination.neighbors.none { isUnknownTileWeShouldAssumeToBePassable(it) || it.isWater }) {
// edge case where this unit is a boat and all of the tiles around the destination are
// explored and known to be land so we know a priori that no path exists
if (destination.neighbors.none { isUnknownTileWeShouldAssumeToBePassable(it) || canPassThrough(it) }) {
// edge case where this all of the tiles around the destination are
// explored and known the unit can't pass through any of thoes tiles so we know a priori that no path exists
pathfindingCache.setShortestPathCache(destination, listOf())
return listOf()
}