Units in the middle of a preordered action (automate, move) don't do it if there's an enemy withing walking distance
This commit is contained in:
parent
18ec3eba9c
commit
41f37f5ee7
2 changed files with 5 additions and 1 deletions
|
@ -115,7 +115,6 @@ class UnitAutomation{
|
|||
unit.moveToTile(distanceToTiles.keys.filter { it.unit == null }.toList().getRandom())
|
||||
}
|
||||
|
||||
|
||||
fun rankTileAsCityCenter(tileInfo: TileInfo, nearbyTileRankings: Map<TileInfo, Float>): Float {
|
||||
val bestTilesFromOuterLayer = tileInfo.tileMap.getTilesAtDistance(tileInfo.position,2)
|
||||
.sortedByDescending { nearbyTileRankings[it] }.take(2)
|
||||
|
|
|
@ -32,6 +32,11 @@ class MapUnit {
|
|||
fun doPreTurnAction() {
|
||||
val currentTile = getTile()
|
||||
if (currentMovement == 0f) return // We've already done stuff this turn, and can't do any more stuff
|
||||
|
||||
val enemyUnitsInWalkingDistance = getDistanceToTiles().keys
|
||||
.filter { it.unit!=null && it.unit!!.civInfo!=civInfo }
|
||||
if(enemyUnitsInWalkingDistance.isNotEmpty()) return // Don't you dare move.
|
||||
|
||||
if (action != null && action!!.startsWith("moveTo")) {
|
||||
val destination = action!!.replace("moveTo ", "").split(",").dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
val destinationVector = Vector2(Integer.parseInt(destination[0]).toFloat(), Integer.parseInt(destination[1]).toFloat())
|
||||
|
|
Loading…
Reference in a new issue