v1.2.0: improved logic for swapping misc items and light cloak talent

This commit is contained in:
Evan Debenham 2022-03-06 12:08:41 -05:00
parent bac328c531
commit 154d9256f4

View File

@ -96,8 +96,11 @@ public abstract class KindofMisc extends EquipableItem {
protected void onSelect(int index) { protected void onSelect(int index) {
KindofMisc equipped = miscs[index]; KindofMisc equipped = miscs[index];
//we directly remove the item because we want to have inventory capacity
// to unequip the equipped one, but don't want to trigger any other
// item detaching logic
int slot = Dungeon.quickslot.getSlot(KindofMisc.this); int slot = Dungeon.quickslot.getSlot(KindofMisc.this);
detach(hero.belongings.backpack); Dungeon.hero.belongings.backpack.items.remove(KindofMisc.this);
if (equipped.doUnequip(hero, true, false)) { if (equipped.doUnequip(hero, true, false)) {
//swap out equip in misc slot if needed //swap out equip in misc slot if needed
if (index == 0 && KindofMisc.this instanceof Ring){ if (index == 0 && KindofMisc.this instanceof Ring){
@ -107,9 +110,10 @@ public abstract class KindofMisc extends EquipableItem {
hero.belongings.ring = (Ring) hero.belongings.misc; hero.belongings.ring = (Ring) hero.belongings.misc;
hero.belongings.misc = null; hero.belongings.misc = null;
} }
Dungeon.hero.belongings.backpack.items.add(KindofMisc.this);
doEquip(hero); doEquip(hero);
} else { } else {
collect(); Dungeon.hero.belongings.backpack.items.add(KindofMisc.this);
} }
if (slot != -1) Dungeon.quickslot.setSlot(slot, KindofMisc.this); if (slot != -1) Dungeon.quickslot.setSlot(slot, KindofMisc.this);
updateQuickslot(); updateQuickslot();