mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 12:54:06 -04:00
chore: Early exit moveToNewEra
This commit is contained in:
parent
9fca320574
commit
ced36b8e8a
@ -417,66 +417,66 @@ 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) {
|
||||||
civInfo.addNotification(
|
if (!civInfo.isSpectator())
|
||||||
"You have entered the [$currentEra]!",
|
civInfo.addNotification(
|
||||||
NotificationCategory.General,
|
"You have entered the [$currentEra]!",
|
||||||
NotificationIcon.Science
|
NotificationCategory.General,
|
||||||
|
NotificationIcon.Science
|
||||||
|
)
|
||||||
|
if (civInfo.isMajorCiv()) {
|
||||||
|
for (knownCiv in civInfo.getKnownCivsWithSpectators()) {
|
||||||
|
knownCiv.addNotification(
|
||||||
|
"[${civInfo.civName}] has entered the [$currentEra]!",
|
||||||
|
NotificationCategory.General, civInfo.civName, NotificationIcon.Science
|
||||||
)
|
)
|
||||||
if (civInfo.isMajorCiv()) {
|
|
||||||
for (knownCiv in civInfo.getKnownCivsWithSpectators()) {
|
|
||||||
knownCiv.addNotification(
|
|
||||||
"[${civInfo.civName}] has entered the [$currentEra]!",
|
|
||||||
NotificationCategory.General, civInfo.civName, NotificationIcon.Science
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (policyBranch in getRuleset().policyBranches.values.filter {
|
|
||||||
it.era == currentEra.name && civInfo.policies.isAdoptable(it)
|
|
||||||
}) {
|
|
||||||
if (!civInfo.isSpectator())
|
|
||||||
civInfo.addNotification(
|
|
||||||
"[${policyBranch.name}] policy branch unlocked!",
|
|
||||||
PolicyAction(policyBranch.name),
|
|
||||||
NotificationCategory.General,
|
|
||||||
NotificationIcon.Culture
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val erasPassed = getRuleset().eras.values
|
for (policyBranch in getRuleset().policyBranches.values.filter {
|
||||||
.filter { it.eraNumber > previousEra.eraNumber && it.eraNumber <= currentEra.eraNumber }
|
it.era == currentEra.name && civInfo.policies.isAdoptable(it)
|
||||||
.sortedBy { it.eraNumber }
|
}) {
|
||||||
|
if (!civInfo.isSpectator())
|
||||||
|
civInfo.addNotification(
|
||||||
for (era in erasPassed)
|
"[${policyBranch.name}] policy branch unlocked!",
|
||||||
for (unique in era.uniqueObjects)
|
PolicyAction(policyBranch.name),
|
||||||
if (!unique.hasTriggerConditional() && unique.conditionalsApply(civInfo.state))
|
NotificationCategory.General,
|
||||||
UniqueTriggerActivation.triggerUnique(
|
NotificationIcon.Culture
|
||||||
unique,
|
)
|
||||||
civInfo,
|
}
|
||||||
triggerNotificationText = "due to entering the [${era.name}]"
|
|
||||||
)
|
|
||||||
|
|
||||||
val eraNames = erasPassed.map { it.name }.toHashSet()
|
|
||||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponEnteringEra))
|
|
||||||
for (eraName in eraNames)
|
|
||||||
if (unique.getModifiers(UniqueType.TriggerUponEnteringEra).any { it.params[0] == eraName })
|
|
||||||
UniqueTriggerActivation.triggerUnique(
|
|
||||||
unique,
|
|
||||||
civInfo,
|
|
||||||
triggerNotificationText = "due to entering the [$eraName]"
|
|
||||||
)
|
|
||||||
|
|
||||||
// The unfiltered version
|
|
||||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponEnteringEraUnfiltered))
|
|
||||||
UniqueTriggerActivation.triggerUnique(
|
|
||||||
unique,
|
|
||||||
civInfo,
|
|
||||||
triggerNotificationText = "due to entering the [${currentEra.name}]")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val erasPassed = getRuleset().eras.values
|
||||||
|
.filter { it.eraNumber > previousEra.eraNumber && it.eraNumber <= currentEra.eraNumber }
|
||||||
|
.sortedBy { it.eraNumber }
|
||||||
|
|
||||||
|
for (era in erasPassed)
|
||||||
|
for (unique in era.uniqueObjects)
|
||||||
|
if (!unique.hasTriggerConditional() && unique.conditionalsApply(civInfo.state))
|
||||||
|
UniqueTriggerActivation.triggerUnique(
|
||||||
|
unique,
|
||||||
|
civInfo,
|
||||||
|
triggerNotificationText = "due to entering the [${era.name}]"
|
||||||
|
)
|
||||||
|
|
||||||
|
val eraNames = erasPassed.map { it.name }.toHashSet()
|
||||||
|
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponEnteringEra))
|
||||||
|
for (eraName in eraNames)
|
||||||
|
if (unique.getModifiers(UniqueType.TriggerUponEnteringEra).any { it.params[0] == eraName })
|
||||||
|
UniqueTriggerActivation.triggerUnique(
|
||||||
|
unique,
|
||||||
|
civInfo,
|
||||||
|
triggerNotificationText = "due to entering the [$eraName]"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The unfiltered version
|
||||||
|
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponEnteringEraUnfiltered))
|
||||||
|
UniqueTriggerActivation.triggerUnique(
|
||||||
|
unique,
|
||||||
|
civInfo,
|
||||||
|
triggerNotificationText = "due to entering the [${currentEra.name}]")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateEra() {
|
private fun updateEra() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user