When aa unit that was moving towards somewhere encounters an enemy unit within walking distance, it stops the movement that it had completely

This commit is contained in:
Yair Morgenstern 2018-07-01 17:10:52 +03:00
parent 4593bed7dc
commit 67b9b7ea7a

View File

@ -42,7 +42,10 @@ class MapUnit {
val enemyUnitsInWalkingDistance = getDistanceToTiles().keys
.filter { it.militaryUnit!=null && it.militaryUnit!!.civInfo!=civInfo }
if(enemyUnitsInWalkingDistance.isNotEmpty()) return // Don't you dare move.
if(enemyUnitsInWalkingDistance.isNotEmpty()) {
if (action != null && action!!.startsWith("moveTo")) action=null
return // Don't you dare move.
}
if (action != null && action!!.startsWith("moveTo")) {
val destination = action!!.replace("moveTo ", "").split(",").dropLastWhile { it.isEmpty() }.toTypedArray()