mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-22 23:24:25 +07:00
perf: save tile ref on each tile layer
This commit is contained in:
parent
c3c397aade
commit
7bc5047ace
@ -18,9 +18,10 @@ abstract class TileLayer(val tileGroup: TileGroup, size: Float) : Group() {
|
|||||||
@Suppress("LeakingThis")
|
@Suppress("LeakingThis")
|
||||||
setSize(size, size)
|
setSize(size, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tile(): Tile = tileGroup.tile
|
// these should not change
|
||||||
fun strings(): TileSetStrings = tileGroup.tileSetStrings
|
val tile: Tile = tileGroup.tile
|
||||||
|
val strings: TileSetStrings = tileGroup.tileSetStrings
|
||||||
|
|
||||||
fun Image.setHexagonSize(scale: Float? = null): Image {
|
fun Image.setHexagonSize(scale: Float? = null): Image {
|
||||||
this.setSize(tileGroup.hexagonImageWidth, this.height*tileGroup.hexagonImageWidth/this.width)
|
this.setSize(tileGroup.hexagonImageWidth, this.height*tileGroup.hexagonImageWidth/this.width)
|
||||||
|
@ -128,7 +128,7 @@ class TileLayerBorders(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
val angle = sign * (atan(sign * relativeWorldPosition.y / relativeWorldPosition.x) * 180 / PI - 90.0).toFloat()
|
val angle = sign * (atan(sign * relativeWorldPosition.y / relativeWorldPosition.x) * 180 / PI - 90.0).toFloat()
|
||||||
|
|
||||||
val innerBorderImage = ImageGetter.getImage(
|
val innerBorderImage = ImageGetter.getImage(
|
||||||
strings().orFallback { getBorder(borderShapeString,"Inner") }
|
strings.orFallback { getBorder(borderShapeString,"Inner") }
|
||||||
).setHexagonSize()
|
).setHexagonSize()
|
||||||
|
|
||||||
addActor(innerBorderImage)
|
addActor(innerBorderImage)
|
||||||
@ -137,7 +137,7 @@ class TileLayerBorders(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
innerBorderImage.color = civOuterColor
|
innerBorderImage.color = civOuterColor
|
||||||
|
|
||||||
val outerBorderImage = ImageGetter.getImage(
|
val outerBorderImage = ImageGetter.getImage(
|
||||||
strings().orFallback { getBorder(borderShapeString, "Outer") }
|
strings.orFallback { getBorder(borderShapeString, "Outer") }
|
||||||
).setHexagonSize()
|
).setHexagonSize()
|
||||||
|
|
||||||
addActor(outerBorderImage)
|
addActor(outerBorderImage)
|
||||||
|
@ -47,7 +47,7 @@ class TileLayerCityButton(tileGroup: TileGroup, size: Float) : TileLayer(tileGro
|
|||||||
override fun doUpdate(viewingCiv: Civilization?, localUniqueCache: LocalUniqueCache) {
|
override fun doUpdate(viewingCiv: Civilization?, localUniqueCache: LocalUniqueCache) {
|
||||||
if (tileGroup !is WorldTileGroup) return
|
if (tileGroup !is WorldTileGroup) return
|
||||||
|
|
||||||
val city = tile().getCity()
|
val city = tile.getCity()
|
||||||
|
|
||||||
// There used to be a city here but it was razed
|
// There used to be a city here but it was razed
|
||||||
if (city == null && cityButton != null) {
|
if (city == null && cityButton != null) {
|
||||||
|
@ -51,7 +51,7 @@ class TileLayerFeatures(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup
|
|||||||
}
|
}
|
||||||
if (roadStatus == RoadStatus.None) continue // no road image
|
if (roadStatus == RoadStatus.None) continue // no road image
|
||||||
|
|
||||||
val image = ImageGetter.getImage(strings().orFallback { roadsMap[roadStatus]!! })
|
val image = ImageGetter.getImage(strings.orFallback { roadsMap[roadStatus]!! })
|
||||||
roadImage.image = image
|
roadImage.image = image
|
||||||
|
|
||||||
val relativeWorldPosition = tile.tileMap.getNeighborTilePositionAsWorldCoords(tile, neighbor)
|
val relativeWorldPosition = tile.tileMap.getNeighborTilePositionAsWorldCoords(tile, neighbor)
|
||||||
|
@ -50,7 +50,7 @@ private class MapArrow(val targetTile: Tile, val arrowType: MapArrowType, val st
|
|||||||
class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, size) {
|
class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, size) {
|
||||||
|
|
||||||
// For different unit views, we want to effectively "ignore" the terrain and color it by special view
|
// For different unit views, we want to effectively "ignore" the terrain and color it by special view
|
||||||
private var terrainOverlay: Image? = ImageGetter.getImage(strings().hexagon).setHexagonSize()
|
private var terrainOverlay: Image? = ImageGetter.getImage(strings.hexagon).setHexagonSize()
|
||||||
|
|
||||||
override fun act(delta: Float) {}
|
override fun act(delta: Float) {}
|
||||||
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? {
|
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? {
|
||||||
@ -108,11 +108,11 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
for (arrowToAdd in arrowsToDraw) {
|
for (arrowToAdd in arrowsToDraw) {
|
||||||
val targetTile = arrowToAdd.targetTile
|
val targetTile = arrowToAdd.targetTile
|
||||||
var targetPos = Vector2(targetTile.position)
|
var targetPos = Vector2(targetTile.position)
|
||||||
if (tile().tileMap.mapParameters.worldWrap)
|
if (tile.tileMap.mapParameters.worldWrap)
|
||||||
targetPos = HexMath.getUnwrappedNearestTo(targetPos,
|
targetPos = HexMath.getUnwrappedNearestTo(targetPos,
|
||||||
tile().position, tile().tileMap.maxLongitude)
|
tile.position, tile.tileMap.maxLongitude)
|
||||||
val targetRelative = HexMath.hex2WorldCoords(targetPos)
|
val targetRelative = HexMath.hex2WorldCoords(targetPos)
|
||||||
.sub(HexMath.hex2WorldCoords(tile().position))
|
.sub(HexMath.hex2WorldCoords(tile.position))
|
||||||
|
|
||||||
val targetDistance = sqrt(targetRelative.x.pow(2) + targetRelative.y.pow(2))
|
val targetDistance = sqrt(targetRelative.x.pow(2) + targetRelative.y.pow(2))
|
||||||
val targetAngle = atan2(targetRelative.y, targetRelative.x)
|
val targetAngle = atan2(targetRelative.y, targetRelative.x)
|
||||||
@ -139,9 +139,9 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
|
|
||||||
private fun updateImprovementIcon(viewingCiv: Civilization?, show: Boolean) {
|
private fun updateImprovementIcon(viewingCiv: Civilization?, show: Boolean) {
|
||||||
// If improvement has changed, force new icon next time it is needed
|
// If improvement has changed, force new icon next time it is needed
|
||||||
val improvementToShow = tile().getShownImprovement(viewingCiv)
|
val improvementToShow = tile.getShownImprovement(viewingCiv)
|
||||||
val newImprovementPlusPillagedID = if (improvementToShow==null) null
|
val newImprovementPlusPillagedID = if (improvementToShow==null) null
|
||||||
else if (tile().improvementIsPillaged) "$improvementToShow-Pillaged"
|
else if (tile.improvementIsPillaged) "$improvementToShow-Pillaged"
|
||||||
else improvementToShow
|
else improvementToShow
|
||||||
|
|
||||||
if (improvementPlusPillagedID != newImprovementPlusPillagedID) {
|
if (improvementPlusPillagedID != newImprovementPlusPillagedID) {
|
||||||
@ -152,7 +152,7 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
|
|
||||||
// Get new icon when needed
|
// Get new icon when needed
|
||||||
if (improvementPlusPillagedID != null && show && improvementIcon == null) {
|
if (improvementPlusPillagedID != null && show && improvementIcon == null) {
|
||||||
val icon = ImageGetter.getImprovementPortrait(improvementToShow!!, dim = false, isPillaged = tile().improvementIsPillaged)
|
val icon = ImageGetter.getImprovementPortrait(improvementToShow!!, dim = false, isPillaged = tile.improvementIsPillaged)
|
||||||
icon.center(tileGroup)
|
icon.center(tileGroup)
|
||||||
icon.x -= 22 // left
|
icon.x -= 22 // left
|
||||||
icon.y -= 12 // bottom
|
icon.y -= 12 // bottom
|
||||||
@ -168,14 +168,14 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
val effectiveVisible = when {
|
val effectiveVisible = when {
|
||||||
tileGroup.isForceVisible -> show
|
tileGroup.isForceVisible -> show
|
||||||
show && viewingCiv == null -> true
|
show && viewingCiv == null -> true
|
||||||
show && tile().hasViewableResource(viewingCiv!!) -> true
|
show && tile.hasViewableResource(viewingCiv!!) -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|
||||||
// If resource has changed (e.g. tech researched) - force new icon next time it's needed
|
// If resource has changed (e.g. tech researched) - force new icon next time it's needed
|
||||||
if (resourceName != tile().resource || resourceAmount != tile().resourceAmount) {
|
if (resourceName != tile.resource || resourceAmount != tile.resourceAmount) {
|
||||||
resourceName = tile().resource
|
resourceName = tile.resource
|
||||||
resourceAmount = tile().resourceAmount
|
resourceAmount = tile.resourceAmount
|
||||||
resourceIcon?.remove()
|
resourceIcon?.remove()
|
||||||
resourceIcon = null
|
resourceIcon = null
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
return
|
return
|
||||||
|
|
||||||
if (DebugUtils.SHOW_TILE_COORDS) {
|
if (DebugUtils.SHOW_TILE_COORDS) {
|
||||||
val label = this.tile().position.toPrettyString()
|
val label = this.tile.position.toPrettyString()
|
||||||
startingLocationIcons.add(label.toLabel(ImageGetter.CHARCOAL.cpy().apply { a = 0.7f }, 14).apply {
|
startingLocationIcons.add(label.toLabel(ImageGetter.CHARCOAL.cpy().apply { a = 0.7f }, 14).apply {
|
||||||
tileGroup.layerMisc.addActor(this)
|
tileGroup.layerMisc.addActor(this)
|
||||||
setOrigin(Align.center)
|
setOrigin(Align.center)
|
||||||
@ -228,7 +228,7 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
val tilemap = tile().tileMap
|
val tilemap = tile.tileMap
|
||||||
|
|
||||||
if (tilemap.startingLocationsByNation.isEmpty())
|
if (tilemap.startingLocationsByNation.isEmpty())
|
||||||
return
|
return
|
||||||
@ -237,7 +237,7 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
// Sorted so major get precedence and to make the display deterministic, otherwise you could get
|
// Sorted so major get precedence and to make the display deterministic, otherwise you could get
|
||||||
// different stacking order of the same nations in the same editing session
|
// different stacking order of the same nations in the same editing session
|
||||||
val nations = tilemap.startingLocationsByNation.asSequence()
|
val nations = tilemap.startingLocationsByNation.asSequence()
|
||||||
.filter { tile() in it.value }
|
.filter { tile in it.value }
|
||||||
.filter { it.key in tilemap.ruleset!!.nations } // Ignore missing nations
|
.filter { it.key in tilemap.ruleset!!.nations } // Ignore missing nations
|
||||||
.map { it.key to tilemap.ruleset!!.nations[it.key]!! }
|
.map { it.key to tilemap.ruleset!!.nations[it.key]!! }
|
||||||
.sortedWith(compareBy({ it.second.isCityState }, { it.first }))
|
.sortedWith(compareBy({ it.second.isCityState }, { it.first }))
|
||||||
@ -295,9 +295,9 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
if (effectiveVisible) yields.run {
|
if (effectiveVisible) yields.run {
|
||||||
// Update YieldGroup Icon
|
// Update YieldGroup Icon
|
||||||
if (tileGroup is CityTileGroup)
|
if (tileGroup is CityTileGroup)
|
||||||
setStats(tile().stats.getTileStats(tileGroup.city, viewingCiv, localUniqueCache))
|
setStats(tile.stats.getTileStats(tileGroup.city, viewingCiv, localUniqueCache))
|
||||||
else
|
else
|
||||||
setStats(tile().stats.getTileStats(viewingCiv, localUniqueCache))
|
setStats(tile.stats.getTileStats(viewingCiv, localUniqueCache))
|
||||||
toFront()
|
toFront()
|
||||||
centerX(tileGroup)
|
centerX(tileGroup)
|
||||||
isVisible = true
|
isVisible = true
|
||||||
@ -339,7 +339,7 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
|
|
||||||
private fun overlayTerrainInner(color: Color) {
|
private fun overlayTerrainInner(color: Color) {
|
||||||
if (terrainOverlay == null){
|
if (terrainOverlay == null){
|
||||||
terrainOverlay = ImageGetter.getImage(strings().hexagon).setHexagonSize()
|
terrainOverlay = ImageGetter.getImage(strings.hexagon).setHexagonSize()
|
||||||
addActor(terrainOverlay)
|
addActor(terrainOverlay)
|
||||||
}
|
}
|
||||||
terrainOverlay?.color = color
|
terrainOverlay?.color = color
|
||||||
@ -354,8 +354,8 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
|||||||
|
|
||||||
|
|
||||||
fun addArrow(targetTile: Tile, type: MapArrowType) {
|
fun addArrow(targetTile: Tile, type: MapArrowType) {
|
||||||
if (targetTile.position != tile().position)
|
if (targetTile.position != tile.position)
|
||||||
arrowsToDraw.add(MapArrow(targetTile, type, strings()))
|
arrowsToDraw.add(MapArrow(targetTile, type, strings))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetArrows() {
|
fun resetArrows() {
|
||||||
|
@ -22,13 +22,13 @@ class TileLayerOverlay(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
private var fog: Image? = null
|
private var fog: Image? = null
|
||||||
private var unexplored: Image? = null
|
private var unexplored: Image? = null
|
||||||
|
|
||||||
private fun getHighlight() = ImageGetter.getImage(strings().highlight).setHexagonSize() // for blue and red circles/emphasis on the tile
|
private fun getHighlight() = ImageGetter.getImage(strings.highlight).setHexagonSize() // for blue and red circles/emphasis on the tile
|
||||||
private fun getCrosshair() = ImageGetter.getImage(strings().crosshair).setHexagonSize() // for when a unit is targeted
|
private fun getCrosshair() = ImageGetter.getImage(strings.crosshair).setHexagonSize() // for when a unit is targeted
|
||||||
private fun getGoodCityLocationIndicator() = ImageGetter.getImage("OtherIcons/Cities").setHexagonSize(0.25f)
|
private fun getGoodCityLocationIndicator() = ImageGetter.getImage("OtherIcons/Cities").setHexagonSize(0.25f)
|
||||||
private fun getFog() = ImageGetter.getImage(strings().crosshatchHexagon ).setHexagonSize().apply {
|
private fun getFog() = ImageGetter.getImage(strings.crosshatchHexagon ).setHexagonSize().apply {
|
||||||
color = Color.WHITE.cpy().apply { a = 0.2f }
|
color = Color.WHITE.cpy().apply { a = 0.2f }
|
||||||
}
|
}
|
||||||
private fun getUnexplored() = ImageGetter.getImage(strings().unexploredTile ).setHexagonSize()
|
private fun getUnexplored() = ImageGetter.getImage(strings.unexploredTile ).setHexagonSize()
|
||||||
|
|
||||||
fun orderToFront() {
|
fun orderToFront() {
|
||||||
unexplored?.toFront()
|
unexplored?.toFront()
|
||||||
@ -100,19 +100,19 @@ class TileLayerOverlay(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
|
|
||||||
setUnexplored(viewingCiv)
|
setUnexplored(viewingCiv)
|
||||||
|
|
||||||
if (tile().getShownImprovement(viewingCiv) == Constants.barbarianEncampment
|
if (tile.getShownImprovement(viewingCiv) == Constants.barbarianEncampment
|
||||||
&& tile().isExplored(viewingCiv))
|
&& tile.isExplored(viewingCiv))
|
||||||
showHighlight(Color.RED)
|
showHighlight(Color.RED)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUnexplored(viewingCiv: Civilization) {
|
private fun setUnexplored(viewingCiv: Civilization) {
|
||||||
val unexploredShouldBeVisible = !viewingCiv.hasExplored(tile())
|
val unexploredShouldBeVisible = !viewingCiv.hasExplored(tile)
|
||||||
val unexploredIsVisible = unexplored != null
|
val unexploredIsVisible = unexplored != null
|
||||||
if (unexploredIsVisible && !unexploredShouldBeVisible) {
|
if (unexploredIsVisible && !unexploredShouldBeVisible) {
|
||||||
unexplored?.remove()
|
unexplored?.remove()
|
||||||
determineVisibility()
|
determineVisibility()
|
||||||
} else if (!unexploredIsVisible && unexploredShouldBeVisible
|
} else if (!unexploredIsVisible && unexploredShouldBeVisible
|
||||||
&& ImageGetter.imageExists(strings().unexploredTile)) {
|
&& ImageGetter.imageExists(strings.unexploredTile)) {
|
||||||
unexplored = getUnexplored()
|
unexplored = getUnexplored()
|
||||||
addActor(unexplored)
|
addActor(unexplored)
|
||||||
determineVisibility()
|
determineVisibility()
|
||||||
|
@ -28,23 +28,23 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
|
|
||||||
private fun getTerrainImageLocations(terrainSequence: Sequence<String>): List<String> {
|
private fun getTerrainImageLocations(terrainSequence: Sequence<String>): List<String> {
|
||||||
val allTerrains = terrainSequence.joinToString("+")
|
val allTerrains = terrainSequence.joinToString("+")
|
||||||
if (strings().tileSetConfig.ruleVariants.containsKey(allTerrains))
|
if (strings.tileSetConfig.ruleVariants.containsKey(allTerrains))
|
||||||
return strings().tileSetConfig.ruleVariants[allTerrains]!!.map { strings().getTile(it) }
|
return strings.tileSetConfig.ruleVariants[allTerrains]!!.map { strings.getTile(it) }
|
||||||
val allTerrainTile = strings().getTile(allTerrains)
|
val allTerrainTile = strings.getTile(allTerrains)
|
||||||
return if (ImageGetter.imageExists(allTerrainTile)) listOf(allTerrainTile)
|
return if (ImageGetter.imageExists(allTerrainTile)) listOf(allTerrainTile)
|
||||||
else terrainSequence.map { strings().orFallback { getTile(it) } }.toList()
|
else terrainSequence.map { strings.orFallback { getTile(it) } }.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getImprovementAndResourceImages(resourceAndImprovementSequence: Sequence<String>): List<String> {
|
private fun getImprovementAndResourceImages(resourceAndImprovementSequence: Sequence<String>): List<String> {
|
||||||
val altogether = resourceAndImprovementSequence.joinToString("+").let { strings().getTile(it) }
|
val altogether = resourceAndImprovementSequence.joinToString("+").let { strings.getTile(it) }
|
||||||
return if (ImageGetter.imageExists(altogether)) listOf(altogether)
|
return if (ImageGetter.imageExists(altogether)) listOf(altogether)
|
||||||
else resourceAndImprovementSequence.map { strings().orFallback { getTile(it) } }.toList()
|
else resourceAndImprovementSequence.map { strings.orFallback { getTile(it) } }.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun usePillagedImprovementImage(tile: Tile, viewingCiv: Civilization?): Boolean {
|
private fun usePillagedImprovementImage(tile: Tile, viewingCiv: Civilization?): Boolean {
|
||||||
if (!tile.improvementIsPillaged || !UncivGame.Current.settings.showPixelImprovements) return false
|
if (!tile.improvementIsPillaged || !UncivGame.Current.settings.showPixelImprovements) return false
|
||||||
val shownImprovement = tile.getShownImprovement(viewingCiv) ?: return false
|
val shownImprovement = tile.getShownImprovement(viewingCiv) ?: return false
|
||||||
return ImageGetter.imageExists(strings().getTile("$shownImprovement-Pillaged"))
|
return ImageGetter.imageExists(strings.getTile("$shownImprovement-Pillaged"))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTileBaseImageLocations(viewingCiv: Civilization?): List<String> {
|
private fun getTileBaseImageLocations(viewingCiv: Civilization?): List<String> {
|
||||||
@ -52,10 +52,10 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
val isForceVisible = tileGroup.isForceVisible
|
val isForceVisible = tileGroup.isForceVisible
|
||||||
|
|
||||||
if (viewingCiv == null && !isForceVisible)
|
if (viewingCiv == null && !isForceVisible)
|
||||||
return strings().hexagonList
|
return strings.hexagonList
|
||||||
|
|
||||||
val baseHexagon = if (strings().tileSetConfig.useColorAsBaseTerrain)
|
val baseHexagon = if (strings.tileSetConfig.useColorAsBaseTerrain)
|
||||||
listOf(strings().hexagon)
|
listOf(strings.hexagon)
|
||||||
else emptyList()
|
else emptyList()
|
||||||
|
|
||||||
val tile = tileGroup.tile
|
val tile = tileGroup.tile
|
||||||
@ -80,14 +80,14 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
else sequenceOf(tile.baseTerrain) + tile.terrainFeatures.asSequence()
|
else sequenceOf(tile.baseTerrain) + tile.terrainFeatures.asSequence()
|
||||||
val edgeImages = getEdgeTileLocations()
|
val edgeImages = getEdgeTileLocations()
|
||||||
val allTogether = (terrainImages + resourceAndImprovementSequence).joinToString("+")
|
val allTogether = (terrainImages + resourceAndImprovementSequence).joinToString("+")
|
||||||
val allTogetherLocation = strings().getTile(allTogether)
|
val allTogetherLocation = strings.getTile(allTogether)
|
||||||
|
|
||||||
// If the tilesetconfig *explicitly* lists the terrains+improvements etc, we can't know where in that list to place the edges
|
// If the tilesetconfig *explicitly* lists the terrains+improvements etc, we can't know where in that list to place the edges
|
||||||
// So we default to placing them over everything else.
|
// So we default to placing them over everything else.
|
||||||
// If there is no explicit list, then we can know to place them between the terrain and the improvement
|
// If there is no explicit list, then we can know to place them between the terrain and the improvement
|
||||||
return when {
|
return when {
|
||||||
strings().tileSetConfig.ruleVariants[allTogether] != null -> baseHexagon +
|
strings.tileSetConfig.ruleVariants[allTogether] != null -> baseHexagon +
|
||||||
strings().tileSetConfig.ruleVariants[allTogether]!!.map { strings().getTile(it) } + edgeImages
|
strings.tileSetConfig.ruleVariants[allTogether]!!.map { strings.getTile(it) } + edgeImages
|
||||||
ImageGetter.imageExists(allTogetherLocation) -> baseHexagon + allTogetherLocation + edgeImages
|
ImageGetter.imageExists(allTogetherLocation) -> baseHexagon + allTogetherLocation + edgeImages
|
||||||
tile.naturalWonder != null -> getNaturalWonderBackupImage(baseHexagon) + edgeImages
|
tile.naturalWonder != null -> getNaturalWonderBackupImage(baseHexagon) + edgeImages
|
||||||
else -> baseHexagon + getTerrainImageLocations(terrainImages) + edgeImages + getImprovementAndResourceImages(resourceAndImprovementSequence)
|
else -> baseHexagon + getTerrainImageLocations(terrainImages) + edgeImages + getImprovementAndResourceImages(resourceAndImprovementSequence)
|
||||||
@ -95,7 +95,6 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getEdgeTileLocations(): Sequence<String> {
|
private fun getEdgeTileLocations(): Sequence<String> {
|
||||||
val tile = tile()
|
|
||||||
if (!tile.isTilemapInitialized()) // fake tile
|
if (!tile.isTilemapInitialized()) // fake tile
|
||||||
return emptySequence()
|
return emptySequence()
|
||||||
return tile.neighbors
|
return tile.neighbors
|
||||||
@ -106,7 +105,7 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
val vectorToNeighbor = neighborTile.position.cpy().sub(originTile.position)
|
val vectorToNeighbor = neighborTile.position.cpy().sub(originTile.position)
|
||||||
val direction = NeighborDirection.fromVector(vectorToNeighbor)
|
val direction = NeighborDirection.fromVector(vectorToNeighbor)
|
||||||
?: return emptySequence()
|
?: return emptySequence()
|
||||||
val possibleEdgeFiles = strings().edgeImagesByPosition[direction] ?: return emptySequence()
|
val possibleEdgeFiles = strings.edgeImagesByPosition[direction] ?: return emptySequence()
|
||||||
|
|
||||||
// Required for performance - full matchesFilter is too expensive for something that needs to run every update()
|
// Required for performance - full matchesFilter is too expensive for something that needs to run every update()
|
||||||
fun matchesFilterMinimal(originTile: Tile, filter: String): Boolean {
|
fun matchesFilterMinimal(originTile: Tile, filter: String): Boolean {
|
||||||
@ -140,7 +139,7 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
|
|
||||||
val locationToCheck =
|
val locationToCheck =
|
||||||
if (tileGroup.tile.owningCity != null)
|
if (tileGroup.tile.owningCity != null)
|
||||||
strings().getOwnedTileImageLocation(baseLocation, tileGroup.tile.getOwner()!!)
|
strings.getOwnedTileImageLocation(baseLocation, tileGroup.tile.getOwner()!!)
|
||||||
else baseLocation
|
else baseLocation
|
||||||
|
|
||||||
val existingImages = ArrayList<String>()
|
val existingImages = ArrayList<String>()
|
||||||
@ -160,8 +159,8 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
tileBaseImages.add(image)
|
tileBaseImages.add(image)
|
||||||
addActor(image)
|
addActor(image)
|
||||||
|
|
||||||
if (strings().tileSetConfig.tileScales.isNotEmpty()) {
|
if (strings.tileSetConfig.tileScales.isNotEmpty()) {
|
||||||
val scale = strings().tileSetConfig.tileScales[baseLocation.takeLastWhile { it != '/' }]
|
val scale = strings.tileSetConfig.tileScales[baseLocation.takeLastWhile { it != '/' }]
|
||||||
image.setHexagonSize(scale)
|
image.setHexagonSize(scale)
|
||||||
} else {
|
} else {
|
||||||
image.setHexagonSize()
|
image.setHexagonSize()
|
||||||
@ -175,21 +174,21 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
val colorPillagedTile = isViewable && tile.isPillaged() && !usePillagedImprovementImage(tile, viewingCiv)
|
val colorPillagedTile = isViewable && tile.isPillaged() && !usePillagedImprovementImage(tile, viewingCiv)
|
||||||
|
|
||||||
val baseTerrainColor = when {
|
val baseTerrainColor = when {
|
||||||
colorPillagedTile && strings().tileSetConfig.useColorAsBaseTerrain -> tile.getBaseTerrain()
|
colorPillagedTile && strings.tileSetConfig.useColorAsBaseTerrain -> tile.getBaseTerrain()
|
||||||
.getColor().lerp(Color.BROWN, 0.6f)
|
.getColor().lerp(Color.BROWN, 0.6f)
|
||||||
colorPillagedTile -> Color.WHITE.cpy().lerp(Color.BROWN, 0.6f)
|
colorPillagedTile -> Color.WHITE.cpy().lerp(Color.BROWN, 0.6f)
|
||||||
strings().tileSetConfig.useColorAsBaseTerrain && !isViewable -> tile.getBaseTerrain()
|
strings.tileSetConfig.useColorAsBaseTerrain && !isViewable -> tile.getBaseTerrain()
|
||||||
.getColor().lerp(strings().tileSetConfig.fogOfWarColor, 0.6f)
|
.getColor().lerp(strings.tileSetConfig.fogOfWarColor, 0.6f)
|
||||||
strings().tileSetConfig.useColorAsBaseTerrain -> tile.getBaseTerrain()
|
strings.tileSetConfig.useColorAsBaseTerrain -> tile.getBaseTerrain()
|
||||||
.getColor()
|
.getColor()
|
||||||
!isViewable -> Color.WHITE.cpy().lerp(strings().tileSetConfig.fogOfWarColor, 0.6f)
|
!isViewable -> Color.WHITE.cpy().lerp(strings.tileSetConfig.fogOfWarColor, 0.6f)
|
||||||
else -> Color.WHITE.cpy()
|
else -> Color.WHITE.cpy()
|
||||||
}
|
}
|
||||||
|
|
||||||
val color = when {
|
val color = when {
|
||||||
colorPillagedTile -> Color.WHITE.cpy().lerp(Color.RED.cpy(), 0.5f)
|
colorPillagedTile -> Color.WHITE.cpy().lerp(Color.RED.cpy(), 0.5f)
|
||||||
!isViewable -> Color.WHITE.cpy()
|
!isViewable -> Color.WHITE.cpy()
|
||||||
.lerp(strings().tileSetConfig.fogOfWarColor, 0.6f)
|
.lerp(strings.tileSetConfig.fogOfWarColor, 0.6f)
|
||||||
else -> Color.WHITE.cpy()
|
else -> Color.WHITE.cpy()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,9 +197,9 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateRivers(displayBottomRight: Boolean, displayBottom: Boolean, displayBottomLeft: Boolean) {
|
private fun updateRivers(displayBottomRight: Boolean, displayBottom: Boolean, displayBottomLeft: Boolean) {
|
||||||
bottomRightRiverImage = updateRiver(bottomRightRiverImage,displayBottomRight, strings().bottomRightRiver)
|
bottomRightRiverImage = updateRiver(bottomRightRiverImage,displayBottomRight, strings.bottomRightRiver)
|
||||||
bottomRiverImage = updateRiver(bottomRiverImage, displayBottom, strings().bottomRiver)
|
bottomRiverImage = updateRiver(bottomRiverImage, displayBottom, strings.bottomRiver)
|
||||||
bottomLeftRiverImage = updateRiver(bottomLeftRiverImage, displayBottomLeft, strings().bottomLeftRiver)
|
bottomLeftRiverImage = updateRiver(bottomLeftRiverImage, displayBottomLeft, strings.bottomLeftRiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateRiver(currentImage: Image?, shouldDisplay: Boolean, imageName: String): Image? {
|
private fun updateRiver(currentImage: Image?, shouldDisplay: Boolean, imageName: String): Image? {
|
||||||
@ -244,8 +243,8 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getNaturalWonderBackupImage(baseHexagon: List<String>): List<String> =
|
private fun getNaturalWonderBackupImage(baseHexagon: List<String>): List<String> =
|
||||||
if (strings().tileSetConfig.useSummaryImages) baseHexagon + strings().naturalWonder
|
if (strings.tileSetConfig.useSummaryImages) baseHexagon + strings.naturalWonder
|
||||||
else baseHexagon + strings().orFallback{ getTile(tileGroup.tile.naturalWonder!!) }
|
else baseHexagon + strings.orFallback{ getTile(tileGroup.tile.naturalWonder!!) }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ class TileLayerUnitFlag(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup
|
|||||||
fillSlots(viewingCiv)
|
fillSlots(viewingCiv)
|
||||||
|
|
||||||
if (viewingCiv != null) {
|
if (viewingCiv != null) {
|
||||||
val unitsInTile = tile().getUnits()
|
val unitsInTile = tile.getUnits()
|
||||||
val shouldBeHighlighted = unitsInTile.any()
|
val shouldBeHighlighted = unitsInTile.any()
|
||||||
&& unitsInTile.first().civ.isAtWarWith(viewingCiv)
|
&& unitsInTile.first().civ.isAtWarWith(viewingCiv)
|
||||||
&& isViewable(viewingCiv)
|
&& isViewable(viewingCiv)
|
||||||
|
@ -41,7 +41,7 @@ class TileLayerUnitSprite(tileGroup: TileGroup, size: Float) : TileLayer(tileGro
|
|||||||
var nationName = ""
|
var nationName = ""
|
||||||
|
|
||||||
if (unit != null && isShown && UncivGame.Current.settings.showPixelUnits) {
|
if (unit != null && isShown && UncivGame.Current.settings.showPixelUnits) {
|
||||||
location = strings().getUnitImageLocation(unit)
|
location = strings.getUnitImageLocation(unit)
|
||||||
nationName = "${unit.civ.civName}-"
|
nationName = "${unit.civ.civName}-"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user