use of com.watabou.utils.Bundlable in project pixel-dungeon by watabou.
the class Dungeon method loadGame.
public static void loadGame(String fileName, boolean fullLoad) throws IOException {
Bundle bundle = gameBundle(fileName);
Dungeon.challenges = bundle.getInt(CHALLENGES);
Dungeon.level = null;
Dungeon.depth = -1;
if (fullLoad) {
PathFinder.setMapSize(Level.WIDTH, Level.HEIGHT);
}
Scroll.restore(bundle);
Potion.restore(bundle);
Wand.restore(bundle);
Ring.restore(bundle);
potionOfStrength = bundle.getInt(POS);
scrollsOfUpgrade = bundle.getInt(SOU);
scrollsOfEnchantment = bundle.getInt(SOE);
dewVial = bundle.getBoolean(DV);
if (fullLoad) {
chapters = new HashSet<Integer>();
int[] ids = bundle.getIntArray(CHAPTERS);
if (ids != null) {
for (int id : ids) {
chapters.add(id);
}
}
Bundle quests = bundle.getBundle(QUESTS);
if (!quests.isNull()) {
Ghost.Quest.restoreFromBundle(quests);
Wandmaker.Quest.restoreFromBundle(quests);
Blacksmith.Quest.restoreFromBundle(quests);
Imp.Quest.restoreFromBundle(quests);
} else {
Ghost.Quest.reset();
Wandmaker.Quest.reset();
Blacksmith.Quest.reset();
Imp.Quest.reset();
}
Room.restoreRoomsFromBundle(bundle);
}
Bundle badges = bundle.getBundle(BADGES);
if (!badges.isNull()) {
Badges.loadLocal(badges);
} else {
Badges.reset();
}
QuickSlot.restore(bundle);
@SuppressWarnings("unused") String version = bundle.getString(VERSION);
hero = null;
hero = (Hero) bundle.get(HERO);
QuickSlot.compress();
gold = bundle.getInt(GOLD);
depth = bundle.getInt(DEPTH);
Statistics.restoreFromBundle(bundle);
Journal.restoreFromBundle(bundle);
droppedItems = new SparseArray<ArrayList<Item>>();
for (int i = 2; i <= Statistics.deepestFloor + 1; i++) {
ArrayList<Item> dropped = new ArrayList<Item>();
for (Bundlable b : bundle.getCollection(String.format(DROPPED, i))) {
dropped.add((Item) b);
}
if (!dropped.isEmpty()) {
droppedItems.put(i, dropped);
}
}
}
use of com.watabou.utils.Bundlable in project pixel-dungeon by watabou.
the class Char method restoreFromBundle.
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
pos = bundle.getInt(POS);
HP = bundle.getInt(TAG_HP);
HT = bundle.getInt(TAG_HT);
for (Bundlable b : bundle.getCollection(BUFFS)) {
if (b != null) {
((Buff) b).attachTo(this);
}
}
}
use of com.watabou.utils.Bundlable in project pixel-dungeon by watabou.
the class Level method restoreFromBundle.
@Override
public void restoreFromBundle(Bundle bundle) {
mobs = new HashSet<Mob>();
heaps = new SparseArray<Heap>();
blobs = new HashMap<Class<? extends Blob>, Blob>();
plants = new SparseArray<Plant>();
map = bundle.getIntArray(MAP);
visited = bundle.getBooleanArray(VISITED);
mapped = bundle.getBooleanArray(MAPPED);
entrance = bundle.getInt(ENTRANCE);
exit = bundle.getInt(EXIT);
weakFloorCreated = false;
adjustMapSize();
Collection<Bundlable> collection = bundle.getCollection(HEAPS);
for (Bundlable h : collection) {
Heap heap = (Heap) h;
if (resizingNeeded) {
heap.pos = adjustPos(heap.pos);
}
heaps.put(heap.pos, heap);
}
collection = bundle.getCollection(PLANTS);
for (Bundlable p : collection) {
Plant plant = (Plant) p;
if (resizingNeeded) {
plant.pos = adjustPos(plant.pos);
}
plants.put(plant.pos, plant);
}
collection = bundle.getCollection(MOBS);
for (Bundlable m : collection) {
Mob mob = (Mob) m;
if (mob != null) {
if (resizingNeeded) {
mob.pos = adjustPos(mob.pos);
}
mobs.add(mob);
}
}
collection = bundle.getCollection(BLOBS);
for (Bundlable b : collection) {
Blob blob = (Blob) b;
blobs.put(blob.getClass(), blob);
}
buildFlagMaps();
cleanWalls();
}
Aggregations