mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-05 21:11:35 +07:00
Performance - copy resourceCache, and don't reassign population and update civ resources, when checking improvement stat diff
This commit is contained in:
parent
bf687f2f0f
commit
41fa29f50c
@ -179,6 +179,8 @@ open class Tile : IsPartOfGameInfoSerialization {
|
|||||||
toReturn.continent = continent
|
toReturn.continent = continent
|
||||||
toReturn.exploredBy = exploredBy
|
toReturn.exploredBy = exploredBy
|
||||||
toReturn.history = history.clone()
|
toReturn.history = history.clone()
|
||||||
|
// Setting even though it's transient - where it's needed, it's a real performance saver
|
||||||
|
toReturn.tileResourceCache = tileResourceCache
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,8 +208,10 @@ class TileInfoImprovementFunctions(val tile: Tile) {
|
|||||||
val city = tile.owningCity
|
val city = tile.owningCity
|
||||||
if (city != null) {
|
if (city != null) {
|
||||||
city.cityStats.update()
|
city.cityStats.update()
|
||||||
city.civ.cache.updateCivResources()
|
if (civToActivateBroaderEffects != null) {
|
||||||
city.reassignPopulationDeferred()
|
city.civ.cache.updateCivResources()
|
||||||
|
city.reassignPopulationDeferred()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ class CityScreen(
|
|||||||
|
|
||||||
private fun updateTileGroups() {
|
private fun updateTileGroups() {
|
||||||
val cityUniqueCache = LocalUniqueCache()
|
val cityUniqueCache = LocalUniqueCache()
|
||||||
fun isExistingImprovementValuable(tile: Tile, improvementToPlace: TileImprovement): Boolean {
|
fun isExistingImprovementValuable(tile: Tile): Boolean {
|
||||||
if (tile.improvement == null) return false
|
if (tile.improvement == null) return false
|
||||||
val civInfo = city.civ
|
val civInfo = city.civ
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ class CityScreen(
|
|||||||
return when {
|
return when {
|
||||||
tile.isMarkedForCreatesOneImprovement() -> Color.BROWN to 0.7f
|
tile.isMarkedForCreatesOneImprovement() -> Color.BROWN to 0.7f
|
||||||
!tile.improvementFunctions.canBuildImprovement(improvementToPlace, city.civ) -> Color.RED to 0.4f
|
!tile.improvementFunctions.canBuildImprovement(improvementToPlace, city.civ) -> Color.RED to 0.4f
|
||||||
isExistingImprovementValuable(tile, improvementToPlace) -> Color.ORANGE to 0.5f
|
isExistingImprovementValuable(tile) -> Color.ORANGE to 0.5f
|
||||||
tile.improvement != null -> Color.YELLOW to 0.6f
|
tile.improvement != null -> Color.YELLOW to 0.6f
|
||||||
tile.turnsToImprovement > 0 -> Color.YELLOW to 0.6f
|
tile.turnsToImprovement > 0 -> Color.YELLOW to 0.6f
|
||||||
else -> Color.GREEN to 0.5f
|
else -> Color.GREEN to 0.5f
|
||||||
|
Loading…
Reference in New Issue
Block a user