mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-03 22:22:51 +07:00
Terrain-Specific Natural Wonder Sprite Support (#8568)
* Terrain specific natural wonder sprite support * Simplify expression and add translation * Merge sequenceOf()s * Revert * Merge sequenceOf()s * Remove unique type
This commit is contained in:
parent
f6d89678b5
commit
3147c39b40
@ -169,7 +169,8 @@ class NaturalWonderGenerator(val ruleset: Ruleset, val randomness: MapGeneration
|
||||
list.forEach {
|
||||
clearTile(it)
|
||||
it.naturalWonder = wonder.name
|
||||
it.baseTerrain = wonder.turnsInto!!
|
||||
if (wonder.turnsInto != null)
|
||||
it.baseTerrain = wonder.turnsInto!!
|
||||
// Add all tiles within a certain distance to a blacklist so NW:s don't cluster
|
||||
blockedTiles.addAll(it.getTilesInDistance(it.tileMap.mapParameters.mapSize.height / 5))
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class Terrain : RulesetStatsObject() {
|
||||
|
||||
val textList = ArrayList<FormattedLine>()
|
||||
|
||||
if (turnsInto != null) {
|
||||
if (type == TerrainType.NaturalWonder) {
|
||||
textList += FormattedLine("Natural Wonder", header=3, color="#3A0")
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ object CivilopediaImageGetters {
|
||||
when (terrain.type) {
|
||||
TerrainType.NaturalWonder -> {
|
||||
tile.naturalWonder = terrain.name
|
||||
tile.baseTerrain = terrain.turnsInto ?: Constants.grassland
|
||||
tile.baseTerrain = terrain.turnsInto ?: terrain.occursOn.firstOrNull() ?: Constants.grassland
|
||||
}
|
||||
TerrainType.TerrainFeature -> {
|
||||
tile.baseTerrain =
|
||||
|
@ -11,7 +11,8 @@ object TileInfoNormalizer {
|
||||
if (tile.naturalWonder != null && !ruleset.terrains.containsKey(tile.naturalWonder))
|
||||
tile.naturalWonder = null
|
||||
if (tile.naturalWonder != null) {
|
||||
tile.baseTerrain = tile.getNaturalWonder().turnsInto!!
|
||||
if (tile.getNaturalWonder().turnsInto != null)
|
||||
tile.baseTerrain = tile.getNaturalWonder().turnsInto!!
|
||||
tile.setTerrainFeatures(listOf())
|
||||
tile.resource = null
|
||||
tile.changeImprovement(null)
|
||||
|
@ -119,7 +119,8 @@ class MapEditorEditWondersTab(
|
||||
) {
|
||||
editTab.setBrush(it, "Terrain/$it") { tile ->
|
||||
// Normally the caller would ensure compliance, but here we make an exception - place it no matter what
|
||||
tile.baseTerrain = ruleset.terrains[it]!!.turnsInto!!
|
||||
if (ruleset.terrains[it]!!.turnsInto != null)
|
||||
tile.baseTerrain = ruleset.terrains[it]!!.turnsInto!!
|
||||
tile.removeTerrainFeatures()
|
||||
tile.naturalWonder = it
|
||||
}
|
||||
|
@ -49,10 +49,6 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
|
||||
val tile = tileGroup.tile
|
||||
|
||||
if (tile.naturalWonder != null)
|
||||
return if (strings().tileSetConfig.useSummaryImages) baseHexagon + strings().naturalWonder
|
||||
else baseHexagon + strings().orFallback{ getTile(tile.naturalWonder!!) }
|
||||
|
||||
val shownImprovement = tile.getShownImprovement(viewingCiv)
|
||||
val shouldShowImprovement = shownImprovement != null && UncivGame.Current.settings.showPixelImprovements
|
||||
|
||||
@ -64,13 +60,16 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
if (shouldShowImprovement) yield(shownImprovement!!)
|
||||
}
|
||||
|
||||
val terrainImages = sequenceOf(tile.baseTerrain) + tile.terrainFeatures.asSequence()
|
||||
val terrainImages = if (tile.naturalWonder != null)
|
||||
sequenceOf(tile.baseTerrain, tile.naturalWonder!!)
|
||||
else sequenceOf(tile.baseTerrain) + tile.terrainFeatures.asSequence()
|
||||
val allTogether = (terrainImages + resourceAndImprovementSequence).joinToString("+")
|
||||
val allTogetherLocation = strings().getTile(allTogether)
|
||||
|
||||
return when {
|
||||
strings().tileSetConfig.ruleVariants[allTogether] != null -> baseHexagon + strings().tileSetConfig.ruleVariants[allTogether]!!.map { strings().getTile(it) }
|
||||
ImageGetter.imageExists(allTogetherLocation) -> baseHexagon + allTogetherLocation
|
||||
tile.naturalWonder != null -> getNaturalWonderBackupImage(baseHexagon)
|
||||
else -> baseHexagon + getTerrainImageLocations(terrainImages) + getImprovementAndResourceImages(resourceAndImprovementSequence)
|
||||
}
|
||||
}
|
||||
@ -193,4 +192,8 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
updateRivers(displayBottomRight = false, displayBottom = false, displayBottomLeft = false)
|
||||
}
|
||||
|
||||
private fun getNaturalWonderBackupImage(baseHexagon: List<String>): List<String> =
|
||||
if (strings().tileSetConfig.useSummaryImages) baseHexagon + strings().naturalWonder
|
||||
else baseHexagon + strings().orFallback{ getTile(tileGroup.tile.naturalWonder!!) }
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user