mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 21:35:14 -04:00
Rivers at the bottom edge of maps are considered by tiles for river-adjacency
This commit is contained in:
parent
0fbe5a18b8
commit
95b8fab950
@ -63,6 +63,8 @@ class UnitMovement(val unit: MapUnit) {
|
|||||||
// when entering territory of a city state
|
// when entering territory of a city state
|
||||||
val areConnectedByRoad = from.hasConnection(civInfo) && to.hasConnection(civInfo)
|
val areConnectedByRoad = from.hasConnection(civInfo) && to.hasConnection(civInfo)
|
||||||
|
|
||||||
|
// You might think "wait doesn't isAdjacentToRiver() call isConnectedByRiver() anyway, why have those checks?"
|
||||||
|
// The answer is that the isAdjacentToRiver values are CACHED per tile, but the isConnectedByRiver are not - this is an efficiency optimization
|
||||||
val areConnectedByRiver =
|
val areConnectedByRiver =
|
||||||
from.isAdjacentToRiver() && to.isAdjacentToRiver() && from.isConnectedByRiver(to)
|
from.isAdjacentToRiver() && to.isAdjacentToRiver() && from.isConnectedByRiver(to)
|
||||||
|
|
||||||
|
@ -673,7 +673,11 @@ open class Tile : IsPartOfGameInfoSerialization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@delegate:Transient
|
@delegate:Transient
|
||||||
private val isAdjacentToRiverLazy by lazy { neighbors.any { isConnectedByRiver(it) } }
|
private val isAdjacentToRiverLazy by lazy {
|
||||||
|
// These are so if you add a river at the bottom of the map (no neighboring tile to be connected to)
|
||||||
|
// that tile is still considered adjacent to river
|
||||||
|
hasBottomLeftRiver || hasBottomRiver || hasBottomRightRiver
|
||||||
|
|| neighbors.any { isConnectedByRiver(it) } }
|
||||||
fun isAdjacentToRiver() = isAdjacentToRiverLazy
|
fun isAdjacentToRiver() = isAdjacentToRiverLazy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user