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

The following examples show how to use com.watabou.utils.Bundle#optString() . 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: CustomBuff.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);
    initFromFile(scriptFile);

    String luaData = bundle.optString(LuaEngine.LUA_DATA,null);
    if(luaData!=null) {
        script.run("loadData",luaData);
    }
}
 
Example 2
Source File: CustomMob.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	fillMobStats(true);

	super.restoreFromBundle(bundle);

	String luaData = bundle.optString(LuaEngine.LUA_DATA,null);
	if(luaData!=null) {
		script.run("loadData",luaData);
	}
	script.run("fillStats");
}
 
Example 3
Source File: CustomItem.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);
    initItem();

    String luaData = bundle.optString(LuaEngine.LUA_DATA,null);
    if(luaData!=null) {
        script.run("loadData",luaData);
    }
}
 
Example 4
Source File: Rankings.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	info	= bundle.getString  ( REASON );
	win		= bundle.getBoolean ( WIN    );
	score	= bundle.getInt     ( SCORE  );
	
	heroClass	= HeroClass.restoreFromBundle(bundle);

	gameFile	= bundle.getString( GAME );
	mod			= bundle.optString(MOD, ModdingMode.REMIXED);
}
 
Example 5
Source File: Key.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 );
	levelId = bundle.optString(LEVELID, Utils.UNKNOWN);
	depth = bundle.optInt( DEPTH,DungeonGenerator.getLevelDepth(levelId) );

}
 
Example 6
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));
    }