mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
Fixing bad quickslot behaviour where it would unequip things when the selection changed
This commit is contained in:
@@ -122,6 +122,11 @@ class ActorInventory(@Transient val actor: Pocketed, var maxCapacity: Int, var c
|
|||||||
actor.unequipItem(existingItem.item)
|
actor.unequipItem(existingItem.item)
|
||||||
// depleted item; remove entry from inventory
|
// depleted item; remove entry from inventory
|
||||||
itemList.remove(existingItem)
|
itemList.remove(existingItem)
|
||||||
|
|
||||||
|
// also unequip on the quickslot
|
||||||
|
actor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||||
|
actor.inventory.setQuickBar(it, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -202,6 +207,7 @@ class ActorInventory(@Transient val actor: Pocketed, var maxCapacity: Int, var c
|
|||||||
add(newItem)
|
add(newItem)
|
||||||
itemEquipped[newItem.equipPosition] = newItem.dynamicID //invSearchByDynamicID(newItem.dynamicID)!!.item // will test if some sketchy code is written. Test fail: kotlinNullpointerException
|
itemEquipped[newItem.equipPosition] = newItem.dynamicID //invSearchByDynamicID(newItem.dynamicID)!!.item // will test if some sketchy code is written. Test fail: kotlinNullpointerException
|
||||||
|
|
||||||
|
// update quickslot designation as the item is being unpacked (e.g. using fresh new pickaxe)
|
||||||
actor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
actor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||||
setQuickBar(it, newItem.dynamicID)
|
setQuickBar(it, newItem.dynamicID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
|
import net.torvald.terrarum.gameactors.ActorValue
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameitem.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.gameitem.ItemID
|
||||||
@@ -11,6 +12,7 @@ import net.torvald.terrarum.gameitem.ItemID
|
|||||||
interface Pocketed {
|
interface Pocketed {
|
||||||
|
|
||||||
var inventory: ActorInventory
|
var inventory: ActorInventory
|
||||||
|
val actorValue: ActorValue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equips an item. If the item is not in the inventory, an error will be thrown.
|
* Equips an item. If the item is not in the inventory, an error will be thrown.
|
||||||
@@ -29,12 +31,9 @@ interface Pocketed {
|
|||||||
|
|
||||||
inventory.itemEquipped[item.equipPosition] = null
|
inventory.itemEquipped[item.equipPosition] = null
|
||||||
|
|
||||||
// remove it from the quickslot
|
// NOTE: DON'T TOUCH QUICKSLOT HERE
|
||||||
inventory.quickSlot.forEachIndexed { index, itemID ->
|
// Relevant Actorvalue is NOT being updated on time
|
||||||
if (itemID == item.dynamicID) {
|
// They're being safely handled by UIItemInventoryElem*.touchDown() and ActorInventory.remove
|
||||||
inventory.setQuickBar(index, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item.effectOnUnequip(AppLoader.UPDATE_RATE)
|
item.effectOnUnequip(AppLoader.UPDATE_RATE)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user