mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-31 01:44:45 +07:00
Conditioned trigger uniques do not 'go off' without the trigger (e.g. when tech researched, building built)
This commit is contained in:
parent
cfca929e73
commit
48bf588b48
@ -16,7 +16,6 @@ import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.unique.LocalUniqueCache
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.UniqueMap
|
||||
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stat
|
||||
@ -441,18 +440,6 @@ class CityConstructions : IsPartOfGameInfoSerialization {
|
||||
NotificationCategory.General, NotificationIcon.Construction, buildingIcon)
|
||||
}
|
||||
}
|
||||
|
||||
if (construction is Building) {
|
||||
for (unique in cityInfo.civInfo.getTriggeredUniques(UniqueType.TriggerUponConstructingBuilding, StateForConditionals(cityInfo.civInfo, cityInfo)))
|
||||
if (unique.conditionals.any {it.type == UniqueType.TriggerUponConstructingBuilding && construction.matchesFilter(it.params[0])})
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, cityInfo.civInfo, cityInfo)
|
||||
|
||||
for (unique in cityInfo.civInfo.getTriggeredUniques(UniqueType.TriggerUponConstructingBuildingCityFilter, StateForConditionals(cityInfo.civInfo, cityInfo)))
|
||||
if (unique.conditionals.any {it.type == UniqueType.TriggerUponConstructingBuildingCityFilter
|
||||
&& construction.matchesFilter(it.params[0])
|
||||
&& cityInfo.matchesFilter(it.params[1])})
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, cityInfo.civInfo, cityInfo)
|
||||
}
|
||||
}
|
||||
|
||||
fun addBuilding(buildingName: String) {
|
||||
|
@ -6,6 +6,7 @@ import com.unciv.models.ruleset.Policy
|
||||
import com.unciv.models.ruleset.Policy.PolicyBranchType
|
||||
import com.unciv.models.ruleset.PolicyBranch
|
||||
import com.unciv.models.ruleset.unique.UniqueMap
|
||||
import com.unciv.models.ruleset.unique.UniqueTarget
|
||||
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.ui.utils.extensions.toPercent
|
||||
@ -199,8 +200,8 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
for (unique in policy.uniqueObjects)
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
|
||||
if (unique.conditionals.none { it.type!!.targetTypes.contains(UniqueTarget.TriggerCondition) })
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
|
||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponAdoptingPolicy))
|
||||
if (unique.conditionals.any {it.type == UniqueType.TriggerUponAdoptingPolicy && it.params[0] == policy.name})
|
||||
|
@ -7,6 +7,7 @@ import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.models.ruleset.Era
|
||||
import com.unciv.models.ruleset.tech.Technology
|
||||
import com.unciv.models.ruleset.unique.UniqueMap
|
||||
import com.unciv.models.ruleset.unique.UniqueTarget
|
||||
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
@ -248,9 +249,15 @@ class TechManager : IsPartOfGameInfoSerialization {
|
||||
repeatingTechsResearched++
|
||||
researchedTechnologies = researchedTechnologies.withItem(newTech)
|
||||
addTechToTransients(newTech)
|
||||
for (unique in newTech.uniqueObjects) {
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
}
|
||||
for (unique in newTech.uniqueObjects)
|
||||
if (unique.conditionals.none { it.type!!.targetTypes.contains(UniqueTarget.TriggerCondition) })
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
|
||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponResearch))
|
||||
if (unique.conditionals.any {it.type == UniqueType.TriggerUponResearch && it.params[0] == techName})
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
|
||||
|
||||
updateTransientBooleans()
|
||||
for (city in civInfo.cities) {
|
||||
city.updateCitizens = true
|
||||
@ -340,17 +347,14 @@ class TechManager : IsPartOfGameInfoSerialization {
|
||||
.sortedBy { it.eraNumber }
|
||||
for (era in erasPassed)
|
||||
for (unique in era.uniqueObjects)
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
if (unique.conditionals.none { it.type!!.targetTypes.contains(UniqueTarget.TriggerCondition) })
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
|
||||
val eraNames = erasPassed.map { it.name }.toHashSet()
|
||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponEnteringEra))
|
||||
if (unique.conditionals.any {it.type == UniqueType.TriggerUponEnteringEra && it.params[0] in eraNames})
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
}
|
||||
|
||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponResearch))
|
||||
if (unique.conditionals.any {it.type == UniqueType.TriggerUponResearch && it.params[0] == techName})
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
}
|
||||
|
||||
fun updateEra() {
|
||||
|
@ -644,7 +644,8 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
getRejectionReasons(cityConstructions).isEmpty()
|
||||
|
||||
override fun postBuildEvent(cityConstructions: CityConstructions, boughtWith: Stat?): Boolean {
|
||||
val civInfo = cityConstructions.cityInfo.civInfo
|
||||
val cityInfo = cityConstructions.cityInfo
|
||||
val civInfo = cityInfo.civInfo
|
||||
|
||||
if (civInfo.gameInfo.spaceResources.contains(name)) {
|
||||
civInfo.victoryManager.currentsSpaceshipParts.add(name, 1)
|
||||
@ -666,7 +667,18 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
cityConstructions.addFreeBuildings()
|
||||
|
||||
for (unique in uniqueObjects)
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo, cityConstructions.cityInfo)
|
||||
if (unique.conditionals.none { it.type!!.targetTypes.contains(UniqueTarget.TriggerCondition) })
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo, cityConstructions.cityInfo)
|
||||
|
||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponConstructingBuilding, StateForConditionals(civInfo, cityInfo)))
|
||||
if (unique.conditionals.any {it.type == UniqueType.TriggerUponConstructingBuilding && matchesFilter(it.params[0])})
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, cityInfo.civInfo, cityInfo)
|
||||
|
||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponConstructingBuildingCityFilter, StateForConditionals(cityInfo.civInfo, cityInfo)))
|
||||
if (unique.conditionals.any {it.type == UniqueType.TriggerUponConstructingBuildingCityFilter
|
||||
&& matchesFilter(it.params[0])
|
||||
&& cityInfo.matchesFilter(it.params[1])})
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, cityInfo.civInfo, cityInfo)
|
||||
|
||||
if (hasUnique(UniqueType.EnemyLandUnitsSpendExtraMovement))
|
||||
civInfo.updateHasActiveEnemyMovementPenalty()
|
||||
|
Loading…
Reference in New Issue
Block a user