mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-21 01:37:39 +07:00
Merge pull request #347 from ninjatao/place_new_unit
prefer to place new land units on land.
This commit is contained in:
commit
b3c79ec299
@ -74,10 +74,12 @@ class TileMap {
|
||||
fun placeUnitNearTile(position: Vector2, unitName: String, civInfo: CivilizationInfo): MapUnit {
|
||||
val unit = GameBasics.Units[unitName]!!.getMapUnit()
|
||||
val tilesInDistance = getTilesInDistance(position, 2)
|
||||
|
||||
unit.assignOwner(civInfo) // both the civ name and actual civ need to be in here in order to calculate the canMoveTo...Darn
|
||||
val unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) }
|
||||
if(unitToPlaceTile!=null) {
|
||||
var unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) && (unit.type.isWaterUnit() || it.isLand()) }
|
||||
if (unitToPlaceTile==null)
|
||||
unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) }
|
||||
|
||||
if(unitToPlaceTile!=null) { //see if a land unit can be placed on land. if impossible, put it on water.
|
||||
// only once we know the unit can be placed do we add it to the civ's unit list
|
||||
unit.putInTile(unitToPlaceTile)
|
||||
unit.currentMovement = unit.getMaxMovement().toFloat()
|
||||
|
Loading…
Reference in New Issue
Block a user