Actual performance change :)

This commit is contained in:
yairm210 2024-11-13 12:16:00 +02:00
parent 1c17a20018
commit 8e0115263b

View File

@ -109,8 +109,7 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
}
private fun updateTileImage(viewingCiv: Civilization?) {
val tileBaseImageLocations = getTileBaseImageLocations(viewingCiv) +
getEdgeTileLocations()
val tileBaseImageLocations = getTileBaseImageLocations(viewingCiv)
if (tileBaseImageLocations.size == tileImageIdentifiers.size) {
if (tileBaseImageLocations.withIndex().all { (i, imageLocation) -> tileImageIdentifiers[i] == imageLocation })
@ -118,9 +117,11 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
}
tileImageIdentifiers = tileBaseImageLocations
val allImages = tileBaseImageLocations + getEdgeTileLocations()
for (image in tileBaseImages) image.remove()
tileBaseImages.clear()
for (baseLocation in tileBaseImageLocations) {
for (baseLocation in allImages) {
// Here we check what actual tiles exist, and pick one - not at random, but based on the tile location,
// so it stays consistent throughout the game
if (!ImageGetter.imageExists(baseLocation)) continue