Performance: Added Transient list of researched technologies

This commit is contained in:
Yair Morgenstern 2018-11-21 20:02:12 +02:00
parent 3a1196d39a
commit e16ea5c803
4 changed files with 12 additions and 9 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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]!! })
}
}

View File

@ -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))