diff --git a/core/src/com/unciv/logic/automation/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/WorkerAutomation.kt index 57c4270252..8b8dc86993 100644 --- a/core/src/com/unciv/logic/automation/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/WorkerAutomation.kt @@ -53,9 +53,9 @@ class WorkerAutomation(val unit: MapUnit) { val mostUndevelopedCity = unit.civInfo.cities .filter { citiesToNumberOfUnimprovedTiles[it.name]!! > 0 } .sortedByDescending { citiesToNumberOfUnimprovedTiles[it.name] } - .firstOrNull { unit.movement.canReach(it.ccenterTile) } //goto most undeveloped city + .firstOrNull { unit.movement.canReach(it.getCenterTile()) } //goto most undeveloped city if (mostUndevelopedCity != null && mostUndevelopedCity != unit.currentTile.owningCity) { - val reachedTile = unit.movement.headTowards(mostUndevelopedCity.ccenterTile) + val reachedTile = unit.movement.headTowards(mostUndevelopedCity.getCenterTile()) if (reachedTile != currentTile) unit.doPreTurnAction() // since we've moved, maybe we can do something here - automate return } diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 3a8f6bc864..498b7d3433 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -24,7 +24,7 @@ import kotlin.math.roundToInt class CityInfo { @Transient lateinit var civInfo: CivilizationInfo - @Transient lateinit var ccenterTile:TileInfo // cached for better performance + @Transient lateinit private var centerTileInfo:TileInfo // cached for better performance @Transient val range = 2 @Transient lateinit var tileMap: TileMap @Transient lateinit var tilesInRange:HashSet @@ -115,7 +115,7 @@ class CityInfo { - fun getCenterTile(): TileInfo = ccenterTile + fun getCenterTile(): TileInfo = centerTileInfo fun getTiles(): List = tiles.map { tileMap[it] } fun getWorkableTiles() = getTiles().filter { it in tilesInRange } @@ -239,7 +239,7 @@ class CityInfo { //region state-changing functions fun setTransients() { tileMap = civInfo.gameInfo.tileMap - ccenterTile = tileMap[location] + centerTileInfo = tileMap[location] tilesInRange = getCenterTile().getTilesInDistance( 3).toHashSet() population.cityInfo = this expansion.cityInfo = this diff --git a/core/src/com/unciv/ui/tilegroups/CityButton.kt b/core/src/com/unciv/ui/tilegroups/CityButton.kt index de130101c7..1726854767 100644 --- a/core/src/com/unciv/ui/tilegroups/CityButton.kt +++ b/core/src/com/unciv/ui/tilegroups/CityButton.kt @@ -82,7 +82,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski // when deselected, move city button to its original position if (isButtonMoved && unitTable.selectedCity != city - && unitTable.selectedUnit?.currentTile != city.ccenterTile) { + && unitTable.selectedUnit?.currentTile != city.getCenterTile()) { moveButtonUp() } diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index 394a80f144..fcf6ea5b86 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -126,7 +126,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: if(newSelectedUnit==null || newSelectedUnit.type==UnitType.Civilian){ val unitsInTile = selectedTile!!.getUnits() if(previousSelectedCity != null && !previousSelectedCity.attackedThisTurn - && selectedTile!!.getTilesInDistance(2).contains(previousSelectedCity.ccenterTile) + && selectedTile!!.getTilesInDistance(2).contains(previousSelectedCity.getCenterTile()) && unitsInTile.isNotEmpty() && unitsInTile.first().civInfo.isAtWarWith(worldScreen.viewingCiv)){ // try to select the closest city to bombard this guy