mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-08 23:08:35 +07:00
Avoid first contact alerts for dead City-States (#9269)
* Avoid first contact alerts for dead City-States * Clearer simpler (hopefully) updateOurTiles
This commit is contained in:
@ -143,19 +143,26 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
||||
/** 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
|
||||
* a unit moves */
|
||||
fun updateOurTiles(){
|
||||
val newOurTilesAndNeighboring = HashSet<Tile>()
|
||||
val ownedTiles = civInfo.cities.asSequence().flatMap { it.getTiles() }
|
||||
newOurTilesAndNeighboring.addAll(ownedTiles)
|
||||
val neighboringUnownedTiles = ownedTiles.flatMap { tile -> tile.neighbors.filter { it.getOwner() != civInfo } }
|
||||
newOurTilesAndNeighboring.addAll(neighboringUnownedTiles)
|
||||
ourTilesAndNeighboringTiles = newOurTilesAndNeighboring
|
||||
fun updateOurTiles() {
|
||||
ourTilesAndNeighboringTiles = civInfo.cities.asSequence()
|
||||
.flatMap { it.getTiles() } // our owned tiles, still distinct
|
||||
.flatMap { sequenceOf(it) + it.neighbors }
|
||||
// now we got a mix of owned, unowned and competitor-owned tiles, and **duplicates**
|
||||
// but Sequence.toSet is just as good at making them distinct as any other operation
|
||||
.toSet()
|
||||
|
||||
updateViewableTiles()
|
||||
updateCivResources()
|
||||
}
|
||||
|
||||
private fun setNewViewableTiles() {
|
||||
if (civInfo.isDefeated()) {
|
||||
// Avoid meeting dead city states when entering a tile owned by their former ally (#9245)
|
||||
// In that case ourTilesAndNeighboringTiles and getCivUnits will be empty, but the for
|
||||
// loop getKnownCivs/getAllyCiv would add tiles.
|
||||
civInfo.viewableTiles = emptySet()
|
||||
return
|
||||
}
|
||||
|
||||
// while spectating all map is visible
|
||||
if (civInfo.isSpectator() || DebugUtils.VISIBLE_MAP) {
|
||||
|
Reference in New Issue
Block a user