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
1 changed files with 4 additions and 2 deletions
|
@ -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 a new issue