From bbba24baae7140ce2d803635ffb0478b79784d9f Mon Sep 17 00:00:00 2001 From: SeventhM <127357473+SeventhM@users.noreply.github.com> Date: Tue, 9 Jan 2024 12:11:11 -0800 Subject: [PATCH] Reorder AddTechnology (#10901) --- .../civilization/managers/TechManager.kt | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/managers/TechManager.kt b/core/src/com/unciv/logic/civilization/managers/TechManager.kt index 273d819cd7..3cb339b055 100644 --- a/core/src/com/unciv/logic/civilization/managers/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/TechManager.kt @@ -285,6 +285,15 @@ class TechManager : IsPartOfGameInfoSerialization { researchedTechnologies = researchedTechnologies.withItem(newTech) addTechToTransients(newTech) + moveToNewEra(showNotification) + + if (!civInfo.isSpectator() && showNotification) + civInfo.addNotification("Research of [$techName] has completed!", TechAction(techName), + NotificationCategory.General, + NotificationIcon.Science) + if (isNewTech) + civInfo.popupAlerts.add(PopupAlert(AlertType.TechResearched, techName)) + val triggerNotificationText = "due to researching [$techName]" for (unique in newTech.uniqueObjects) if (!unique.hasTriggerConditional()) @@ -295,29 +304,24 @@ class TechManager : IsPartOfGameInfoSerialization { UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo, triggerNotificationText = triggerNotificationText) - updateTransientBooleans() - for (city in civInfo.cities) { - city.reassignPopulationDeferred() - } - - if (!civInfo.isSpectator() && showNotification) - civInfo.addNotification("Research of [$techName] has completed!", TechAction(techName), - NotificationCategory.General, - NotificationIcon.Science) - if (isNewTech) - civInfo.popupAlerts.add(PopupAlert(AlertType.TechResearched, techName)) - val revealedResources = getRuleset().tileResources.values.filter { techName == it.revealedBy } if (civInfo.playerType == PlayerType.Human) { for (revealedResource in revealedResources) { civInfo.gameInfo.notifyExploredResources(civInfo, revealedResource.name, 5) } } + + updateTransientBooleans() + // In the case of a 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 or when a tech provides a resource. // That can be seen on WorldScreenTopBar, so better update. civInfo.cache.updateCivResources() + for (city in civInfo.cities) { + city.reassignPopulationDeferred() + } + obsoleteOldUnits(techName) for (unique in civInfo.getMatchingUniques(UniqueType.MayanGainGreatPerson)) { @@ -326,7 +330,6 @@ class TechManager : IsPartOfGameInfoSerialization { MayaLongCountAction(), NotificationCategory.General, MayaCalendar.notificationIcon) } - moveToNewEra(showNotification) updateResearchProgress() }