mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-19 16:57:38 +07:00
Trigger resource recalculation upon gaining a unit that requires resources
This commit is contained in:
parent
fcd309781d
commit
a7107fa04d
@ -70,10 +70,13 @@ class UnitManager(val civInfo:Civilization) {
|
|||||||
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit? {
|
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit? {
|
||||||
val unit = civInfo.gameInfo.tileMap.placeUnitNearTile(location, unitName, civInfo)
|
val unit = civInfo.gameInfo.tileMap.placeUnitNearTile(location, unitName, civInfo)
|
||||||
|
|
||||||
if (unit != null)
|
if (unit != null) {
|
||||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponGainingUnit))
|
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponGainingUnit))
|
||||||
if (unit.matchesFilter(unique.params[0]))
|
if (unit.matchesFilter(unique.params[0]))
|
||||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||||
|
if (unit.baseUnit.getResourceRequirementsPerTurn().isNotEmpty())
|
||||||
|
civInfo.cache.updateCivResources()
|
||||||
|
}
|
||||||
return unit
|
return unit
|
||||||
}
|
}
|
||||||
fun getCivUnitsSize(): Int = unitList.size
|
fun getCivUnitsSize(): Int = unitList.size
|
||||||
|
@ -278,7 +278,7 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
|||||||
for (city in civInfo.cities) newDetailedCivResources.add(city.getCityResources())
|
for (city in civInfo.cities) newDetailedCivResources.add(city.getCityResources())
|
||||||
|
|
||||||
for (resourceSupply in newDetailedCivResources)
|
for (resourceSupply in newDetailedCivResources)
|
||||||
if(resourceSupply.amount > 0)
|
if (resourceSupply.amount > 0)
|
||||||
resourceSupply.amount = (resourceSupply.amount * civInfo.getResourceModifier(resourceSupply.resource)).toInt()
|
resourceSupply.amount = (resourceSupply.amount * civInfo.getResourceModifier(resourceSupply.resource)).toInt()
|
||||||
|
|
||||||
if (!civInfo.isCityState()) {
|
if (!civInfo.isCityState()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user