setting up the inventory using builder (during init) requires ingame.player to be nullable, lateinit won't work

This commit is contained in:
Song Minjae
2017-04-11 23:07:29 +09:00
parent e7f221a499
commit 498cf4709b
21 changed files with 132 additions and 103 deletions

View File

@@ -138,11 +138,11 @@ class UIItemInventoryElem(
val itemEquipSlot = item!!.equipPosition
val player = Terrarum.ingame!!.player
if (item != player.inventory.itemEquipped[itemEquipSlot]) { // if this item is unequipped, equip it
player.equipItem(item!!)
if (item != player?.inventory?.itemEquipped?.get(itemEquipSlot)) { // if this item is unequipped, equip it
player?.equipItem(item!!)
}
else { // if not, unequip it
player.unequipItem(item!!)
player?.unequipItem(item!!)
}
}