Starting in later eras triggers era uniques in all previous eras (#7787)

This commit is contained in:
Xander Lenstra
2022-09-15 15:01:10 +02:00
committed by GitHub
parent 291b962f97
commit 5ae9b221fc
3 changed files with 20 additions and 15 deletions

View File

@ -88,6 +88,11 @@ object GameStarter {
} }
} }
if (tileMap.continentSizes.isEmpty()) // Probably saved map without continent data
runAndMeasure("assignContinents") {
tileMap.assignContinents(TileMap.AssignContinentsMode.Ensure)
}
runAndMeasure("setTransients") { runAndMeasure("setTransients") {
tileMap.setTransients(ruleset) // if we're starting from a map with pre-placed units, they need the civs to exist first tileMap.setTransients(ruleset) // if we're starting from a map with pre-placed units, they need the civs to exist first
tileMap.setStartingLocationsTransients() tileMap.setStartingLocationsTransients()
@ -97,24 +102,20 @@ object GameStarter {
gameInfo.setTransients() // needs to be before placeBarbarianUnit because it depends on the tilemap having its gameInfo set gameInfo.setTransients() // needs to be before placeBarbarianUnit because it depends on the tilemap having its gameInfo set
} }
runAndMeasure("Techs and Stats") { runAndMeasure("addCivStartingUnits") {
addCivTechs(gameInfo, ruleset, gameSetupInfo) addCivStartingUnits(gameInfo)
addCivStats(gameInfo)
} }
runAndMeasure("Policies") { runAndMeasure("Policies") {
addCivPolicies(gameInfo, ruleset) addCivPolicies(gameInfo, ruleset)
} }
if (tileMap.continentSizes.isEmpty()) // Probably saved map without continent data runAndMeasure("Techs and Stats") {
runAndMeasure("assignContinents") { addCivTechs(gameInfo, ruleset, gameSetupInfo)
tileMap.assignContinents(TileMap.AssignContinentsMode.Ensure) }
}
runAndMeasure("addCivStartingUnits") { runAndMeasure("Starting stats") {
// and only now do we add units for everyone, because otherwise both the gameInfo.setTransients() and the placeUnit will both add the unit to the civ's unit list! addCivStats(gameInfo)
addCivStartingUnits(gameInfo)
} }
// remove starting locations once we're done // remove starting locations once we're done

View File

@ -333,9 +333,12 @@ class TechManager : IsPartOfGameInfoSerialization {
civInfo.addNotification("[" + policyBranch.name + "] policy branch unlocked!", NotificationIcon.Culture) civInfo.addNotification("[" + policyBranch.name + "] policy branch unlocked!", NotificationIcon.Culture)
} }
// Note that if you somehow skip over an era, its uniques aren't triggered // Note that if you somehow skip over an era, its uniques aren't triggered
for (unique in currentEra.uniqueObjects) { val erasPassed = getRuleset().eras.values
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo) .filter { it.eraNumber > previousEra.eraNumber && it.eraNumber <= currentEra.eraNumber }
} .sortedBy { it.eraNumber }
for (era in erasPassed)
for (unique in era.uniqueObjects)
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
} }
} }

View File

@ -26,7 +26,7 @@ object UniqueTriggerActivation {
tile: TileInfo? = null, tile: TileInfo? = null,
notification: String? = null notification: String? = null
): Boolean { ): Boolean {
val timingConditional = unique.conditionals.firstOrNull{it.type == ConditionalTimedUnique} val timingConditional = unique.conditionals.firstOrNull { it.type == ConditionalTimedUnique }
if (timingConditional != null) { if (timingConditional != null) {
civInfo.temporaryUniques.add(TemporaryUnique(unique, timingConditional.params[0].toInt())) civInfo.temporaryUniques.add(TemporaryUnique(unique, timingConditional.params[0].toInt()))
return true return true
@ -486,6 +486,7 @@ object UniqueTriggerActivation {
val spyName = otherCiv.espionageManager.addSpy() val spyName = otherCiv.espionageManager.addSpy()
otherCiv.espionageManager.erasSpyEarnedFor.add(currentEra) otherCiv.espionageManager.erasSpyEarnedFor.add(currentEra)
if (otherCiv == civInfo || otherCiv.knows(civInfo)) if (otherCiv == civInfo || otherCiv.knows(civInfo))
// We don't tell which civilization entered the new era, as that is done in the notification directly above this one
otherCiv.addNotification("We have recruited [${spyName}] as a spy!", NotificationIcon.Spy) otherCiv.addNotification("We have recruited [${spyName}] as a spy!", NotificationIcon.Spy)
else else
otherCiv.addNotification("After an unknown civilization entered the [${currentEra}], we have recruited [${spyName}] as a spy!", NotificationIcon.Spy) otherCiv.addNotification("After an unknown civilization entered the [${currentEra}], we have recruited [${spyName}] as a spy!", NotificationIcon.Spy)