Java Code Examples for com.watabou.utils.Bundle#getBundle()

The following examples show how to use com.watabou.utils.Bundle#getBundle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Ghost.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {
	
	Bundle node = bundle.getBundle( NODE );

	if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {

		type = node.getInt(TYPE);
		given	= node.getBoolean( GIVEN );
		processed = node.getBoolean( PROCESSED );

		depth	= node.getInt( DEPTH );
		
		weapon	= (Weapon)node.get( WEAPON );
		armor	= (Armor)node.get( ARMOR );
	} else {
		reset();
	}
}
 
Example 2
Source File: TimekeepersHourglass.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	super.restoreFromBundle(bundle);
	sandBags = bundle.getInt( SANDBAGS );

	//these buffs belong to hourglass, need to handle unbundling within the hourglass class.
	if (bundle.contains( BUFF )){
		Bundle buffBundle = bundle.getBundle( BUFF );

		if (buffBundle.contains( timeFreeze.PRESSES ))
			activeBuff = new timeFreeze();
		else
			activeBuff = new timeStasis();

		activeBuff.restoreFromBundle(buffBundle);
	}
}
 
Example 3
Source File: Rankings.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	if (bundle.contains( CAUSE )) {
		cause   = bundle.getClass( CAUSE );
	} else {
		cause = null;
	}
	
	win		= bundle.getBoolean( WIN );
	score	= bundle.getInt( SCORE );
	
	heroClass	= HeroClass.restoreInBundle( bundle );
	armorTier	= bundle.getInt( TIER );
	
	if (bundle.contains(DATA))  gameData = bundle.getBundle(DATA);
	if (bundle.contains(ID))   gameID = bundle.getString(ID);
	
	if (gameID == null) gameID = UUID.randomUUID().toString();

	depth = bundle.getInt( DEPTH );
	herolevel = bundle.getInt( LEVEL );

}
 
Example 4
Source File: Ghost.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {
	
	Bundle node = bundle.getBundle( NODE );

	if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {

		type = node.getInt(TYPE);
		given	= node.getBoolean( GIVEN );
		processed = node.getBoolean( PROCESSED );

		depth	= node.getInt( DEPTH );
		
		weapon	= (Weapon)node.get( WEAPON );
		armor	= (Armor)node.get( ARMOR );
	} else {
		reset();
	}
}
 
Example 5
Source File: TimekeepersHourglass.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	super.restoreFromBundle(bundle);
	sandBags = bundle.getInt( SANDBAGS );

	//these buffs belong to hourglass, need to handle unbundling within the hourglass class.
	if (bundle.contains( BUFF )){
		Bundle buffBundle = bundle.getBundle( BUFF );

		if (buffBundle.contains( timeFreeze.PRESSES ))
			activeBuff = new timeFreeze();
		else
			activeBuff = new timeStasis();

		activeBuff.restoreFromBundle(buffBundle);
	}
}
 
Example 6
Source File: TimekeepersHourglass.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	super.restoreFromBundle(bundle);
	sandBags = bundle.getInt( SANDBAGS );

	//these buffs belong to hourglass, need to handle unbundling within the hourglass class.
	if (bundle.contains( BUFF )){
		Bundle buffBundle = bundle.getBundle( BUFF );

		if (buffBundle.contains( timeFreeze.PARTIALTIME ))
			activeBuff = new timeFreeze();
		else
			activeBuff = new timeStasis();

		activeBuff.restoreFromBundle(buffBundle);
	}
}
 
Example 7
Source File: PlagueDoctorNPC.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreFromBundle(Bundle bundle) {

			Bundle node = bundle.getBundle(NODE);

			if (!node.isNull()) {
				given = node.getBoolean(GIVEN);
				depth = node.getInt(DEPTH);
				processed = node.getBoolean(PROCESSED);
				completed = node.getBoolean(COMPLETED);
			}
		}
 
Example 8
Source File: Imp.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );
			
			if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
				alternative	= node.getBoolean( ALTERNATIVE );
				
				given = node.getBoolean( GIVEN );
				completed = node.getBoolean( COMPLETED );
				reward = (Ring)node.get( REWARD );
			}
		}
 
Example 9
Source File: Blacksmith.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );
			
			if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
				alternative	=  node.getBoolean( ALTERNATIVE );
				given = node.getBoolean( GIVEN );
				completed = node.getBoolean( COMPLETED );
				reforged = node.getBoolean( REFORGED );
			} else {
				reset();
			}
		}
 
Example 10
Source File: Blacksmith.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );
			
			if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
				alternative	=  node.getBoolean( ALTERNATIVE );
				given = node.getBoolean( GIVEN );
				completed = node.getBoolean( COMPLETED );
				reforged = node.getBoolean( REFORGED );
			} else {
				reset();
			}
		}
 
Example 11
Source File: WandMaker.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );
			
			if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
				
				alternative	=  node.getBoolean( ALTERNATIVE );
				given = node.getBoolean( GIVEN );
			} else {
				reset();
			}
		}
 
Example 12
Source File: CagedKobold.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );

			if (!node.isNull() ) {
				given	= node.getBoolean( GIVEN );
				depth	= node.getInt( DEPTH );
				processed	= node.getBoolean( PROCESSED );
				completed = node.getBoolean( COMPLETED );
				spawned = node.getBoolean( SPAWNED );
			}
		}
 
Example 13
Source File: Imp.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );
			
			if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
				alternative	= node.getBoolean( ALTERNATIVE );
				
				given = node.getBoolean( GIVEN );
				completed = node.getBoolean( COMPLETED );
				reward = (Ring)node.get( REWARD );
			}
		}
 
Example 14
Source File: NecromancerNPC.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);

	Bundle node = bundle.getBundle(NODE);

	if(node.isNull()){
		return;
	}

	introduced = node.optBoolean(INTRODUCED, false);
}
 
Example 15
Source File: Blacksmith.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );
			
			if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
				alternative	=  node.getBoolean( ALTERNATIVE );
				given = node.getBoolean( GIVEN );
				completed = node.getBoolean( COMPLETED );
				reforged = node.getBoolean( REFORGED );
			} else {
				reset();
			}
		}
 
Example 16
Source File: Wandmaker.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );
			
			if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
				
				alternative	=  node.getBoolean( ALTERNATIVE );
				
				given = node.getBoolean( GIVEN );
				
				wand1 = (Wand)node.get( WAND1 );
				wand2 = (Wand)node.get( WAND2 );
			} else {
				reset();
			}
		}
 
Example 17
Source File: Wandmaker.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );
			
			if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {

				type = node.getInt(TYPE);
				
				given = node.getBoolean( GIVEN );
				
				wand1 = (Wand)node.get( WAND1 );
				wand2 = (Wand)node.get( WAND2 );

				if (type == 2){
					CeremonialCandle.ritualPos = node.getInt( RITUALPOS );
				}

			} else {
				reset();
			}
		}
 
Example 18
Source File: Dungeon.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
private static void loadGameFromBundle(Bundle bundle, boolean fullLoad) {

        if(!bundle.optString("mod","Remixed").equals(ModdingMode.activeMod())) {
            EventCollector.logException(new Exception("loading save from another mod"));
        }

        Dungeon.gameId = bundle.optString(GAME_ID, Utils.UNKNOWN);
        EntityIdSource.setLastUsedId(bundle.optInt(LAST_USED_ID,1));

        Treasury.reset();

        Scroll.restore(bundle);
        Potion.restore(bundle);
        Wand.restore(bundle);
        Ring.restore(bundle);
        QuickSlot.restore(bundle);

        potionOfStrength = bundle.getInt(POS);
        scrollsOfUpgrade = bundle.getInt(SOU);
        arcaneStyli = bundle.getInt(AS);
        dewVial = bundle.getBoolean(DV);
        transmutation = bundle.getInt(WT);

        realtime = bundle.getBoolean(REALTIME);
        setChallenges(bundle.optInt(CHALLENGES,0));

        if (fullLoad) {
            chapters = new HashSet<>();
            int[] ids = bundle.getIntArray(CHAPTERS);
            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);
                AzuterronNPC.Quest.restoreFromBundle(quests);
                ScarecrowNPC.Quest.restoreFromBundle(quests);
                CagedKobold.Quest.restoreFromBundle(quests);
                PlagueDoctorNPC.Quest.restoreFromBundle(quests);
            } else {
                Ghost.Quest.reset();
                WandMaker.Quest.reset();
                Blacksmith.Quest.reset();
                Imp.Quest.reset();
                AzuterronNPC.Quest.reset();
                ScarecrowNPC.Quest.reset();
                CagedKobold.Quest.reset();
                PlagueDoctorNPC.Quest.reset();
            }

            Room.restoreRoomsFromBundle(bundle);
        }

        Bundle badges = bundle.getBundle(BADGES);
        if (!badges.isNull()) {
            Badges.loadLocal(badges);
        } else {
            Badges.reset();
        }

        @SuppressWarnings("unused")
        String version = bundle.getString(VERSION);

        hero = (Hero) bundle.get(HERO);
        if(hero==null) {
            throw new TrackedRuntimeException("no hero in bundle");
        }

        depth = bundle.getInt(DEPTH);

        Statistics.restoreFromBundle(bundle);
        Journal.restoreFromBundle(bundle);
        Logbook.restoreFromBundle(bundle);
        LuaEngine.getEngine().require(LuaEngine.SCRIPTS_LIB_STORAGE).get("deserializeGameData").call(bundle.getString(SCRIPTS_DATA));

        moveTimeoutIndex = RemixedDungeon.limitTimeoutIndex(bundle.optInt(MOVE_TIMEOUT, Integer.MAX_VALUE));
    }
 
Example 19
Source File: Dungeon.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
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 );
		}
	}
}
 
Example 20
Source File: Wandmaker.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void restoreFromBundle( Bundle bundle ) {

			Bundle node = bundle.getBundle( NODE );
			
			if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {

				type = node.getInt(TYPE);
				
				given = node.getBoolean( GIVEN );
				
				wand1 = (Wand)node.get( WAND1 );
				wand2 = (Wand)node.get( WAND2 );

				if (type == 2){
					CeremonialCandle.ritualPos = node.getInt( RITUALPOS );
				}

			} else {
				reset();
			}
		}