mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-06 07:31:26 +07:00
perf: small 1% cpu optimizations
This commit is contained in:
parent
922f459aa4
commit
ee5d06d187
@ -105,7 +105,8 @@ object Automation {
|
||||
if (city.civ.wantsToFocusOn(stat))
|
||||
yieldStats[stat] *= 2f
|
||||
|
||||
yieldStats[stat] *= civPersonality.scaledFocus(PersonalityValue[stat])
|
||||
val scaledFocus = civPersonality.scaledFocus(PersonalityValue[stat])
|
||||
if (scaledFocus != 1f) yieldStats[stat] *= scaledFocus
|
||||
}
|
||||
|
||||
// Apply City focus
|
||||
@ -184,7 +185,7 @@ object Automation {
|
||||
}
|
||||
// Only now do we filter out the constructable units because that's a heavier check
|
||||
.filter { it.isBuildable(city.cityConstructions) }
|
||||
.toList()
|
||||
.toList().asSequence()
|
||||
|
||||
val chosenUnit: BaseUnit
|
||||
if (!city.civ.isAtWar()
|
||||
|
@ -66,12 +66,15 @@ enum class CityFocus(
|
||||
else -> 1f
|
||||
}
|
||||
|
||||
private val statValuesForFocus: List<Stat> by lazy {
|
||||
Stat.values().filter { getStatMultiplier(it) != 1f }
|
||||
}
|
||||
|
||||
fun applyWeightTo(stats: Stats) {
|
||||
for (stat in Stat.values()) {
|
||||
for (stat in statValuesForFocus) {
|
||||
val currentStat = stats[stat]
|
||||
if (currentStat == 0f) continue
|
||||
val statMultiplier = getStatMultiplier(stat)
|
||||
if (statMultiplier == 1f) continue
|
||||
stats[stat] = currentStat * statMultiplier
|
||||
}
|
||||
}
|
||||
|
@ -82,10 +82,9 @@ class TileImprovementFunctions(val tile: Tile) {
|
||||
.any { civInfo.getResourceAmount(it.params[1]) < it.params[0].toInt() })
|
||||
yield(ImprovementBuildingProblem.MissingResources)
|
||||
|
||||
val knownFeatureRemovals = tile.ruleset.tileRemovals
|
||||
val knownFeatureRemovals = tile.ruleset.nonRoadTileRemovals
|
||||
.filter { rulesetImprovement ->
|
||||
RoadStatus.values().none { it.removeAction == rulesetImprovement.name }
|
||||
&& (rulesetImprovement.techRequired == null || civInfo.tech.isResearched(rulesetImprovement.techRequired!!))
|
||||
rulesetImprovement.techRequired == null || civInfo.tech.isResearched(rulesetImprovement.techRequired!!)
|
||||
}
|
||||
|
||||
if (!canImprovementBeBuiltHere(improvement, tile.hasViewableResource(civInfo), knownFeatureRemovals, stateForConditionals))
|
||||
|
@ -88,6 +88,8 @@ class Ruleset {
|
||||
}
|
||||
|
||||
val tileRemovals by lazy { tileImprovements.values.filter { it.name.startsWith(Constants.remove) } }
|
||||
val nonRoadTileRemovals by lazy { tileRemovals.filter { rulesetImprovement ->
|
||||
RoadStatus.values().none { it.removeAction == rulesetImprovement.name } } }
|
||||
|
||||
/** Contains all happiness levels that moving *from* them, to one *below* them, can change uniques that apply */
|
||||
val allHappinessLevelsThatAffectUniques by lazy {
|
||||
|
Loading…
Reference in New Issue
Block a user