Fixed bug where game would crash if you ordered a unit to go womewhere that it can't reach (now it just ignores you entirely)
This commit is contained in:
parent
8b748384af
commit
602532b721
1 changed files with 6 additions and 0 deletions
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label
|
|||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.logic.map.UnitMovementAlgorithms
|
||||
import com.unciv.logic.map.UnitType
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
|
@ -64,6 +65,11 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||
|
||||
fun tileSelected(selectedTile: TileInfo) {
|
||||
if(currentlyExecutingAction=="moveTo"){
|
||||
|
||||
if(UnitMovementAlgorithms(selectedTile.tileMap)
|
||||
.getShortestPath(selectedTile.position, selectedTile.position, selectedUnit!!).isEmpty())
|
||||
return // can't reach there with the selected unit, watcha want me to do?
|
||||
|
||||
val reachedTile = selectedUnit!!.headTowards(selectedTile.position)
|
||||
|
||||
if(reachedTile!=selectedTile) // Didn't get all the way there
|
||||
|
|
Loading…
Reference in a new issue