chore: Early exit moveToNewEra

This commit is contained in:
yairm210 2025-01-02 20:47:15 +02:00
parent 9fca320574
commit ced36b8e8a

View File

@ -417,9 +417,10 @@ class TechManager : IsPartOfGameInfoSerialization {
val previousEra = civInfo.getEra() val previousEra = civInfo.getEra()
updateEra() updateEra()
val currentEra = civInfo.getEra() val currentEra = civInfo.getEra()
if (previousEra != currentEra) { if (previousEra == currentEra) return
if(showNotification) {
if(!civInfo.isSpectator()) if (showNotification) {
if (!civInfo.isSpectator())
civInfo.addNotification( civInfo.addNotification(
"You have entered the [$currentEra]!", "You have entered the [$currentEra]!",
NotificationCategory.General, NotificationCategory.General,
@ -433,6 +434,7 @@ class TechManager : IsPartOfGameInfoSerialization {
) )
} }
} }
for (policyBranch in getRuleset().policyBranches.values.filter { for (policyBranch in getRuleset().policyBranches.values.filter {
it.era == currentEra.name && civInfo.policies.isAdoptable(it) it.era == currentEra.name && civInfo.policies.isAdoptable(it)
}) { }) {
@ -450,7 +452,6 @@ class TechManager : IsPartOfGameInfoSerialization {
.filter { it.eraNumber > previousEra.eraNumber && it.eraNumber <= currentEra.eraNumber } .filter { it.eraNumber > previousEra.eraNumber && it.eraNumber <= currentEra.eraNumber }
.sortedBy { it.eraNumber } .sortedBy { it.eraNumber }
for (era in erasPassed) for (era in erasPassed)
for (unique in era.uniqueObjects) for (unique in era.uniqueObjects)
if (!unique.hasTriggerConditional() && unique.conditionalsApply(civInfo.state)) if (!unique.hasTriggerConditional() && unique.conditionalsApply(civInfo.state))
@ -477,7 +478,6 @@ class TechManager : IsPartOfGameInfoSerialization {
civInfo, civInfo,
triggerNotificationText = "due to entering the [${currentEra.name}]") triggerNotificationText = "due to entering the [${currentEra.name}]")
} }
}
private fun updateEra() { private fun updateEra() {
val ruleset = civInfo.gameInfo.ruleset val ruleset = civInfo.gameInfo.ruleset