mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 13:49:54 +07:00
Resolved #2406 - land units prefer to be generated in land tiles
This commit is contained in:
@ -144,7 +144,9 @@ class TileMap {
|
|||||||
var tryCount = 0
|
var tryCount = 0
|
||||||
var potentialCandidates = getPassableNeighbours(currentTile)
|
var potentialCandidates = getPassableNeighbours(currentTile)
|
||||||
while (unitToPlaceTile == null && tryCount++ < 10) {
|
while (unitToPlaceTile == null && tryCount++ < 10) {
|
||||||
unitToPlaceTile = potentialCandidates.firstOrNull { unit.movement.canMoveTo(it) }
|
unitToPlaceTile = potentialCandidates
|
||||||
|
.sortedByDescending { if(unit.type.isLandUnit()) it.isLand else true } // Land units should prefer to go into land tiles
|
||||||
|
.firstOrNull { unit.movement.canMoveTo(it) }
|
||||||
if (unitToPlaceTile != null) continue
|
if (unitToPlaceTile != null) continue
|
||||||
// if it's not found yet, let's check their neighbours
|
// if it's not found yet, let's check their neighbours
|
||||||
val newPotentialCandidates = mutableSetOf<TileInfo>()
|
val newPotentialCandidates = mutableSetOf<TileInfo>()
|
||||||
|
Reference in New Issue
Block a user