save/load kinda mostly working but fixtures are not getting their sprites back

This commit is contained in:
minjaesong
2021-09-06 17:31:37 +09:00
parent ec08f8d07e
commit 1accf985e7
29 changed files with 230 additions and 126 deletions

View File

@@ -26,9 +26,9 @@ class ItemCodex {
* <ItemID or RefID for Actor, TheItem>
* Will return corresponding Actor if ID >= ACTORID_MIN
*/
val itemCodex = HashMap<ItemID, GameItem>()
val dynamicItemDescription = HashMap<ItemID, GameItem>()
val dynamicToStaticTable = HashMap<ItemID, ItemID>()
@Transient val itemCodex = HashMap<ItemID, GameItem>()
@Transient var dynamicItemDescription = HashMap<ItemID, GameItem>(); private set
var dynamicToStaticTable = HashMap<ItemID, ItemID>(); private set
@Transient val ACTORID_MIN = ReferencingRanges.ACTORS.first
@@ -40,6 +40,17 @@ class ItemCodex {
dynamicToStaticTable.clear()
}
/**
* This method does not alter already-been-loaded itemCodex; only filles up dynamicitem-related fields
*/
fun loadFromSave(other: ItemCodex) {
this.dynamicToStaticTable = other.dynamicToStaticTable
dynamicToStaticTable.forEach { dynid, itemid ->
printdbg(this, "Loadfromsave dynid $dynid ->> $itemid")
dynamicItemDescription[dynid] = itemCodex[itemid]!!
}
}
private val itemImagePlaceholder: TextureRegion
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_24") // copper pickaxe
@@ -62,7 +73,7 @@ class ItemCodex {
if (code == null) return null
if (code.startsWith("$PREFIX_DYNAMICITEM:"))
return dynamicItemDescription[code]!!
return dynamicItemDescription[code] ?: throw NullPointerException("No ItemProp with id $code")
else if (code.startsWith("$PREFIX_ACTORITEM:")) {
val a = (Terrarum.ingame!! as TerrarumIngame).getActorByID(code.substring(6).toInt()) // actor item
if (a is CanBeAnItem) return a.itemData

View File

@@ -34,7 +34,7 @@ class Material {
class MaterialCodex {
val materialProps = HashMap<String, Material>()
@Transient val materialProps = HashMap<String, Material>()
@Transient private val nullMaterial = Material()
internal constructor()