Files
shattered-pixel-dungeon-web…/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/PinCushion.java
T
2015-06-12 16:44:09 -04:00

61 lines
1.8 KiB
Java

/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2015 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.watabou.utils.Bundle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
public class PinCushion extends Buff {
private ArrayList<MissileWeapon> items = new ArrayList<MissileWeapon>();
public void stick(MissileWeapon item){
items.add(item);
}
@Override
public void detach() {
for (Item item : items)
Dungeon.level.drop( item, target.pos).sprite.drop();
super.detach();
}
private static final String ITEMS = "items";
@Override
public void storeInBundle(Bundle bundle) {
bundle.put( ITEMS , items );
super.storeInBundle(bundle);
}
@Override
public void restoreFromBundle(Bundle bundle) {
items = new ArrayList<MissileWeapon>((Collection<MissileWeapon>)((Collection<?>)bundle.getCollection( ITEMS )));
super.restoreFromBundle( bundle );
}
}