mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
River adjacency and 'is land unit' saved in lazies for another pathfinding performance boost
This commit is contained in:
parent
8ee2a34a4d
commit
505a78182c
@ -663,7 +663,8 @@ open class TileInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fun isAdjacentToRiver() = neighbors.any { isConnectedByRiver(it) }
|
||||
private val isAdjacentToRiverLazy by lazy { neighbors.any { isConnectedByRiver(it) } }
|
||||
fun isAdjacentToRiver() = isAdjacentToRiverLazy
|
||||
|
||||
/**
|
||||
* @returns whether units of [civInfo] can pass through this tile, considering only civ-wide filters.
|
||||
|
@ -40,7 +40,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
||||
return RoadStatus.Railroad.movement + extraCost
|
||||
|
||||
val areConnectedByRoad = from.hasConnection(civInfo) && to.hasConnection(civInfo)
|
||||
val areConnectedByRiver = from.isConnectedByRiver(to)
|
||||
val areConnectedByRiver = from.isAdjacentToRiver() && to.isAdjacentToRiver() && from.isConnectedByRiver(to)
|
||||
|
||||
if (areConnectedByRoad && (!areConnectedByRiver || civInfo.tech.roadsConnectAcrossRivers))
|
||||
return unit.civInfo.tech.movementSpeedOnRoads + extraCost
|
||||
|
@ -577,7 +577,8 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
fun isMilitary() = isRanged() || isMelee()
|
||||
fun isCivilian() = !isMilitary()
|
||||
|
||||
fun isLandUnit() = getType().isLandUnit()
|
||||
val isLandUnitInternal by lazy { getType().isLandUnit() }
|
||||
fun isLandUnit() = isLandUnitInternal
|
||||
fun isWaterUnit() = getType().isWaterUnit()
|
||||
fun isAirUnit() = getType().isAirUnit()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user