mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 15:30:43 -04:00
Modding - Buildings can be rendered obsolete (unbuildable) by techs
This commit is contained in:
parent
0cb29d64f4
commit
bfa9c65700
@ -26,6 +26,7 @@ Get [unitName] =
|
|||||||
|
|
||||||
Hydro Plant =
|
Hydro Plant =
|
||||||
+1 population in each city =
|
+1 population in each city =
|
||||||
|
[buildingName] obsoleted =
|
||||||
|
|
||||||
# Diplomacy,Trade,Nations
|
# Diplomacy,Trade,Nations
|
||||||
|
|
||||||
@ -919,25 +920,3 @@ Must be on [terrain] =
|
|||||||
in this city =
|
in this city =
|
||||||
in every city =
|
in every city =
|
||||||
in capital =
|
in capital =
|
||||||
|
|
||||||
# Quests
|
|
||||||
Route =
|
|
||||||
Build a road to connect your capital to our city. =
|
|
||||||
Kill Camp =
|
|
||||||
We feel threatened by a Barbarian Camp near our city. Please take care of it. =
|
|
||||||
Connect Resource =
|
|
||||||
In order to make our civilizations stronger, connect [Resource] to your trade network. =
|
|
||||||
Construct Wonder =
|
|
||||||
We recommend you to start building [Wonder] to show the whole world your civilization strength. =
|
|
||||||
Great Person =
|
|
||||||
Great People can change the course of a Civilization! You will be rewarded for acquiring a new [Great Person]. =
|
|
||||||
Kill City State =
|
|
||||||
You will be rewarded for destroying the city state of [Target]! =
|
|
||||||
Find Player =
|
|
||||||
You have yet to discover where [Civilization] set up their cities. You will be rewarded for finding their territories. =
|
|
||||||
Find Natural Wonder =
|
|
||||||
Send your best explorers on a quest to discover Natural Wonders. Nobody knows the location of [Natural Wonder] yet. =
|
|
||||||
Contest Culture =
|
|
||||||
The civilization with the largest Culture growth will gain a reward. =
|
|
||||||
Contest Techs =
|
|
||||||
The civilization with the largest number of new Technologies researched will gain a reward. =
|
|
||||||
|
@ -245,8 +245,9 @@ open class TileInfo {
|
|||||||
if (improvement.improvingTech != null && observingCiv.tech.isResearched(improvement.improvingTech!!))
|
if (improvement.improvingTech != null && observingCiv.tech.isResearched(improvement.improvingTech!!))
|
||||||
stats.add(improvement.improvingTechStats!!) // eg Chemistry for mines
|
stats.add(improvement.improvingTechStats!!) // eg Chemistry for mines
|
||||||
|
|
||||||
for (unique in improvement.uniqueObjects) if (unique.placeholderText == "[] once [] is discovered"
|
for (unique in improvement.uniqueObjects)
|
||||||
&& observingCiv.tech.isResearched(unique.params[1])) stats.add(Stats.parse(unique.params[0]))
|
if (unique.placeholderText == "[] once [] is discovered" && observingCiv.tech.isResearched(unique.params[1]))
|
||||||
|
stats.add(Stats.parse(unique.params[0]))
|
||||||
|
|
||||||
if (city != null) {
|
if (city != null) {
|
||||||
val cityWideUniques = city.cityConstructions.builtBuildingUniqueMap.getUniques("[] from [] tiles in this city")
|
val cityWideUniques = city.cityConstructions.builtBuildingUniqueMap.getUniques("[] from [] tiles in this city")
|
||||||
|
@ -249,6 +249,7 @@ class Building : NamedStats(), IConstruction {
|
|||||||
if (civInfo.cities.none { it.cityConstructions.containsBuildingOrEquivalent(filter) }) return unique.text // Wonder is not built
|
if (civInfo.cities.none { it.cityConstructions.containsBuildingOrEquivalent(filter) }) return unique.text // Wonder is not built
|
||||||
} else if (!civInfo.policies.adoptedPolicies.contains(filter)) return "Policy is not adopted" // this reason should not be displayed
|
} else if (!civInfo.policies.adoptedPolicies.contains(filter)) return "Policy is not adopted" // this reason should not be displayed
|
||||||
}
|
}
|
||||||
|
"Obsolete with []" -> if (civInfo.tech.isResearched(unique.params[0])) return unique.text
|
||||||
|
|
||||||
"Must have an owned mountain within 2 tiles" -> // Deprecated as of 3.10.8 . Use "Must have an owned [Mountain] within [2] tiles" instead
|
"Must have an owned mountain within 2 tiles" -> // Deprecated as of 3.10.8 . Use "Must have an owned [Mountain] within [2] tiles" instead
|
||||||
if (cityCenter.getTilesInDistance(2)
|
if (cityCenter.getTilesInDistance(2)
|
||||||
|
@ -32,7 +32,7 @@ class Technology {
|
|||||||
if (!mapOfImprovedImprovements.containsKey(key)) mapOfImprovedImprovements[key] = ArrayList()
|
if (!mapOfImprovedImprovements.containsKey(key)) mapOfImprovedImprovements[key] = ArrayList()
|
||||||
mapOfImprovedImprovements[key]!!.add(improvement.name)
|
mapOfImprovedImprovements[key]!!.add(improvement.name)
|
||||||
}
|
}
|
||||||
for ( improvements in mapOfImprovedImprovements) {
|
for (improvements in mapOfImprovedImprovements) {
|
||||||
val impimpString = improvements.key.tr() + improvements.value.joinToString(", "," ") { it.tr() }
|
val impimpString = improvements.key.tr() + improvements.value.joinToString(", "," ") { it.tr() }
|
||||||
lineList += impimpString
|
lineList += impimpString
|
||||||
}
|
}
|
||||||
@ -69,6 +69,9 @@ class Technology {
|
|||||||
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")"
|
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(building in getObsoletedBuildings(viewingCiv))
|
||||||
|
lineList += "[${building.name}] obsoleted"
|
||||||
|
|
||||||
val revealedResource = ruleset.tileResources.values.filter { it.revealedBy == name }
|
val revealedResource = ruleset.tileResources.values.filter { it.revealedBy == name }
|
||||||
.map { it.name }.firstOrNull() // can only be one
|
.map { it.name }.firstOrNull() // can only be one
|
||||||
if (revealedResource != null) lineList += "Reveals [$revealedResource] on the map".tr()
|
if (revealedResource != null) lineList += "Reveals [$revealedResource] on the map".tr()
|
||||||
@ -94,6 +97,12 @@ class Technology {
|
|||||||
return enabledBuildings
|
return enabledBuildings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getObsoletedBuildings(civInfo: CivilizationInfo): Sequence<Building> {
|
||||||
|
val obsoletedBuildings = civInfo.gameInfo.ruleSet.buildings.values.asSequence()
|
||||||
|
.filter { it.uniqueObjects.any { it.placeholderText=="Obsolete with []" && it.params[0]==name } }
|
||||||
|
return obsoletedBuildings.filter { civInfo.getEquivalentBuilding(it.name)==it }
|
||||||
|
}
|
||||||
|
|
||||||
fun getEnabledUnits(civInfo: CivilizationInfo): List<BaseUnit> {
|
fun getEnabledUnits(civInfo: CivilizationInfo): List<BaseUnit> {
|
||||||
var enabledUnits = civInfo.gameInfo.ruleSet.units.values.filter {
|
var enabledUnits = civInfo.gameInfo.ruleSet.units.values.filter {
|
||||||
it.requiredTech == name &&
|
it.requiredTech == name &&
|
||||||
|
@ -5,10 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.Touchable
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.logic.civilization.TechManager
|
import com.unciv.logic.civilization.TechManager
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.*
|
||||||
import com.unciv.ui.utils.ImageGetter
|
|
||||||
import com.unciv.ui.utils.surroundWithCircle
|
|
||||||
import com.unciv.ui.utils.toLabel
|
|
||||||
|
|
||||||
class TechButton(techName:String, private val techManager: TechManager, isWorldScreen: Boolean = true) : Table(CameraStageBaseScreen.skin) {
|
class TechButton(techName:String, private val techManager: TechManager, isWorldScreen: Boolean = true) : Table(CameraStageBaseScreen.skin) {
|
||||||
val text= "".toLabel().apply { setAlignment(Align.center) }
|
val text= "".toLabel().apply { setAlignment(Align.center) }
|
||||||
@ -44,9 +41,9 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
|||||||
val techIconSize = 30f
|
val techIconSize = 30f
|
||||||
|
|
||||||
val civName = techManager.civInfo.civName
|
val civName = techManager.civInfo.civName
|
||||||
val gameBasics = techManager.civInfo.gameInfo.ruleSet
|
val ruleset = techManager.civInfo.gameInfo.ruleSet
|
||||||
|
|
||||||
val tech = gameBasics.technologies[techName]!!
|
val tech = ruleset.technologies[techName]!!
|
||||||
|
|
||||||
for (unit in tech.getEnabledUnits(techManager.civInfo))
|
for (unit in tech.getEnabledUnits(techManager.civInfo))
|
||||||
techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(techIconSize))
|
techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(techIconSize))
|
||||||
@ -54,16 +51,26 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
|||||||
for (building in tech.getEnabledBuildings(techManager.civInfo))
|
for (building in tech.getEnabledBuildings(techManager.civInfo))
|
||||||
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(techIconSize))
|
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(techIconSize))
|
||||||
|
|
||||||
for (improvement in gameBasics.tileImprovements.values
|
for(building in tech.getObsoletedBuildings(techManager.civInfo) )
|
||||||
|
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(techIconSize).apply {
|
||||||
|
val closeImage = ImageGetter.getImage("OtherIcons/Close")
|
||||||
|
closeImage.setSize(techIconSize/2,techIconSize/2)
|
||||||
|
closeImage.color = Color.RED
|
||||||
|
closeImage.center(this)
|
||||||
|
addActor(closeImage)
|
||||||
|
})
|
||||||
|
|
||||||
|
for (improvement in ruleset.tileImprovements.values
|
||||||
.filter { it.techRequired == techName || it.uniqueObjects.any { u -> u.params.contains(techName) }
|
.filter { it.techRequired == techName || it.uniqueObjects.any { u -> u.params.contains(techName) }
|
||||||
|| it.improvingTech == techName }
|
|| it.improvingTech == techName
|
||||||
.filter { it.uniqueTo==null || it.uniqueTo==civName }) {
|
|| it.uniqueObjects.any { it.placeholderText=="[] once [] is discovered" && it.params[1]==techName } }
|
||||||
|
.filter { it.uniqueTo==null || it.uniqueTo==civName })
|
||||||
if (improvement.name.startsWith("Remove"))
|
if (improvement.name.startsWith("Remove"))
|
||||||
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Stop")).size(techIconSize)
|
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Stop")).size(techIconSize)
|
||||||
else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, techIconSize))
|
else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, techIconSize))
|
||||||
}
|
|
||||||
|
|
||||||
for (resource in gameBasics.tileResources.values.filter { it.revealedBy == techName })
|
|
||||||
|
for (resource in ruleset.tileResources.values.filter { it.revealedBy == techName })
|
||||||
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, techIconSize))
|
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, techIconSize))
|
||||||
|
|
||||||
for (unique in tech.uniques)
|
for (unique in tech.uniques)
|
||||||
@ -72,7 +79,6 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
|||||||
|
|
||||||
if (isWorldScreen) rightSide.add(techEnabledIcons)
|
if (isWorldScreen) rightSide.add(techEnabledIcons)
|
||||||
else rightSide.add(techEnabledIcons)
|
else rightSide.add(techEnabledIcons)
|
||||||
// .width(techEnabledIcons.children.size * (techIconSize+6f))
|
|
||||||
.minWidth(225f)
|
.minWidth(225f)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user