From a743c4d8fff32d09e2640e1336139f044a5226db Mon Sep 17 00:00:00 2001 From: Oskar Niesen Date: Thu, 4 Apr 2024 15:40:56 -0500 Subject: [PATCH] Changed the heuristic to be applicable to any unit and to use canPassThrough() (#11383) --- .../com/unciv/logic/map/mapunit/movement/UnitMovement.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt b/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt index 22c701b8a6..e1e862076c 100644 --- a/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt +++ b/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt @@ -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() }