v2.2.0: fixed imp shop not generating items during levelgen
This commit is contained in:
@@ -200,6 +200,7 @@ public class CityBossLevel extends Level {
|
|||||||
Painter.fill(this, end.left+5, end.bottom+1, 5, 1, Terrain.EMPTY);
|
Painter.fill(this, end.left+5, end.bottom+1, 5, 1, Terrain.EMPTY);
|
||||||
Painter.fill(this, end.left+6, end.bottom+2, 3, 1, Terrain.EMPTY);
|
Painter.fill(this, end.left+6, end.bottom+2, 3, 1, Terrain.EMPTY);
|
||||||
|
|
||||||
|
impShop.paint(this);
|
||||||
new CityPainter().paint(this, null);
|
new CityPainter().paint(this, null);
|
||||||
|
|
||||||
//pillars last, no deco on these
|
//pillars last, no deco on these
|
||||||
|
|||||||
+13
-14
@@ -25,14 +25,17 @@ import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.ImpShopkeeper;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.ImpShopkeeper;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Point;
|
import com.watabou.utils.Point;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
//shops probably shouldn't extend special room, because of cases like this.
|
//shops probably shouldn't extend special room, because of cases like this.
|
||||||
public class ImpShopRoom extends ShopRoom {
|
public class ImpShopRoom extends ShopRoom {
|
||||||
|
|
||||||
@@ -56,20 +59,11 @@ public class ImpShopRoom extends ShopRoom {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
Painter.fill( level, this, Terrain.WALL );
|
//this room isn't actually filled in until the city boss is defeated, at the earliest
|
||||||
Painter.fill( level, this, 1, Terrain.EMPTY_SP );
|
//but we want to decide the items as part of levelgen
|
||||||
Painter.fill( level, this, 3, Terrain.WATER);
|
if (itemsToSpawn == null) {
|
||||||
|
itemsToSpawn = generateItems();
|
||||||
for (Door door : connected.values()) {
|
|
||||||
door.set( Door.Type.REGULAR );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Imp.Quest.isCompleted()){
|
|
||||||
spawnShop(level);
|
|
||||||
} else {
|
|
||||||
impSpawned = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -111,17 +105,22 @@ public class ImpShopRoom extends ShopRoom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final String IMP = "imp_spawned";
|
private static final String IMP = "imp_spawned";
|
||||||
|
private static final String ITEMS = "items";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeInBundle(Bundle bundle) {
|
public void storeInBundle(Bundle bundle) {
|
||||||
super.storeInBundle(bundle);
|
super.storeInBundle(bundle);
|
||||||
bundle.put(IMP, impSpawned);
|
bundle.put(IMP, impSpawned);
|
||||||
|
if (itemsToSpawn != null) bundle.put(ITEMS, itemsToSpawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreFromBundle(Bundle bundle) {
|
public void restoreFromBundle(Bundle bundle) {
|
||||||
super.restoreFromBundle(bundle);
|
super.restoreFromBundle(bundle);
|
||||||
impSpawned = bundle.getBoolean(IMP);
|
impSpawned = bundle.getBoolean(IMP);
|
||||||
|
if (bundle.contains( ITEMS )) {
|
||||||
|
itemsToSpawn = new ArrayList<>((Collection<Item>) ((Collection<?>) bundle.getCollection(ITEMS)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user