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