mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-22 17:24:24 +07:00
Revert "perf(tile-update): cache base data for tile rendering to only recompute when base data changes"
This reverts commit 16f0a9844c
.
This commit is contained in:
parent
62bae6b166
commit
c3c397aade
@ -14,7 +14,6 @@ import com.unciv.utils.DebugUtils
|
||||
class TileLayerCityButton(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, size) {
|
||||
|
||||
private var cityButton: CityButton? = null
|
||||
val tile = tileGroup.tile
|
||||
|
||||
init {
|
||||
touchable = Touchable.childrenOnly
|
||||
@ -22,18 +21,18 @@ class TileLayerCityButton(tileGroup: TileGroup, size: Float) : TileLayer(tileGro
|
||||
}
|
||||
|
||||
override fun act(delta: Float) {
|
||||
if (tile.isCityCenter())
|
||||
if (tileGroup.tile.isCityCenter())
|
||||
super.act(delta)
|
||||
}
|
||||
|
||||
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? {
|
||||
if (tile.isCityCenter())
|
||||
if (tileGroup.tile.isCityCenter())
|
||||
return super.hit(x, y, touchable)
|
||||
return null
|
||||
}
|
||||
|
||||
override fun draw(batch: Batch?, parentAlpha: Float) {
|
||||
if (tile.isCityCenter())
|
||||
if (tileGroup.tile.isCityCenter())
|
||||
super.draw(batch, parentAlpha)
|
||||
}
|
||||
|
||||
@ -48,7 +47,7 @@ class TileLayerCityButton(tileGroup: TileGroup, size: Float) : TileLayer(tileGro
|
||||
override fun doUpdate(viewingCiv: Civilization?, localUniqueCache: LocalUniqueCache) {
|
||||
if (tileGroup !is WorldTileGroup) return
|
||||
|
||||
val city = tile.getCity()
|
||||
val city = tile().getCity()
|
||||
|
||||
// There used to be a city here but it was razed
|
||||
if (city == null && cityButton != null) {
|
||||
@ -57,7 +56,7 @@ class TileLayerCityButton(tileGroup: TileGroup, size: Float) : TileLayer(tileGro
|
||||
}
|
||||
|
||||
if (viewingCiv == null) return
|
||||
if (city == null || !tile.isCityCenter()) return
|
||||
if (city == null || !tileGroup.tile.isCityCenter()) return
|
||||
|
||||
// Create (if not yet) and update city button
|
||||
if (cityButton == null) {
|
||||
|
@ -47,7 +47,6 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
return ImageGetter.imageExists(strings().getTile("$shownImprovement-Pillaged"))
|
||||
}
|
||||
|
||||
var previousTileImageLocationData: TileImageLocationData? = null
|
||||
private fun getTileBaseImageLocations(viewingCiv: Civilization?): List<String> {
|
||||
|
||||
val isForceVisible = tileGroup.isForceVisible
|
||||
@ -76,20 +75,6 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
}
|
||||
}
|
||||
|
||||
// Anything that, if changed, would change the terrain images - optimization to avoid unnecessary work
|
||||
val tileImageLocationData = TileImageLocationData(
|
||||
viewingCiv,
|
||||
isForceVisible,
|
||||
shownImprovement,
|
||||
shouldShowImprovement,
|
||||
shouldShowResource,
|
||||
tile.baseTerrain,
|
||||
tile.naturalWonder,
|
||||
tile.terrainFeatures,
|
||||
)
|
||||
if (previousTileImageLocationData == tileImageLocationData) return tileImageIdentifiers
|
||||
else previousTileImageLocationData = tileImageLocationData
|
||||
|
||||
val terrainImages = if (tile.naturalWonder != null)
|
||||
sequenceOf(tile.baseTerrain, tile.naturalWonder!!)
|
||||
else sequenceOf(tile.baseTerrain) + tile.terrainFeatures.asSequence()
|
||||
@ -103,8 +88,7 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
return when {
|
||||
strings().tileSetConfig.ruleVariants[allTogether] != null -> baseHexagon +
|
||||
strings().tileSetConfig.ruleVariants[allTogether]!!.map { strings().getTile(it) } + edgeImages
|
||||
ImageGetter.imageExists(allTogetherLocation) ->
|
||||
baseHexagon + allTogetherLocation + edgeImages
|
||||
ImageGetter.imageExists(allTogetherLocation) -> baseHexagon + allTogetherLocation + edgeImages
|
||||
tile.naturalWonder != null -> getNaturalWonderBackupImage(baseHexagon) + edgeImages
|
||||
else -> baseHexagon + getTerrainImageLocations(terrainImages) + edgeImages + getImprovementAndResourceImages(resourceAndImprovementSequence)
|
||||
}
|
||||
@ -137,21 +121,8 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
return@filter true
|
||||
}.map { it.fileName }
|
||||
}
|
||||
|
||||
data class TileImageLocationData(
|
||||
val viewingCiv: Civilization?,
|
||||
val isForceVisible: Boolean,
|
||||
val shownImprovement: String?,
|
||||
val shouldShowImprovement: Boolean,
|
||||
val shouldShowResource: Boolean,
|
||||
val baseTerrain: String,
|
||||
val naturalWonder: String?,
|
||||
val terrainFeatures: List<String>,
|
||||
|
||||
)
|
||||
|
||||
private fun updateTileImage(viewingCiv: Civilization?) {
|
||||
|
||||
val tileBaseImageLocations = getTileBaseImageLocations(viewingCiv)
|
||||
|
||||
if (tileBaseImageLocations.size == tileImageIdentifiers.size) {
|
||||
|
Loading…
Reference in New Issue
Block a user