quickslot works, new event for actor "actorValueChanged"

- "unpacking" fresh new tool would un-register quickslot desig.
- priority issue on "equipped by quickslot change" and "equipped by inventory UI"
This commit is contained in:
Song Minjae
2017-04-28 12:21:27 +09:00
parent 253260de6f
commit 93939f22bf
34 changed files with 215 additions and 61 deletions

View File

@@ -14,7 +14,9 @@ interface Pocketed {
/**
* Equips an item. If the item is not in the inventory, an error will be thrown.
*/
fun unequipItem(item: InventoryItem) {
fun unequipItem(item: InventoryItem?) {
if (item == null) return
if (item.equipPosition == InventoryItem.EquipPosition.NULL)
throw Error("Unequipping the item that cannot be equipped in the first place")
@@ -28,6 +30,14 @@ interface Pocketed {
item.effectOnUnequip(Terrarum.appgc, Terrarum.delta)
}
// no need for equipSlot(Int)
fun unequipSlot(slot: Int) {
if (slot < 0 || slot > InventoryItem.EquipPosition.INDEX_MAX)
throw IllegalArgumentException("Slot index out of range: $slot")
unequipItem(inventory.itemEquipped[slot])
}
/**
* Equips an item. If the item is not in the inventory, adds the item first.
*/