mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 19:43:13 -04:00
Bugfix: Building 'improvement to create' no longer cached across rulesets
This commit is contained in:
parent
da908106de
commit
666c2056f3
@ -529,24 +529,20 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This can be 'by lazy' across all rulesets because it only checks building uniques
|
// This can be 'by lazy' across all rulesets because it only checks building uniques
|
||||||
private val _hasCreatesOneImprovementUnique by lazy {
|
private val improvementToCreate: String? by lazy {
|
||||||
hasUnique(UniqueType.CreatesOneImprovement)
|
val unique = getMatchingUniques(UniqueType.CreatesOneImprovement).firstOrNull()
|
||||||
|
if (unique == null) null
|
||||||
|
else unique.params[0]
|
||||||
}
|
}
|
||||||
@Readonly fun hasCreateOneImprovementUnique() = _hasCreatesOneImprovementUnique
|
|
||||||
|
|
||||||
@Cache private var _getImprovementToCreate: TileImprovement? = null
|
@Readonly fun hasCreateOneImprovementUnique() = improvementToCreate != null
|
||||||
|
|
||||||
@Readonly
|
@Readonly
|
||||||
// This CANNOT be cached across rulesets, because the improvement itself is retrieved. Currently a bug!
|
// Only the name can be cached across rulesets.
|
||||||
// TODO: Clean up - retrieve only the *name* of the improvement
|
// The improvement itself CANNOT be cached because it's ruleset-dependent.
|
||||||
private fun getImprovementToCreate(ruleset: Ruleset): TileImprovement? {
|
private fun getImprovementToCreate(ruleset: Ruleset): TileImprovement? {
|
||||||
if (!hasCreateOneImprovementUnique()) return null
|
if (improvementToCreate == null) return null
|
||||||
if (_getImprovementToCreate == null) {
|
return ruleset.tileImprovements[improvementToCreate]
|
||||||
val improvementUnique = getMatchingUniques(UniqueType.CreatesOneImprovement)
|
|
||||||
.firstOrNull() ?: return null
|
|
||||||
_getImprovementToCreate = ruleset.tileImprovements[improvementUnique.params[0]]
|
|
||||||
}
|
|
||||||
return _getImprovementToCreate
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Readonly
|
@Readonly
|
||||||
|
@ -360,7 +360,8 @@ enum class UniqueType(
|
|||||||
|
|
||||||
CreatesOneImprovement("Creates a [improvementName] improvement on a specific tile", UniqueTarget.Building,
|
CreatesOneImprovement("Creates a [improvementName] improvement on a specific tile", UniqueTarget.Building,
|
||||||
docDescription = "When choosing to construct this building, the player must select a tile where the improvement can be built." +
|
docDescription = "When choosing to construct this building, the player must select a tile where the improvement can be built." +
|
||||||
" Upon building completion, the tile will gain this improvement."),
|
" Upon building completion, the tile will gain this improvement." +
|
||||||
|
" Limited to one per building."),
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
///////////////////////////////////////// region 04 UNIT UNIQUES /////////////////////////////////////////
|
///////////////////////////////////////// region 04 UNIT UNIQUES /////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user