UnitMovementAlgorithms

class UnitMovementAlgorithms(unit: MapUnit)

Types

ParentTileAndTotalDistance
Link copied to clipboard
class ParentTileAndTotalDistance(parentTile: TileInfo, totalDistance: Float)

Functions

canAirUnitMoveTo
Link copied to clipboard
private fun canAirUnitMoveTo(tile: TileInfo, unit: MapUnit): Boolean
canMoveTo
Link copied to clipboard
fun canMoveTo(tile: TileInfo, assumeCanPassThrough: Boolean = false): Boolean

Designates whether we can enter the tile - without attacking DOES NOT designate whether we can reach that tile in the current turn

canParadropOn
Link copied to clipboard
fun canParadropOn(destination: TileInfo): Boolean
canPassThrough
Link copied to clipboard
fun canPassThrough(tile: TileInfo): Boolean
canReach
Link copied to clipboard
fun canReach(destination: TileInfo): Boolean

This is performance-heavy - use as last resort, only after checking everything else! Also note that REACHABLE tiles are not necessarily tiles that the unit CAN ENTER

canReachInCurrentTurn
Link copied to clipboard
private fun canReachInCurrentTurn(destination: TileInfo): Boolean
canUnitSwapTo
Link copied to clipboard
fun canUnitSwapTo(destination: TileInfo): Boolean

Returns whether we can perform a swap move to the specified tile

canUnitSwapToReachableTile
Link copied to clipboard
private fun canUnitSwapToReachableTile(reachableTile: TileInfo): Boolean

Returns whether we can perform a unit swap move to the specified tile, given that it is reachable in the current turn

equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
getAerialPathsToCities
Link copied to clipboard
fun getAerialPathsToCities(): HashMap<TileInfo, ArrayList<TileInfo>>
getDistanceToTiles
Link copied to clipboard
fun getDistanceToTiles(considerZoneOfControl: Boolean = true): PathsToTilesWithinTurn
getDistanceToTilesWithinTurn
Link copied to clipboard
fun getDistanceToTilesWithinTurn(origin: Vector2, unitMovement: Float, considerZoneOfControl: Boolean = true): PathsToTilesWithinTurn

Does not consider if tiles can actually be entered, use canMoveTo for that. If a tile can be reached within the turn, but it cannot be passed through, the total distance to it is set to unitMovement

getMovementCostBetweenAdjacentTiles
Link copied to clipboard
private fun getMovementCostBetweenAdjacentTiles(from: TileInfo, to: TileInfo, civInfo: CivilizationInfo, considerZoneOfControl: Boolean = true): Float
getReachableTilesInCurrentTurn
Link copied to clipboard
fun getReachableTilesInCurrentTurn(): Sequence<TileInfo>
getShortestPath
Link copied to clipboard
fun getShortestPath(destination: TileInfo, avoidDamagingTerrain: Boolean = false): List<TileInfo>

Does not consider if the destination tile can actually be entered, use canMoveTo for that. Returns an empty list if there's no way to get to the destination.

getTileToMoveToThisTurn
Link copied to clipboard
fun getTileToMoveToThisTurn(finalDestination: TileInfo): TileInfo
getUnitSwappableTiles
Link copied to clipboard
fun getUnitSwappableTiles(): Sequence<TileInfo>

Returns the tiles to which we can perform a swap move

hashCode
Link copied to clipboard
open fun hashCode(): Int
headTowards
Link copied to clipboard
fun headTowards(destination: TileInfo): TileInfo
isMovementAffectedByZoneOfControl
Link copied to clipboard
private fun isMovementAffectedByZoneOfControl(from: TileInfo, to: TileInfo, civInfo: CivilizationInfo): Boolean

Returns whether the movement between the adjacent tiles from and to is affected by Zone of Control

isUnknownTileWeShouldAssumeToBePassable
Link copied to clipboard
fun isUnknownTileWeShouldAssumeToBePassable(tileInfo: TileInfo): Boolean
moveToTile
Link copied to clipboard
fun moveToTile(destination: TileInfo, considerZoneOfControl: Boolean = true)
swapMoveToTile
Link copied to clipboard
fun swapMoveToTile(destination: TileInfo)

Swaps this unit with the unit on the given tile Precondition: this unit can swap-move to the given tile, as determined by canUnitSwapTo

teleportToClosestMoveableTile
Link copied to clipboard
fun teleportToClosestMoveableTile()

Displace a unit - choose a viable tile close by if possible and 'teleport' the unit there. This will not use movement points or check for a possible route. It is used e.g. if an enemy city expands its borders, or trades or diplomacy change a unit's allowed position. CAN DESTROY THE UNIT.

toString
Link copied to clipboard
open fun toString(): String

Properties

unit
Link copied to clipboard
val unit: MapUnit

Sources

jvm source
Link copied to clipboard