v0.8.2c: bags now try to grab new items when an item leaves them
This commit is contained in:
parent
0608a5447d
commit
39c5da6061
|
@ -270,6 +270,7 @@ public class Item implements Bundlable {
|
|||
if (item == this) {
|
||||
container.items.remove(this);
|
||||
item.onDetach();
|
||||
container.grabItems(); //try to put more items into the bag as it now has free space
|
||||
return this;
|
||||
} else if (item instanceof Bag) {
|
||||
Bag bag = (Bag)item;
|
||||
|
|
|
@ -69,18 +69,7 @@ public class Bag extends Item implements Iterable<Item> {
|
|||
@Override
|
||||
public boolean collect( Bag container ) {
|
||||
|
||||
for (Item item : container.items.toArray( new Item[0] )) {
|
||||
if (canHold( item )) {
|
||||
int slot = Dungeon.quickslot.getSlot(item);
|
||||
item.detachAll(container);
|
||||
if (!item.collect(this)) {
|
||||
item.collect(container);
|
||||
}
|
||||
if (slot != -1) {
|
||||
Dungeon.quickslot.setSlot(slot, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
grabItems(container);
|
||||
|
||||
if (super.collect( container )) {
|
||||
|
||||
|
@ -102,6 +91,27 @@ public class Bag extends Item implements Iterable<Item> {
|
|||
updateQuickslot();
|
||||
}
|
||||
|
||||
public void grabItems(){
|
||||
if (this != Dungeon.hero.belongings.backpack) {
|
||||
grabItems(Dungeon.hero.belongings.backpack);
|
||||
}
|
||||
}
|
||||
|
||||
public void grabItems( Bag container ){
|
||||
for (Item item : container.items.toArray( new Item[0] )) {
|
||||
if (canHold( item )) {
|
||||
int slot = Dungeon.quickslot.getSlot(item);
|
||||
item.detachAll(container);
|
||||
if (!item.collect(this)) {
|
||||
item.collect(container);
|
||||
}
|
||||
if (slot != -1) {
|
||||
Dungeon.quickslot.setSlot(slot, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgradable() {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user