mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 11:28:03 +07:00
Fixed bug where even if the unit couldn't be placed within 3 tiles it was still added to the civ's unit list
This commit is contained in:
parent
9fbb997e63
commit
ce00fd43e0
@ -60,10 +60,15 @@ class TileMap {
|
||||
|
||||
fun placeUnitNearTile(position: Vector2, unitName: String, civInfo: CivilizationInfo): MapUnit {
|
||||
val unit = GameBasics.Units[unitName]!!.getMapUnit()
|
||||
unit.assignOwner(civInfo)
|
||||
|
||||
val tilesInDistance = getTilesInDistance(position, 2)
|
||||
|
||||
unit.owner=civInfo.civName // needed in order to calculate canMoveTo
|
||||
val unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) }
|
||||
if(unitToPlaceTile!=null) unit.putInTile(unitToPlaceTile)
|
||||
if(unitToPlaceTile!=null) {
|
||||
unit.putInTile(unitToPlaceTile)
|
||||
unit.assignOwner(civInfo) // only once we know the unit can be placed do we add it to the civ's unit list
|
||||
}
|
||||
return unit
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user