fixed a stupid bug where spawning a same kind of fixture twice would crash the game because the spawner would not renew the fixture instance after a first spawn

This commit is contained in:
minjaesong
2022-03-23 10:03:03 +09:00
parent de45ad1c25
commit 76435dbbdf
5 changed files with 24 additions and 19 deletions

View File

@@ -26,6 +26,8 @@ open class DroppedItem : ActorWithBody {
var itemID: ItemID = ""; private set
@Transient private var visualItemID = ""
@Transient private var textureRegion: TextureRegion? = null // deserialiser won't call setter of the fields
var itemCount = 1L
@@ -76,8 +78,11 @@ open class DroppedItem : ActorWithBody {
override fun drawBody(batch: SpriteBatch) {
// deserialiser won't call setter of the fields
if (visualItemID == "") {
visualItemID = BlockCodex.getOrNull(itemID)?.world ?: itemID
}
if (textureRegion == null) {
textureRegion = ItemCodex.getItemImage(itemID)!!
textureRegion = ItemCodex.getItemImage(visualItemID)!!
}
// copy-pasted from ActorWithBody.drawSpriteInGoodPosition()