mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-29 06:09:24 +07:00
Performance boost for GameInfo.setTransients - speeds up loadGame and nextTurn
This commit is contained in:
@ -417,7 +417,8 @@ class GameInfo {
|
||||
|
||||
for (civInfo in civilizations) {
|
||||
for (unit in civInfo.getCivUnits())
|
||||
unit.updateVisibleTiles() // this needs to be done after all the units are assigned to their civs and all other transients are set
|
||||
unit.updateVisibleTiles(false) // this needs to be done after all the units are assigned to their civs and all other transients are set
|
||||
civInfo.updateViewableTiles() // only run ONCE and not for each unit - this is a huge performance saver!
|
||||
|
||||
// Since this depends on the cities of ALL civilizations,
|
||||
// we need to wait until we've set the transients of all the cities before we can run this.
|
||||
|
@ -500,7 +500,6 @@ class CityStats(val cityInfo: CityInfo) {
|
||||
statPercentBonusTree = newStatsBonusTree
|
||||
}
|
||||
|
||||
/** Does not update tile stats - instead, updating tile stats updates this */
|
||||
fun update(currentConstruction: IConstruction = cityInfo.cityConstructions.getCurrentConstruction(),
|
||||
updateTileStats:Boolean = true) {
|
||||
if (updateTileStats) updateTileStats()
|
||||
|
@ -402,7 +402,7 @@ class MapUnit {
|
||||
/**
|
||||
* Update this unit's cache of viewable tiles and its civ's as well.
|
||||
*/
|
||||
fun updateVisibleTiles() {
|
||||
fun updateVisibleTiles(updateCivViewableTiles:Boolean = true) {
|
||||
if (baseUnit.isAirUnit()) {
|
||||
viewableTiles = if (hasUnique(UniqueType.SixTilesAlwaysVisible))
|
||||
getTile().getTilesInDistance(6).toList() // it's that simple
|
||||
@ -411,7 +411,7 @@ class MapUnit {
|
||||
return
|
||||
}
|
||||
viewableTiles = getTile().getViewableTilesList(getVisibilityRange())
|
||||
civInfo.updateViewableTiles() // for the civ
|
||||
if (updateCivViewableTiles) civInfo.updateViewableTiles() // for the civ
|
||||
}
|
||||
|
||||
fun isActionUntilHealed() = action?.endsWith("until healed") == true
|
||||
|
Reference in New Issue
Block a user