mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-03 21:40:31 +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.exploredBy = exploredBy
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -208,8 +208,10 @@ class TileInfoImprovementFunctions(val tile: Tile) {
|
||||
val city = tile.owningCity
|
||||
if (city != null) {
|
||||
city.cityStats.update()
|
||||
city.civ.cache.updateCivResources()
|
||||
city.reassignPopulationDeferred()
|
||||
if (civToActivateBroaderEffects != null) {
|
||||
city.civ.cache.updateCivResources()
|
||||
city.reassignPopulationDeferred()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ class CityScreen(
|
||||
|
||||
private fun updateTileGroups() {
|
||||
val cityUniqueCache = LocalUniqueCache()
|
||||
fun isExistingImprovementValuable(tile: Tile, improvementToPlace: TileImprovement): Boolean {
|
||||
fun isExistingImprovementValuable(tile: Tile): Boolean {
|
||||
if (tile.improvement == null) return false
|
||||
val civInfo = city.civ
|
||||
|
||||
@ -226,7 +226,7 @@ class CityScreen(
|
||||
return when {
|
||||
tile.isMarkedForCreatesOneImprovement() -> Color.BROWN to 0.7f
|
||||
!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.turnsToImprovement > 0 -> Color.YELLOW to 0.6f
|
||||
else -> Color.GREEN to 0.5f
|
||||
|
Loading…
Reference in New Issue
Block a user