Merging Source v1.7.2: item changes

This commit is contained in:
Evan Debenham
2014-10-21 00:38:15 -04:00
parent 4a49763309
commit 13afc9df8d
32 changed files with 523 additions and 269 deletions
@@ -187,7 +187,7 @@ public class Item implements Bundlable {
return collect( Dungeon.hero.belongings.backpack );
}
public Item detach( Bag container ) {
public final Item detach( Bag container ) {
if (quantity <= 0) {
@@ -203,28 +203,30 @@ public class Item implements Bundlable {
quantity--;
updateQuickslot();
try {
return getClass().newInstance();
try {
Item detached = getClass().newInstance();
detached.onDetach( );
return detached;
} catch (Exception e) {
return null;
}
}
}
public Item detachAll( Bag container ) {
for (Item item : container.items) {
if (item == this) {
container.items.remove( this );
QuickSlot.refresh();
return this;
} else if (item instanceof Bag) {
Bag bag = (Bag)item;
if (bag.contains( this )) {
detachAll( bag );
return this;
}
}
}
public final Item detachAll( Bag container ) {
for (Item item : container.items) {
if (item == this) {
container.items.remove( this );
item.onDetach( );
QuickSlot.refresh();
return this;
} else if (item instanceof Bag) {
Bag bag = (Bag)item;
if (bag.contains( this )) {
return detachAll( bag );
}
}
}
return this;
}
@@ -232,6 +234,8 @@ public class Item implements Bundlable {
public boolean isSimilar( Item item ) {
return getClass() == item.getClass();
}
protected void onDetach(){}
public Item upgrade() {
@@ -428,7 +432,7 @@ public class Item implements Bundlable {
float delay = TIME_TO_THROW;
if (this instanceof MissileWeapon) {
// Refactoring needed!
// FIXME
delay *= ((MissileWeapon)this).speedFactor( user );
if (enemy != null && enemy.buff( SnipersMark.class ) != null) {
delay *= 0.5f;