mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
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
@ -115,7 +115,6 @@ class UnitAutomation{
|
|||||||
unit.moveToTile(distanceToTiles.keys.filter { it.unit == null }.toList().getRandom())
|
unit.moveToTile(distanceToTiles.keys.filter { it.unit == null }.toList().getRandom())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun rankTileAsCityCenter(tileInfo: TileInfo, nearbyTileRankings: Map<TileInfo, Float>): Float {
|
fun rankTileAsCityCenter(tileInfo: TileInfo, nearbyTileRankings: Map<TileInfo, Float>): Float {
|
||||||
val bestTilesFromOuterLayer = tileInfo.tileMap.getTilesAtDistance(tileInfo.position,2)
|
val bestTilesFromOuterLayer = tileInfo.tileMap.getTilesAtDistance(tileInfo.position,2)
|
||||||
.sortedByDescending { nearbyTileRankings[it] }.take(2)
|
.sortedByDescending { nearbyTileRankings[it] }.take(2)
|
||||||
|
@ -32,6 +32,11 @@ class MapUnit {
|
|||||||
fun doPreTurnAction() {
|
fun doPreTurnAction() {
|
||||||
val currentTile = getTile()
|
val currentTile = getTile()
|
||||||
if (currentMovement == 0f) return // We've already done stuff this turn, and can't do any more stuff
|
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")) {
|
if (action != null && action!!.startsWith("moveTo")) {
|
||||||
val destination = action!!.replace("moveTo ", "").split(",").dropLastWhile { it.isEmpty() }.toTypedArray()
|
val destination = action!!.replace("moveTo ", "").split(",").dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
val destinationVector = Vector2(Integer.parseInt(destination[0]).toFloat(), Integer.parseInt(destination[1]).toFloat())
|
val destinationVector = Vector2(Integer.parseInt(destination[0]).toFloat(), Integer.parseInt(destination[1]).toFloat())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user