diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index a1590abd13..ff9380e700 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -699,8 +699,8 @@ open class TileGroup( val specificUnitIconLocation = this.unitsLocation + militaryUnit.name return ImageAttempter(militaryUnit) .forceImage { if (!UncivGame.Current.settings.showPixelUnits) "" else null } - .tryImage { if (civInfo.nation.style.isEmpty()) specificUnitIconLocation else null } - .tryImage { "$specificUnitIconLocation-${civInfo.nation.style}" } + .tryGetUnitEraSprite(militaryUnit, specificUnitIconLocation) + .tryImage { if (civInfo.nation.style.isNotEmpty()) "$specificUnitIconLocation-${civInfo.nation.style}" else null } .tryImage { specificUnitIconLocation } .tryImage { if (baseUnit.replaces != null) "$unitsLocation${baseUnit.replaces}" else null } .tryImages( @@ -744,6 +744,7 @@ open class TileGroup( val specificUnitIconLocation = this.unitsLocation + civilianUnit.name return ImageAttempter(civilianUnit) .forceImage { if (!UncivGame.Current.settings.showPixelUnits) "" else null } + .tryGetUnitEraSprite(civilianUnit, specificUnitIconLocation) .tryImage { if (civInfo.nation.style.isNotEmpty()) "$specificUnitIconLocation-${civInfo.nation.style}" else null } .tryImage { specificUnitIconLocation } .tryImage { civilianLandUnit } @@ -767,6 +768,20 @@ open class TileGroup( } } + private fun ImageAttempter.tryGetUnitEraSprite(unit: MapUnit, specificUnitIconLocation: String): ImageAttempter { + return this.tryImages( + // iterate in reverse order to get the most recent era-specific image + (unit.civInfo.getEraNumber() downTo 0).asSequence().map { + { + val era = civInfo.gameInfo.ruleSet.eras.keys.elementAt(it) + if (civInfo.nation.style.isNotEmpty()) + "$specificUnitIconLocation-${civInfo.nation.style}-$era" + else + "$specificUnitIconLocation-$era" + } + } + ) + } private var bottomRightRiverImage :Image?=null private var bottomRiverImage :Image?=null