mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 23:37:31 +07:00
Fixed bug where workers would try to head towards tiles they couldn't reach to construct roads
This commit is contained in:
parent
0c17e19ea2
commit
1c304da9d1
@ -60,8 +60,10 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
return true
|
||||
}
|
||||
|
||||
val closestTileInPathWithNoRoad = pathToClosestCity.filter { unit.canMoveTo(it)}
|
||||
.minBy { HexMath().getDistance(unit.getTile().position, it.position) }
|
||||
val closestTileInPathWithNoRoad = pathToClosestCity
|
||||
.filter { unit.canMoveTo(it)}
|
||||
.sortedByDescending { HexMath().getDistance(unit.getTile().position, it.position) }
|
||||
.firstOrNull { unit.movementAlgs().canReach(it) }
|
||||
|
||||
if(closestTileInPathWithNoRoad==null) return false
|
||||
unit.movementAlgs().headTowards(closestTileInPathWithNoRoad)
|
||||
|
Loading…
Reference in New Issue
Block a user