mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
perf: 'getWorkingCity' optimization
This commit is contained in:
parent
34c3abe74b
commit
82481162c8
@ -390,7 +390,8 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
|
|||||||
|
|
||||||
fun getWorkingCity(): City? {
|
fun getWorkingCity(): City? {
|
||||||
val civInfo = getOwner() ?: return null
|
val civInfo = getOwner() ?: return null
|
||||||
return civInfo.cities.firstOrNull { it.isWorked(this) }
|
if (owningCity?.isWorked(this) == true) return owningCity // common case
|
||||||
|
return civInfo.cities.firstOrNull { it != owningCity && it.isWorked(this) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isBlockaded(): Boolean {
|
fun isBlockaded(): Boolean {
|
||||||
@ -422,7 +423,8 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
|
|||||||
fun isWorked(): Boolean = getWorkingCity() != null
|
fun isWorked(): Boolean = getWorkingCity() != null
|
||||||
fun providesYield(): Boolean {
|
fun providesYield(): Boolean {
|
||||||
if (getCity() == null) return false
|
if (getCity() == null) return false
|
||||||
return isCityCenter() || isWorked()
|
return isCityCenter()
|
||||||
|
|| isWorked()
|
||||||
|| getUnpillagedTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation) == true
|
|| getUnpillagedTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation) == true
|
||||||
|| terrainHasUnique(UniqueType.TileProvidesYieldWithoutPopulation)
|
|| terrainHasUnique(UniqueType.TileProvidesYieldWithoutPopulation)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user