mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-03 00:29:18 +07:00
Converted TileInfo.isCityCenter to use a transient var (#6058)
This commit is contained in:
@ -144,7 +144,7 @@ class CityExpansionManager {
|
||||
city.lockedTiles.remove(tileInfo.position)
|
||||
}
|
||||
|
||||
tileInfo.owningCity = null
|
||||
tileInfo.setOwningCity(null)
|
||||
|
||||
cityInfo.civInfo.updateDetailedCivResources()
|
||||
cityInfo.cityStats.update()
|
||||
@ -164,7 +164,7 @@ class CityExpansionManager {
|
||||
tileInfo.getCity()!!.expansion.relinquishOwnership(tileInfo)
|
||||
|
||||
cityInfo.tiles = cityInfo.tiles.withItem(tileInfo.position)
|
||||
tileInfo.owningCity = cityInfo
|
||||
tileInfo.setOwningCity(cityInfo)
|
||||
cityInfo.population.autoAssignPopulation()
|
||||
cityInfo.civInfo.updateDetailedCivResources()
|
||||
cityInfo.cityStats.update()
|
||||
@ -190,7 +190,7 @@ class CityExpansionManager {
|
||||
fun setTransients() {
|
||||
val tiles = cityInfo.getTiles()
|
||||
for (tile in tiles)
|
||||
tile.owningCity = cityInfo
|
||||
tile.setOwningCity(cityInfo)
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
|
@ -26,8 +26,17 @@ open class TileInfo {
|
||||
@Transient
|
||||
lateinit var ruleset: Ruleset // a tile can be a tile with a ruleset, even without a map.
|
||||
|
||||
@Transient
|
||||
private var isCityCenterInternal = false
|
||||
|
||||
@Transient
|
||||
var owningCity: CityInfo? = null
|
||||
private set
|
||||
|
||||
fun setOwningCity(city:CityInfo?){
|
||||
owningCity = city
|
||||
isCityCenterInternal = getCity()?.location == position
|
||||
}
|
||||
|
||||
@Transient
|
||||
private lateinit var baseTerrainObject: Terrain
|
||||
@ -156,7 +165,7 @@ open class TileInfo {
|
||||
if (naturalWonder == null) throw Exception("No natural wonder exists for this tile!")
|
||||
else ruleset.terrains[naturalWonder!!]!!
|
||||
|
||||
fun isCityCenter(): Boolean = getCity()?.location == position
|
||||
fun isCityCenter(): Boolean = isCityCenterInternal
|
||||
fun isNaturalWonder(): Boolean = naturalWonder != null
|
||||
fun isImpassible() = getLastTerrain().impassable
|
||||
|
||||
|
@ -23,8 +23,8 @@ class TileImprovementConstructionTests {
|
||||
private fun getTile() = TileInfo().apply {
|
||||
baseTerrain = "Plains"
|
||||
ruleset = ruleSet
|
||||
owningCity = city
|
||||
position = Vector2(1f, 1f) // so that it's not on the same position as the city
|
||||
setOwningCity(city)
|
||||
this@apply.tileMap = this@TileImprovementConstructionTests.tileMap
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class UnitMovementAlgorithmsTests {
|
||||
val city = CityInfo()
|
||||
city.location = cityTile.position
|
||||
city.civInfo = civInfo
|
||||
cityTile.owningCity = city
|
||||
cityTile.setOwningCity(city)
|
||||
|
||||
for (type in ruleSet.unitTypes)
|
||||
{
|
||||
@ -248,7 +248,7 @@ class UnitMovementAlgorithmsTests {
|
||||
val city = CityInfo()
|
||||
city.location = tile.position.cpy().add(1f,1f)
|
||||
city.civInfo = otherCiv
|
||||
tile.owningCity = city
|
||||
tile.setOwningCity(city)
|
||||
|
||||
unit.baseUnit = BaseUnit().apply { unitType = ruleSet.unitTypes.keys.first(); ruleset = ruleSet }
|
||||
unit.owner = civInfo.civName
|
||||
|
Reference in New Issue
Block a user