When cities expand, units that aren't allowed to enter there are pushed to the closest moveable tile

This commit is contained in:
Yair Morgenstern 2018-08-12 08:56:10 +03:00
parent 4a35d2f3db
commit 4c0372a8b5
4 changed files with 4 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 849 KiB

After

Width:  |  Height:  |  Size: 850 KiB

View File

@ -43,6 +43,9 @@ class CityExpansionManager {
cityInfo.tiles.remove(tileInfo.position)
cityInfo.tiles.add(tileInfo.position)
for(unit in tileInfo.getUnits())
if(!unit.civInfo.canEnterTiles(cityInfo.civInfo))
unit.movementAlgs().teleportToClosestMoveableTile()
}
fun getNewTile(): TileInfo? {

View File

@ -1,7 +1,6 @@
package com.unciv.logic.map
import com.badlogic.gdx.math.Vector2
import com.unciv.models.gamebasics.unit.UnitType
class UnitMovementAlgorithms(val unit:MapUnit) {
val tileMap = unit.getTile().tileMap
@ -185,9 +184,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
.firstOrNull{unit.canMoveTo(it)}
}
unit.removeFromTile() // we "teleport" them away
if(unit.getBaseUnit().unitType==UnitType.Civilian)
allowedTile.civilianUnit=unit
else allowedTile.militaryUnit=unit
unit.putInTile(allowedTile)
}
}