mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 22:00:24 +07:00
perf(memory): Save unit icon location on baseunit
This commit is contained in:
@ -63,6 +63,9 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
|
||||
@Transient
|
||||
var cachedForceEvaluation: Int = -1
|
||||
|
||||
@delegate:Transient // memory perf optimization to not create the string per unit
|
||||
val unitIconLocation by lazy { "UnitIcons/$name.png" }
|
||||
|
||||
@Transient
|
||||
val costFunctions = BaseUnitCost(this)
|
||||
|
@ -251,8 +251,8 @@ object ImageGetter {
|
||||
fun getRandomNationPortrait(size: Float): Portrait = PortraitNation(Constants.random, size)
|
||||
|
||||
fun getUnitIcon(unit: BaseUnit, color: Color = Color.BLACK): Image =
|
||||
if (imageExists("UnitIcons/${unit.name}"))
|
||||
getImage("UnitIcons/${unit.name}").apply { this.color = color }
|
||||
if (imageExists(unit.unitIconLocation))
|
||||
getImage(unit.unitIconLocation).apply { this.color = color }
|
||||
else getImage("UnitTypeIcons/${unit.type}").apply { this.color = color }
|
||||
|
||||
fun getConstructionPortrait(construction: String, size: Float): Group {
|
||||
|
Reference in New Issue
Block a user