Add TechManager.isObsolete(unit) (#10659)

* Update TechManager.kt

* Update CityStateFunctions.kt
This commit is contained in:
dHannasch 2023-12-04 11:26:39 -07:00 committed by GitHub
parent 8a03f9df12
commit 47e6b788af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -94,7 +94,7 @@ class CityStateFunctions(val civInfo: Civilization) {
?: return null
if (!receivingCiv.tech.isResearched(uniqueUnit))
return null
if (uniqueUnit.obsoleteTech != null && receivingCiv.tech.isResearched(uniqueUnit.obsoleteTech!!))
if (receivingCiv.tech.isObsolete(uniqueUnit))
return null
return uniqueUnit
}

View File

@ -157,6 +157,8 @@ class TechManager : IsPartOfGameInfoSerialization {
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 {
val tech = getRuleset().technologies[techName]!!
if (tech.uniqueObjects.any { it.type == UniqueType.OnlyAvailableWhen && !it.conditionalsApply(civInfo) })