mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -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"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 163
|
versionCode 165
|
||||||
versionName "2.10.3"
|
versionName "2.10.4"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -237,7 +237,7 @@ class CivilizationInfo {
|
|||||||
|
|
||||||
fun isDefeated()= cities.isEmpty() && !getCivUnits().any{it.name=="Settler"}
|
fun isDefeated()= cities.isEmpty() && !getCivUnits().any{it.name=="Settler"}
|
||||||
fun getEra(): TechEra {
|
fun getEra(): TechEra {
|
||||||
val maxEraOfTech = tech.getResearchedTechs()
|
val maxEraOfTech = tech.researchedTechnologies
|
||||||
.map { it.era() }
|
.map { it.era() }
|
||||||
.max()
|
.max()
|
||||||
if(maxEraOfTech!=null) return maxEraOfTech
|
if(maxEraOfTech!=null) return maxEraOfTech
|
||||||
|
@ -9,8 +9,8 @@ import com.unciv.ui.utils.tr
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class TechManager {
|
class TechManager {
|
||||||
@Transient
|
@Transient lateinit var civInfo: CivilizationInfo
|
||||||
lateinit var civInfo: CivilizationInfo
|
@Transient val researchedTechnologies=ArrayList<Technology>()
|
||||||
|
|
||||||
var freeTechs = 0
|
var freeTechs = 0
|
||||||
var techsResearched = HashSet<String>()
|
var techsResearched = HashSet<String>()
|
||||||
@ -57,9 +57,7 @@ class TechManager {
|
|||||||
return GameBasics.Technologies[TechName]!!.prerequisites.all { isResearched(it) }
|
return GameBasics.Technologies[TechName]!!.prerequisites.all { isResearched(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getResearchedTechs() = techsResearched.map { GameBasics.Technologies[it]!! }
|
fun getUniques() = researchedTechnologies.flatMap { it.uniques }
|
||||||
|
|
||||||
fun getUniques() = getResearchedTechs().flatMap { it.uniques }
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
@ -77,6 +75,7 @@ class TechManager {
|
|||||||
if(currentTechnology!="Future Tech")
|
if(currentTechnology!="Future Tech")
|
||||||
techsToResearch.remove(currentTechnology)
|
techsToResearch.remove(currentTechnology)
|
||||||
techsResearched.add(currentTechnology)
|
techsResearched.add(currentTechnology)
|
||||||
|
researchedTechnologies.add(GameBasics.Technologies[currentTechnology]!!)
|
||||||
civInfo.addNotification("Research of [$currentTechnology] has completed!", null, Color.BLUE)
|
civInfo.addNotification("Research of [$currentTechnology] has completed!", null, Color.BLUE)
|
||||||
|
|
||||||
val currentEra = civInfo.getEra()
|
val currentEra = civInfo.getEra()
|
||||||
@ -109,6 +108,10 @@ class TechManager {
|
|||||||
city.cityConstructions.currentConstruction = currentConstructionUnit.upgradesTo!!
|
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 nextTurnStats = civInfo.getStatsForNextTurn()
|
||||||
val goldPerTurn = "(" + (if (nextTurnStats.gold > 0) "+" else "") + Math.round(nextTurnStats.gold) + ")"
|
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))
|
scienceLabel.setText("+" + Math.round(nextTurnStats.science))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user