mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-25 22:59:12 +07:00
More sequencing for faster unique filtering
This commit is contained in:
parent
f85bedeb2f
commit
7039b6a287
@ -569,10 +569,8 @@ class CityInfo {
|
||||
|
||||
// Matching uniques provided by sources in the city itself
|
||||
fun getLocalMatchingUniques(placeholderText: String): Sequence<Unique> {
|
||||
return (
|
||||
cityConstructions.builtBuildingUniqueMap.getUniques(placeholderText) +
|
||||
religion.getMatchingUniques(placeholderText)
|
||||
).asSequence()
|
||||
return cityConstructions.builtBuildingUniqueMap.getUniques(placeholderText) +
|
||||
religion.getMatchingUniques(placeholderText)
|
||||
}
|
||||
|
||||
// Get all uniques that originate from this city
|
||||
@ -582,7 +580,7 @@ class CityInfo {
|
||||
|
||||
// Get all matching uniques that don't apply to only this city
|
||||
fun getMatchingUniquesWithNonLocalEffects(placeholderText: String): Sequence<Unique> {
|
||||
return cityConstructions.builtBuildingUniqueMap.getUniques(placeholderText).asSequence()
|
||||
return cityConstructions.builtBuildingUniqueMap.getUniques(placeholderText)
|
||||
.filter { it.params.none { param -> param == "in this city" } }
|
||||
// Note that we don't query religion here, as those only have local effects (for now at least)
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ class CivilizationInfo {
|
||||
} +
|
||||
policies.policyUniques.getUniques(uniqueTemplate) +
|
||||
tech.getTechUniques().filter { it.placeholderText == uniqueTemplate } +
|
||||
temporaryUniques.filter { it.first.placeholderText == uniqueTemplate }.map { it.first }
|
||||
temporaryUniques.asSequence().filter { it.first.placeholderText == uniqueTemplate }.map { it.first }
|
||||
}
|
||||
|
||||
//region Units
|
||||
|
@ -25,10 +25,10 @@ class UniqueMap:HashMap<String, ArrayList<Unique>>() {
|
||||
this[unique.placeholderText]!!.add(unique)
|
||||
}
|
||||
|
||||
fun getUniques(placeholderText: String): List<Unique> {
|
||||
fun getUniques(placeholderText: String): Sequence<Unique> {
|
||||
val result = this[placeholderText]
|
||||
if (result == null) return listOf()
|
||||
else return result
|
||||
if (result == null) return sequenceOf()
|
||||
else return result.asSequence()
|
||||
}
|
||||
|
||||
fun getAllUniques() = this.asSequence().flatMap { it.value.asSequence() }
|
||||
|
Loading…
Reference in New Issue
Block a user