Special type for unit triggerables

This commit is contained in:
Yair Morgenstern 2023-02-26 21:52:18 +02:00
parent 8c9877365d
commit a47864ecac
2 changed files with 8 additions and 6 deletions

View File

@ -11,6 +11,8 @@ enum class UniqueTarget(val inheritsFrom: UniqueTarget? = null) {
/** Only includes uniques that have immediate effects, caused by UniqueTriggerActivation */ /** Only includes uniques that have immediate effects, caused by UniqueTriggerActivation */
Triggerable, Triggerable,
UnitTriggerable(Triggerable),
/** Buildings, units, nations, policies, religions, techs etc. /** Buildings, units, nations, policies, religions, techs etc.
* Basically anything caught by CivInfo.getMatchingUniques. */ * Basically anything caught by CivInfo.getMatchingUniques. */
Global(Triggerable), Global(Triggerable),
@ -34,7 +36,7 @@ enum class UniqueTarget(val inheritsFrom: UniqueTarget? = null) {
// they're all just Unit uniques in different places. // they're all just Unit uniques in different places.
// So there should be no uniqueType that has a Promotion or UnitType target. // So there should be no uniqueType that has a Promotion or UnitType target.
// Except meta-level uniques, such as 'incompatible with [promotion]', of course // Except meta-level uniques, such as 'incompatible with [promotion]', of course
Unit, Unit(UnitTriggerable),
UnitType(Unit), UnitType(Unit),
Promotion(Unit), Promotion(Unit),
@ -689,11 +691,11 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
OneTimeGlobalAlert("Triggers the following global alert: [comment]", UniqueTarget.Policy), // used in Policy OneTimeGlobalAlert("Triggers the following global alert: [comment]", UniqueTarget.Policy), // used in Policy
OneTimeGlobalSpiesWhenEnteringEra("Every major Civilization gains a spy once a civilization enters this era", UniqueTarget.Era), OneTimeGlobalSpiesWhenEnteringEra("Every major Civilization gains a spy once a civilization enters this era", UniqueTarget.Era),
OneTimeUnitHeal("Heal this unit by [amount] HP", UniqueTarget.Unit), OneTimeUnitHeal("Heal this unit by [amount] HP", UniqueTarget.UnitTriggerable),
OneTimeUnitGainXP("This Unit gains [amount] XP", UniqueTarget.Ruins, UniqueTarget.Unit), OneTimeUnitGainXP("This Unit gains [amount] XP", UniqueTarget.Ruins, UniqueTarget.UnitTriggerable),
OneTimeUnitUpgrade("This Unit upgrades for free", UniqueTarget.Global, UniqueTarget.Unit), // Not used in Vanilla OneTimeUnitUpgrade("This Unit upgrades for free", UniqueTarget.Global, UniqueTarget.UnitTriggerable), // Not used in Vanilla
OneTimeUnitSpecialUpgrade("This Unit upgrades for free including special upgrades", UniqueTarget.Ruins), OneTimeUnitSpecialUpgrade("This Unit upgrades for free including special upgrades", UniqueTarget.Ruins),
OneTimeUnitGainPromotion("This Unit gains the [promotion] promotion", UniqueTarget.Triggerable, UniqueTarget.Unit), // Not used in Vanilla OneTimeUnitGainPromotion("This Unit gains the [promotion] promotion", UniqueTarget.UnitTriggerable), // Not used in Vanilla
SkipPromotion("Doing so will consume this opportunity to choose a Promotion", UniqueTarget.Promotion), SkipPromotion("Doing so will consume this opportunity to choose a Promotion", UniqueTarget.Promotion),
UnitsGainPromotion("[mapUnitFilter] units gain the [promotion] promotion", UniqueTarget.Triggerable), // Not used in Vanilla UnitsGainPromotion("[mapUnitFilter] units gain the [promotion] promotion", UniqueTarget.Triggerable), // Not used in Vanilla

View File

@ -39,7 +39,7 @@ class UniqueDocsWriter {
// The UniqueType are shown in enum order within their group, and groups are ordered // The UniqueType are shown in enum order within their group, and groups are ordered
// by their UniqueTarget.ordinal as well - source code order. // by their UniqueTarget.ordinal as well - source code order.
val targetTypesToUniques: Map<UniqueTarget, List<UniqueType>> = val targetTypesToUniques: Map<UniqueTarget, List<UniqueType>> =
if(showUniqueOnOneTarget) if (showUniqueOnOneTarget)
UniqueType.values().asSequence() UniqueType.values().asSequence()
.groupBy { it.targetTypes.minOrNull()!! } .groupBy { it.targetTypes.minOrNull()!! }
.toSortedMap() .toSortedMap()