mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 10:18:26 +07:00
Changed unitHeight and tileHeight from by lazy to transient vars, to allow updates in preparation for base terrain changes
This commit is contained in:
@ -80,6 +80,12 @@ open class Tile : IsPartOfGameInfoSerialization {
|
|||||||
@Transient
|
@Transient
|
||||||
var isOcean = false
|
var isOcean = false
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
var unitHeight = 0
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
var tileHeight = 0
|
||||||
|
|
||||||
var militaryUnit: MapUnit? = null
|
var militaryUnit: MapUnit? = null
|
||||||
var civilianUnit: MapUnit? = null
|
var civilianUnit: MapUnit? = null
|
||||||
var airUnits = ArrayList<MapUnit>()
|
var airUnits = ArrayList<MapUnit>()
|
||||||
@ -348,19 +354,6 @@ open class Tile : IsPartOfGameInfoSerialization {
|
|||||||
fun getRow() = HexMath.getRow(position)
|
fun getRow() = HexMath.getRow(position)
|
||||||
fun getColumn() = HexMath.getColumn(position)
|
fun getColumn() = HexMath.getColumn(position)
|
||||||
|
|
||||||
@delegate:Transient
|
|
||||||
val tileHeight : Int by lazy { // for e.g. hill+forest this is 2, since forest is visible above units
|
|
||||||
if (terrainHasUnique(UniqueType.BlocksLineOfSightAtSameElevation)) unitHeight + 1
|
|
||||||
else unitHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
@delegate:Transient
|
|
||||||
val unitHeight : Int by lazy { // for e.g. hill+forest this is 1, since only hill provides height for units
|
|
||||||
allTerrains.flatMap { it.getMatchingUniques(UniqueType.VisibilityElevation) }
|
|
||||||
.map { it.params[0].toInt() }.sum()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun getBaseTerrain(): Terrain = baseTerrainObject
|
fun getBaseTerrain(): Terrain = baseTerrainObject
|
||||||
|
|
||||||
fun getOwner(): Civilization? = getCity()?.civ
|
fun getOwner(): Civilization? = getCity()?.civ
|
||||||
@ -821,6 +814,11 @@ open class Tile : IsPartOfGameInfoSerialization {
|
|||||||
naturalWonder != null -> getNaturalWonder()
|
naturalWonder != null -> getNaturalWonder()
|
||||||
else -> getBaseTerrain()
|
else -> getBaseTerrain()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unitHeight = allTerrains.flatMap { it.getMatchingUniques(UniqueType.VisibilityElevation) }
|
||||||
|
.map { it.params[0].toInt() }.sum()
|
||||||
|
tileHeight = if (terrainHasUnique(UniqueType.BlocksLineOfSightAtSameElevation)) unitHeight + 1
|
||||||
|
else unitHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUniqueMap() {
|
private fun updateUniqueMap() {
|
||||||
|
Reference in New Issue
Block a user