mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 23:39:40 +07:00
Add TechManager.isObsolete(unit) (#10659)
* Update TechManager.kt * Update CityStateFunctions.kt
This commit is contained in:
@ -94,7 +94,7 @@ class CityStateFunctions(val civInfo: Civilization) {
|
|||||||
?: return null
|
?: return null
|
||||||
if (!receivingCiv.tech.isResearched(uniqueUnit))
|
if (!receivingCiv.tech.isResearched(uniqueUnit))
|
||||||
return null
|
return null
|
||||||
if (uniqueUnit.obsoleteTech != null && receivingCiv.tech.isResearched(uniqueUnit.obsoleteTech!!))
|
if (receivingCiv.tech.isObsolete(uniqueUnit))
|
||||||
return null
|
return null
|
||||||
return uniqueUnit
|
return uniqueUnit
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,8 @@ class TechManager : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
fun isResearched(construction: INonPerpetualConstruction): Boolean = construction.requiredTechs().all{ requiredTech -> isResearched(requiredTech) }
|
fun isResearched(construction: INonPerpetualConstruction): Boolean = construction.requiredTechs().all{ requiredTech -> isResearched(requiredTech) }
|
||||||
|
|
||||||
|
fun isObsolete(unit: BaseUnit): Boolean = unit.techsThatObsoleteThis().any{ obsoleteTech -> isResearched(obsoleteTech) }
|
||||||
|
|
||||||
fun canBeResearched(techName: String): Boolean {
|
fun canBeResearched(techName: String): Boolean {
|
||||||
val tech = getRuleset().technologies[techName]!!
|
val tech = getRuleset().technologies[techName]!!
|
||||||
if (tech.uniqueObjects.any { it.type == UniqueType.OnlyAvailableWhen && !it.conditionalsApply(civInfo) })
|
if (tech.uniqueObjects.any { it.type == UniqueType.OnlyAvailableWhen && !it.conditionalsApply(civInfo) })
|
||||||
|
Reference in New Issue
Block a user