Fixed 'move to tile' when selecting tile outside of current movement range (#11947)

This commit is contained in:
Yair Morgenstern 2024-07-11 21:28:44 +03:00 committed by GitHub
parent c0c76ad618
commit af4782ec08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -282,10 +282,10 @@ class WorldMapHolder(
// Since this runs in a different thread, even if we check movement.canReach()
// then it might change until we get to the getTileToMoveTo, so we just try/catch it
val tileToMoveTo: Tile
val pathToTile: List<Tile>
val pathToTile: List<Tile>?
try {
tileToMoveTo = selectedUnit.movement.getTileToMoveToThisTurn(targetTile)
pathToTile = selectedUnit.movement.getDistanceToTiles().getPathToTile(targetTile)
pathToTile = selectedUnit.movement.getDistanceToTiles().getPathToTile(tileToMoveTo)
} catch (ex: Exception) {
when (ex) {
is UnitMovement.UnreachableDestinationException -> {
@ -320,7 +320,7 @@ class WorldMapHolder(
worldScreen.shouldUpdate = true
animateMovement(previousTile, selectedUnit, targetTile, pathToTile)
animateMovement(previousTile, selectedUnit, tileToMoveTo, pathToTile)
if (selectedUnits.size > 1) { // We have more tiles to move
moveUnitToTargetTile(selectedUnits.subList(1, selectedUnits.size), targetTile)