TechButton now displays units and buildings corresponding to the description

This commit is contained in:
Yair Morgenstern 2019-11-19 20:16:53 +02:00
parent 15e59b161b
commit ff3795c96f
2 changed files with 4 additions and 16 deletions

View file

@ -66,7 +66,7 @@ class Technology {
return lineList.joinToString("\n") { it.tr() }
}
private fun getEnabledBuildings(civInfo: CivilizationInfo): List<Building> {
fun getEnabledBuildings(civInfo: CivilizationInfo): List<Building> {
var enabledBuildings = GameBasics.Buildings.values.filter {
it.requiredTech == name &&
(it.uniqueTo == null || it.uniqueTo == civInfo.civName)

View file

@ -44,23 +44,12 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
val civName = techManager.civInfo.civName
val techEnabledUnits = GameBasics.Units.values.filter { it.requiredTech == techName }
val ourUniqueUnits = techEnabledUnits.filter { it.uniqueTo == civName }
val replacedUnits = ourUniqueUnits.map { it.replaces!! }
val ourEnabledUnits = techEnabledUnits.filter { it.uniqueTo == null && !replacedUnits.contains(it.name) }
.union(ourUniqueUnits)
val tech = GameBasics.Technologies[techName]!!
for (unit in ourEnabledUnits)
for (unit in tech.getEnabledUnits(techManager.civInfo))
techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(30f))
val techEnabledBuildings = GameBasics.Buildings.values.filter { it.requiredTech == techName }
val ourUniqueBuildings = techEnabledBuildings.filter { it.uniqueTo == civName }
val replacedBuildings = ourUniqueBuildings.map { it.replaces!! }
val ourEnabledBuildings = techEnabledBuildings
.filter { it.uniqueTo == null && !replacedBuildings.contains(it.name) }
.union(ourUniqueBuildings)
for (building in ourEnabledBuildings)
for (building in tech.getEnabledBuildings(techManager.civInfo))
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
for (improvement in GameBasics.TileImprovements.values
@ -74,7 +63,6 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
for (resource in GameBasics.TileResources.values.filter { it.revealedBy == techName })
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, 30f))
val tech = GameBasics.Technologies[techName]!!
for (unique in tech.uniques)
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Star")
.apply { color = Color.BLACK }.surroundWithCircle(30f))