mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 17:28:57 +07:00
Update civ resources when a researched tech reveals a resource (#9467)
This commit is contained in:
@ -312,11 +312,22 @@ class TechManager : IsPartOfGameInfoSerialization {
|
||||
if (isNewTech)
|
||||
civInfo.popupAlerts.add(PopupAlert(AlertType.TechResearched, techName))
|
||||
|
||||
val revealedResources = getRuleset().tileResources.values.filter { techName == it.revealedBy }
|
||||
var mayNeedUpdateResources = revealedResources.isNotEmpty() // default for AI
|
||||
if (civInfo.playerType == PlayerType.Human) {
|
||||
for (revealedResource in getRuleset().tileResources.values.filter { techName == it.revealedBy }) {
|
||||
civInfo.gameInfo.notifyExploredResources(civInfo, revealedResource.name, 5, false)
|
||||
mayNeedUpdateResources = false
|
||||
for (revealedResource in revealedResources) {
|
||||
// notifyExploredResources scans the player's owned tiles and returns false if none
|
||||
// found with a revealed resource - keep this knowledge to avoid the update call.
|
||||
mayNeedUpdateResources = mayNeedUpdateResources ||
|
||||
civInfo.gameInfo.notifyExploredResources(civInfo, revealedResource.name, 5, false)
|
||||
}
|
||||
}
|
||||
// At least in the case of a human player hurrying research, this civ's resource availability
|
||||
// may now be out of date - e.g. when an owned tile by luck already has an appropriate improvement.
|
||||
// That can be seen on WorldScreenTopBar, so better update unless we know there's no resource change.
|
||||
if (mayNeedUpdateResources)
|
||||
civInfo.cache.updateCivResources()
|
||||
|
||||
obsoleteOldUnits(techName)
|
||||
|
||||
|
Reference in New Issue
Block a user