mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 05:09:25 +07:00
Changed the heuristic to be applicable to any unit and to use canPassThrough() (#11383)
This commit is contained in:
@ -96,10 +96,9 @@ class UnitMovement(val unit: MapUnit) {
|
|||||||
val damageFreePath = getShortestPath(destination, true)
|
val damageFreePath = getShortestPath(destination, true)
|
||||||
if (damageFreePath.isNotEmpty()) return damageFreePath
|
if (damageFreePath.isNotEmpty()) return damageFreePath
|
||||||
}
|
}
|
||||||
if (unit.baseUnit.isWaterUnit()
|
if (destination.neighbors.none { isUnknownTileWeShouldAssumeToBePassable(it) || canPassThrough(it) }) {
|
||||||
&& destination.neighbors.none { isUnknownTileWeShouldAssumeToBePassable(it) || it.isWater }) {
|
// edge case where this all of the tiles around the destination are
|
||||||
// edge case where this unit is a boat and 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
|
||||||
// explored and known to be land so we know a priori that no path exists
|
|
||||||
pathfindingCache.setShortestPathCache(destination, listOf())
|
pathfindingCache.setShortestPathCache(destination, listOf())
|
||||||
return listOf()
|
return listOf()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user