Skip to content

Commit

Permalink
Actual performance change :)
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Nov 13, 2024
1 parent 1c17a20 commit 8e01152
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,19 @@ 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 })
return // All image identifiers are the same as the current ones, no need to change anything
}
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
Expand Down

0 comments on commit 8e01152

Please sign in to comment.