mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-07 14:02:48 +07:00
Add a TriggerUponDiscoveringTile unique type (#10523)
* Add a TriggerUponDiscoveringTile unique type * Add a check for trigger presence
This commit is contained in:
parent
90767fce9a
commit
4adbd2e634
@ -21,6 +21,7 @@ import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.Unique
|
||||
import com.unciv.models.ruleset.unique.UniqueMap
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.ruleset.unit.UnitType
|
||||
import com.unciv.models.stats.Stats
|
||||
@ -344,8 +345,29 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
||||
if (updateCivViewableTiles && oldViewableTiles != viewableTiles
|
||||
// Don't bother updating if all previous and current viewable tiles are within our borders
|
||||
&& (oldViewableTiles.any { it !in civ.cache.ourTilesAndNeighboringTiles }
|
||||
|| viewableTiles.any { it !in civ.cache.ourTilesAndNeighboringTiles }))
|
||||
|| viewableTiles.any { it !in civ.cache.ourTilesAndNeighboringTiles })) {
|
||||
|
||||
val unfilteredTriggeredUniques = getTriggeredUniques(UniqueType.TriggerUponDiscoveringTile, StateForConditionals.IgnoreConditionals).toList()
|
||||
if (unfilteredTriggeredUniques.isNotEmpty()) {
|
||||
val newlyExploredTiles = viewableTiles.filter {
|
||||
!it.isExplored(civ)
|
||||
}
|
||||
for (tile in newlyExploredTiles) {
|
||||
// Include tile in the state for correct RNG seeding
|
||||
val state = StateForConditionals(civInfo=civ, unit=this, tile=tile);
|
||||
for (unique in unfilteredTriggeredUniques) {
|
||||
if (unique.conditionals.any {
|
||||
it.type == UniqueType.TriggerUponDiscoveringTile
|
||||
&& tile.matchesFilter(it.params[0], civ)
|
||||
} && unique.conditionalsApply(state)
|
||||
)
|
||||
UniqueTriggerActivation.triggerUnitwideUnique(unique, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
civ.cache.updateViewableTiles(explorerPosition)
|
||||
}
|
||||
}
|
||||
|
||||
fun isActionUntilHealed() = action?.endsWith("until healed") == true
|
||||
|
@ -766,6 +766,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
TriggerUponPromotion("upon being promoted", UniqueTarget.UnitTriggerCondition),
|
||||
TriggerUponLosingHealth("upon losing at least [amount] HP in a single attack", UniqueTarget.UnitTriggerCondition),
|
||||
TriggerUponEndingTurnInTile("upon ending a turn in a [tileFilter] tile", UniqueTarget.UnitTriggerCondition),
|
||||
TriggerUponDiscoveringTile("upon discovering a [tileFilter] tile", UniqueTarget.UnitTriggerCondition),
|
||||
|
||||
//endregion
|
||||
|
||||
|
@ -2133,6 +2133,12 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
||||
|
||||
Applicable to: UnitTriggerCondition
|
||||
|
||||
??? example "<upon discovering a [tileFilter] tile>"
|
||||
Triggers for each tile discovered (unfogged) by the unit.
|
||||
Example: "<upon discovering a [Farm] tile>"
|
||||
|
||||
Applicable to: UnitTriggerCondition
|
||||
|
||||
## UnitActionModifier uniques
|
||||
!!! note ""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user