mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 01:08:25 +07:00
Performance improvement for canPassThrough
This commit is contained in:
@ -53,22 +53,17 @@ class MapUnitCache(private val mapUnit: MapUnit) {
|
||||
val doubleMovementInTerrain = HashMap<String, DoubleMovement>()
|
||||
|
||||
var canEnterIceTiles = false
|
||||
|
||||
var cannotEnterOceanTiles = false
|
||||
|
||||
var canEnterForeignTerrain: Boolean = false
|
||||
|
||||
var canEnterCityStates: Boolean = false
|
||||
var costToDisembark: Float? = null
|
||||
|
||||
var costToEmbark: Float? = null
|
||||
|
||||
var paradropRange = 0
|
||||
|
||||
var hasUniqueToBuildImprovements = false // not canBuildImprovements to avoid confusion
|
||||
var hasUniqueToCreateWaterImprovements = false
|
||||
|
||||
var hasStrengthBonusInRadiusUnique = false
|
||||
|
||||
var hasCitadelPlacementUnique = false
|
||||
|
||||
fun updateUniques() {
|
||||
@ -119,6 +114,8 @@ class MapUnitCache(private val mapUnit: MapUnit) {
|
||||
canEnterForeignTerrain = mapUnit.hasUnique(UniqueType.CanEnterForeignTiles)
|
||||
|| mapUnit.hasUnique(UniqueType.CanEnterForeignTilesButLosesReligiousStrength)
|
||||
|
||||
canEnterCityStates = mapUnit.hasUnique(UniqueType.CanTradeWithCityStateForGoldAndInfluence)
|
||||
|
||||
hasStrengthBonusInRadiusUnique = mapUnit.hasUnique(UniqueType.StrengthBonusInRadius)
|
||||
hasCitadelPlacementUnique = mapUnit.getMatchingUniques(UniqueType.ConstructImprovementInstantly)
|
||||
.mapNotNull { mapUnit.civ.gameInfo.ruleset.tileImprovements[it.params[0]] }
|
||||
|
@ -780,7 +780,7 @@ class UnitMovement(val unit: MapUnit) {
|
||||
if (!unitSpecificAllowOcean && unit.cache.cannotEnterOceanTiles) return false
|
||||
}
|
||||
|
||||
if (unit.hasUnique(UniqueType.CanTradeWithCityStateForGoldAndInfluence) && tile.getOwner()?.isCityState() == true)
|
||||
if (unit.cache.canEnterCityStates && tile.getOwner()?.isCityState() == true)
|
||||
return true
|
||||
if (!unit.cache.canEnterForeignTerrain && !tile.canCivPassThrough(unit.civ)) return false
|
||||
|
||||
|
Reference in New Issue
Block a user