mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Performance: Added Transient list of researched technologies
This commit is contained in:
parent
3a1196d39a
commit
e16ea5c803
@ -21,8 +21,8 @@ android {
|
||||
applicationId "com.unciv.game"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 163
|
||||
versionName "2.10.3"
|
||||
versionCode 165
|
||||
versionName "2.10.4"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -237,7 +237,7 @@ class CivilizationInfo {
|
||||
|
||||
fun isDefeated()= cities.isEmpty() && !getCivUnits().any{it.name=="Settler"}
|
||||
fun getEra(): TechEra {
|
||||
val maxEraOfTech = tech.getResearchedTechs()
|
||||
val maxEraOfTech = tech.researchedTechnologies
|
||||
.map { it.era() }
|
||||
.max()
|
||||
if(maxEraOfTech!=null) return maxEraOfTech
|
||||
|
@ -9,8 +9,8 @@ import com.unciv.ui.utils.tr
|
||||
import java.util.*
|
||||
|
||||
class TechManager {
|
||||
@Transient
|
||||
lateinit var civInfo: CivilizationInfo
|
||||
@Transient lateinit var civInfo: CivilizationInfo
|
||||
@Transient val researchedTechnologies=ArrayList<Technology>()
|
||||
|
||||
var freeTechs = 0
|
||||
var techsResearched = HashSet<String>()
|
||||
@ -57,9 +57,7 @@ class TechManager {
|
||||
return GameBasics.Technologies[TechName]!!.prerequisites.all { isResearched(it) }
|
||||
}
|
||||
|
||||
fun getResearchedTechs() = techsResearched.map { GameBasics.Technologies[it]!! }
|
||||
|
||||
fun getUniques() = getResearchedTechs().flatMap { it.uniques }
|
||||
fun getUniques() = researchedTechnologies.flatMap { it.uniques }
|
||||
|
||||
//endregion
|
||||
|
||||
@ -77,6 +75,7 @@ class TechManager {
|
||||
if(currentTechnology!="Future Tech")
|
||||
techsToResearch.remove(currentTechnology)
|
||||
techsResearched.add(currentTechnology)
|
||||
researchedTechnologies.add(GameBasics.Technologies[currentTechnology]!!)
|
||||
civInfo.addNotification("Research of [$currentTechnology] has completed!", null, Color.BLUE)
|
||||
|
||||
val currentEra = civInfo.getEra()
|
||||
@ -109,6 +108,10 @@ class TechManager {
|
||||
city.cityConstructions.currentConstruction = currentConstructionUnit.upgradesTo!!
|
||||
}
|
||||
}
|
||||
|
||||
fun setTransients(){
|
||||
researchedTechnologies.addAll(techsResearched.map { GameBasics.Technologies[it]!! })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,7 +131,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
||||
|
||||
val nextTurnStats = civInfo.getStatsForNextTurn()
|
||||
val goldPerTurn = "(" + (if (nextTurnStats.gold > 0) "+" else "") + Math.round(nextTurnStats.gold) + ")"
|
||||
goldLabel.setText("" + Math.round(civInfo.gold.toFloat()) + goldPerTurn)
|
||||
goldLabel.setText(Math.round(civInfo.gold.toFloat()).toString() + goldPerTurn)
|
||||
|
||||
scienceLabel.setText("+" + Math.round(nextTurnStats.science))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user