mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 03:18:18 +07:00
performance: Don't update visible tiles if we've moved within our border
This commit is contained in:
parent
ad299a8a62
commit
f387de9506
@ -138,7 +138,7 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
||||
civInfo.viewableInvisibleUnitsTiles = newViewableInvisibleTiles
|
||||
}
|
||||
|
||||
private var ourTilesAndNeighboringTiles: Set<Tile> = HashSet()
|
||||
var ourTilesAndNeighboringTiles: Set<Tile> = HashSet()
|
||||
|
||||
/** Our tiles update pretty infrequently - most 'viewable tile' changes are due to unit movements,
|
||||
* which means we can store this separately and use it 'as is' so we don't need to find the neighboring tiles every time
|
||||
|
@ -307,7 +307,10 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
// Set equality automatically determines if anything changed - https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-abstract-set/equals.html
|
||||
if (updateCivViewableTiles && oldViewableTiles != viewableTiles)
|
||||
if (updateCivViewableTiles && oldViewableTiles != viewableTiles
|
||||
// Don't bother updating if all previous and current viewable tiles are within our borders
|
||||
&& (oldViewableTiles.any { it !in civ.cache.ourTilesAndNeighboringTiles }
|
||||
|| viewableTiles.any { it !in civ.cache.ourTilesAndNeighboringTiles }))
|
||||
civ.cache.updateViewableTiles(explorerPosition)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user