Trigger resource recalculation upon gaining a unit that requires resources

This commit is contained in:
Yair Morgenstern 2023-06-01 11:43:55 +03:00
parent fcd309781d
commit a7107fa04d
2 changed files with 5 additions and 2 deletions

View File

@ -70,10 +70,13 @@ class UnitManager(val civInfo:Civilization) {
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit? {
val unit = civInfo.gameInfo.tileMap.placeUnitNearTile(location, unitName, civInfo)
if (unit != null)
if (unit != null) {
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponGainingUnit))
if (unit.matchesFilter(unique.params[0]))
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
if (unit.baseUnit.getResourceRequirementsPerTurn().isNotEmpty())
civInfo.cache.updateCivResources()
}
return unit
}
fun getCivUnitsSize(): Int = unitList.size