diff --git a/core/src/com/unciv/logic/map/tile/Tile.kt b/core/src/com/unciv/logic/map/tile/Tile.kt index a8e54ba5ca..1de0a29d31 100644 --- a/core/src/com/unciv/logic/map/tile/Tile.kt +++ b/core/src/com/unciv/logic/map/tile/Tile.kt @@ -366,16 +366,17 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable { fun isRoughTerrain() = allTerrains.any { it.isRough() } + private val stateThisTile: StateForConditionals = StateForConditionals(tile = this) /** Checks whether any of the TERRAINS of this tile has a certain unique */ - fun terrainHasUnique(uniqueType: UniqueType, state: StateForConditionals = StateForConditionals(tile = this)) = + fun terrainHasUnique(uniqueType: UniqueType, state: StateForConditionals = stateThisTile) = terrainUniqueMap.getMatchingUniques(uniqueType, state).any() /** Get all uniques of this type that any TERRAIN on this tile has */ - fun getTerrainMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals = StateForConditionals(tile = this) ): Sequence { + fun getTerrainMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals = stateThisTile ): Sequence { return terrainUniqueMap.getMatchingUniques(uniqueType, stateForConditionals) } /** Get all uniques of this type that any part of this tile has: terrains, improvement, resource */ - fun getMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals = StateForConditionals(tile=this)): Sequence { + fun getMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals = stateThisTile): Sequence { var uniques = getTerrainMatchingUniques(uniqueType, stateForConditionals) if (getUnpillagedImprovement() != null) { val tileImprovement = getTileImprovement() @@ -549,7 +550,7 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable { if (naturalWonder != null) bonus += getNaturalWonder().defenceBonus val tileImprovement = getUnpillagedTileImprovement() if (tileImprovement != null && includeImprovementBonus) { - for (unique in tileImprovement.getMatchingUniques(UniqueType.DefensiveBonus, StateForConditionals(tile = this))) + for (unique in tileImprovement.getMatchingUniques(UniqueType.DefensiveBonus, stateThisTile)) bonus += unique.params[0].toFloat() / 100 } return bonus @@ -766,7 +767,7 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable { return } - for (unique in newResource.getMatchingUniques(UniqueType.ResourceAmountOnTiles, StateForConditionals(tile = this))) { + for (unique in newResource.getMatchingUniques(UniqueType.ResourceAmountOnTiles, stateThisTile)) { if (matchesTerrainFilter(unique.params[0])) { resourceAmount = unique.params[1].toInt() return