Modding: Can provide resources as a global unique

This commit is contained in:
Yair Morgenstern 2022-12-15 09:30:14 +02:00
parent 1fb43a805f
commit 557735cb0e
3 changed files with 12 additions and 2 deletions

View File

@ -438,7 +438,7 @@ class CityInfo : IsPartOfGameInfoSerialization {
val resource = getRuleset().tileResources[unique.params[1]]
?: continue
cityResources.add(
resource, "Buildings+",
resource, "Buildings",
unique.params[0].toInt() * civInfo.getResourceModifier(resource)
)
}

View File

@ -5,6 +5,7 @@ import com.unciv.UncivGame
import com.unciv.logic.map.MapShape
import com.unciv.logic.map.TileInfo
import com.unciv.models.ruleset.tile.ResourceSupplyList
import com.unciv.models.ruleset.unique.UniqueTarget
import com.unciv.models.ruleset.unique.UniqueType
/** CivInfo class was getting too crowded */
@ -190,6 +191,15 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
newDetailedCivResources.addByResource(cityStateProvidedResources, Constants.cityStates)
}
for (unique in civInfo.getMatchingUniques(UniqueType.ProvidesResources)) {
if (unique.sourceObjectType == UniqueTarget.Building || unique.sourceObjectType == UniqueTarget.Wonder) continue // already calculated in city
newDetailedCivResources.add(
civInfo.gameInfo.ruleSet.tileResources[unique.params[1]]!!,
unique.sourceObjectType?.name ?: "",
unique.params[1].toInt()
)
}
for (diplomacyManager in civInfo.diplomacy.values)
newDetailedCivResources.add(diplomacyManager.resourcesFromTrade())

View File

@ -143,7 +143,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
CannotBuildUnits("Cannot build [baseUnitFilter] units", UniqueTarget.Global),
ConsumesResources("Consumes [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Building, UniqueTarget.Unit),
ProvidesResources("Provides [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Building),
ProvidesResources("Provides [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Global),
GrowthPercentBonus("[relativeAmount]% growth [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
CarryOverFood("[relativeAmount]% Food is carried over after population increases [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),