Update ReligiousUnitAutomation.kt (#12444)

This commit is contained in:
EmperorPinguin 2024-11-13 14:50:49 +01:00 committed by GitHub
parent 08378cb3c8
commit ba4003bb30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -105,17 +105,11 @@ object ReligiousUnitAutomation {
} }
if (destinationCity == null) return if (destinationCity == null) return
var destinationTile = destinationCity.getCenterTile() val destinationTile = destinationCity.getCenterTile().neighbors
if (!unit.movement.canReach(destinationTile)
// Wait for the addInCapital units to go to the city!
|| CivilianUnitAutomation.shouldClearTileForAddInCapitalUnits(unit, destinationTile)) {
destinationTile = destinationTile.neighbors
.filter { unit.movement.canMoveTo(it) || it == unit.getTile() } .filter { unit.movement.canMoveTo(it) || it == unit.getTile() }
.sortedBy { it.aerialDistanceTo(unit.currentTile) } .sortedBy { it.aerialDistanceTo(unit.currentTile) }
.firstOrNull { unit.movement.canReach(it) } .firstOrNull { unit.movement.canReach(it) }
?: return ?: return
}
unit.movement.headTowards(destinationTile) unit.movement.headTowards(destinationTile)