mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
hopefully fixed a bug where crafting item sometimes enequips an item in the quickslot?
This commit is contained in:
@@ -21,28 +21,31 @@ interface Pocketed {
|
|||||||
fun unequipItem(item: GameItem?) {
|
fun unequipItem(item: GameItem?) {
|
||||||
if (item == null) return
|
if (item == null) return
|
||||||
|
|
||||||
|
// check equipposition of the given item
|
||||||
if (item.equipPosition == GameItem.EquipPosition.NULL)
|
if (item.equipPosition == GameItem.EquipPosition.NULL)
|
||||||
throw Error("Unequipping the item that cannot be equipped in the first place")
|
throw Error("Unequipping the item that cannot be equipped in the first place")
|
||||||
|
|
||||||
|
// check if the actor even has the items
|
||||||
if (!inventory.contains(item)) {
|
if (!inventory.contains(item)) {
|
||||||
//throw Error("Unequipping the item that does not exist in inventory")
|
//throw Error("Unequipping the item that does not exist in inventory")
|
||||||
System.err.println("[Pocketed] Warning -- Unequipping the item that does not exist in inventory")
|
System.err.println("[Pocketed] Warning -- Unequipping the item that does not exist in inventory")
|
||||||
return // just do nothing
|
return // just do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.itemEquipped[item.equipPosition] = null
|
// check if the actor actually have the item equipped
|
||||||
|
if (inventory.itemEquipped[item.equipPosition] == item.dynamicID) {
|
||||||
|
inventory.itemEquipped[item.equipPosition] = null
|
||||||
|
|
||||||
// NOTE: DON'T TOUCH QUICKSLOT HERE
|
// NOTE: DON'T TOUCH QUICKSLOT HERE
|
||||||
// Relevant Actorvalue is NOT being updated on time
|
// Relevant Actorvalue is NOT being updated on time
|
||||||
// They're being safely handled by UIItemInventoryElem*.touchDown() and ActorInventory.remove
|
// They're being safely handled by UIItemInventoryElem*.touchDown() and ActorInventory.remove
|
||||||
|
|
||||||
item.effectOnUnequip(this as ActorWithBody)
|
item.effectOnUnequip(this as ActorWithBody)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unequipItem(itemID: ItemID?) {
|
fun unequipItem(itemID: ItemID?) {
|
||||||
itemID?.let {
|
unequipItem(ItemCodex[itemID])
|
||||||
unequipItem(ItemCodex[itemID])
|
|
||||||
} ?: return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need for equipSlot(Int)
|
// no need for equipSlot(Int)
|
||||||
@@ -50,7 +53,13 @@ interface Pocketed {
|
|||||||
if (slot < 0 || slot > GameItem.EquipPosition.INDEX_MAX)
|
if (slot < 0 || slot > GameItem.EquipPosition.INDEX_MAX)
|
||||||
throw IllegalArgumentException("Slot index out of range: $slot")
|
throw IllegalArgumentException("Slot index out of range: $slot")
|
||||||
|
|
||||||
unequipItem(inventory.itemEquipped[slot])
|
val itemID = inventory.itemEquipped[slot]
|
||||||
|
|
||||||
|
if (itemID != null) {
|
||||||
|
val item = ItemCodex[itemID]!!
|
||||||
|
inventory.itemEquipped[slot] = null
|
||||||
|
item.effectOnUnequip(this as ActorWithBody)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user