From 0c06237570f6f04abd454e94b0bb86ce5431ee7e Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 1 Apr 2021 22:36:27 +0300 Subject: [PATCH] ALL tile images now support era-specific images! But only if the base tile exists as well. --- core/src/com/unciv/ui/tilegroups/TileGroup.kt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 12054d3563..133107af0f 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -341,20 +341,29 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) for (image in tileBaseImages) image.remove() tileBaseImages.clear() - for (location in tileBaseImageLocations.reversed()) { // reversed because we send each one to back + for (baseLocation in tileBaseImageLocations.reversed()) { // reversed because we send each one to back // 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(location)) continue + if (!ImageGetter.imageExists(baseLocation)) continue + + var locationToCheck = baseLocation + if(tileInfo.owningCity!=null) { + val ownersEra = tileInfo.getOwner()!!.getEra() + val eraSpecificLocation = "$locationToCheck-$ownersEra" + if (ImageGetter.imageExists(eraSpecificLocation)) + locationToCheck = eraSpecificLocation + } + val existingImages = ArrayList() - existingImages.add(location) + existingImages.add(locationToCheck) var i = 2 while (true) { - val tileVariant = location + i + val tileVariant = locationToCheck + i if (ImageGetter.imageExists(tileVariant)) existingImages.add(tileVariant) else break i += 1 } - val finalLocation = existingImages.random(Random(tileInfo.position.hashCode() + location.hashCode())) + val finalLocation = existingImages.random(Random(tileInfo.position.hashCode() + locationToCheck.hashCode())) val image = ImageGetter.getImage(finalLocation) tileBaseImages.add(image)