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

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

	if (bundle.contains( CUR )) {

		cur = new int[bundle.getInt(LENGTH)];
		off = new int[cur.length];

		int[] data = bundle.getIntArray(CUR);
		int start = bundle.getInt(START);
		for (int i = 0; i < data.length; i++) {
			cur[i + start] = data[i];
			volume += data[i];
		}

	}
}
 
Example 2
Source File: Blob.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 );

	if (bundle.contains( CUR )) {

		cur = new int[bundle.getInt(LENGTH)];
		off = new int[cur.length];

		int[] data = bundle.getIntArray(CUR);
		int start = bundle.getInt(START);
		for (int i = 0; i < data.length; i++) {
			cur[i + start] = data[i];
			volume += data[i];
		}

	}
}
 
Example 3
Source File: YogDzewa.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);
	phase = bundle.getInt(PHASE);
	if (phase != 0) BossHealthBar.assignBoss(this);

	abilityCooldown = bundle.getFloat(ABILITY_CD);
	summonCooldown = bundle.getFloat(SUMMON_CD);

	fistSummons.clear();
	Collections.addAll(fistSummons, bundle.getClassArray(FIST_SUMMONS));
	regularSummons.clear();
	Collections.addAll(regularSummons, bundle.getClassArray(REGULAR_SUMMONS));

	for (int i : bundle.getIntArray(TARGETED_CELLS)){
		targetedCells.add(i);
	}
}
 
Example 4
Source File: TimekeepersHourglass.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);

	int[] values = bundle.getIntArray( PRESSES );
	for (int value : values)
		presses.add(value);

	turnsToCost = bundle.getFloat( TURNSTOCOST );
}
 
Example 5
Source File: TimekeepersHourglass.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);

	int[] values = bundle.getIntArray( PRESSES );
	for (int value : values)
		presses.add(value);

	turnsToCost = bundle.getFloat( TURNSTOCOST );
}
 
Example 6
Source File: Swiftthistle.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);
	
	int[] values = bundle.getIntArray( PRESSES );
	for (int value : values)
		presses.add(value);
	
	left = bundle.getFloat(LEFT);
}
 
Example 7
Source File: SecretRoom.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreRoomsFromBundle( Bundle bundle ) {
	runSecrets.clear();
	if (bundle.contains( ROOMS )) {
		for (Class<? extends SecretRoom> type : bundle.getClassArray(ROOMS)) {
			if (type != null) runSecrets.add(type);
		}
		regionSecretsThisRun = bundle.getIntArray(REGIONS);
	} else {
		initForRun();
		ShatteredPixelDungeon.reportException(new Exception("secrets array didn't exist!"));
	}
}
 
Example 8
Source File: Blob.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);

	int[] data = bundle.getIntArray(CUR);

	int start = bundle.getInt(START);
	for (int i = 0; i < data.length; i++) {
		cur[i + start] = data[i];
		volume += data[i];
	}
}
 
Example 9
Source File: Swiftthistle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);
	
	int[] values = bundle.getIntArray( PRESSES );
	for (int value : values)
		presses.add(value);
	
	left = bundle.getFloat(LEFT);
}
 
Example 10
Source File: SecretRoom.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void restoreRoomsFromBundle( Bundle bundle ) {
	runSecrets.clear();
	if (bundle.contains( ROOMS )) {
		for (Class<? extends SecretRoom> type : bundle.getClassArray(ROOMS)) {
			if (type != null) runSecrets.add(type);
		}
		regionSecretsThisRun = bundle.getIntArray(REGIONS);
	} else {
		initForRun();
		ShatteredPixelDungeon.reportException(new Exception("secrets array didn't exist!"));
	}
}
 
Example 11
Source File: TimekeepersHourglass.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);

	int[] values = bundle.getIntArray( PRESSES );
	for (int value : values)
		presses.add(value);

	partialTime = bundle.getFloat( PARTIALTIME );
}
 
Example 12
Source File: Level.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {

       heaps = new SparseArray<Heap>();
       hazards = new HashSet<Hazard>();
       mobs = new HashSet<Mob>();
       blobs = new HashMap<Class<? extends Blob>, Blob>();

	map		= bundle.getIntArray( MAP );
	visited	= bundle.getBooleanArray( VISITED );
	mapped	= bundle.getBooleanArray( MAPPED );

	mobsSpawned = bundle.getInt(MOBS_SPAWNED);

	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( heap != null ){
               if( resizingNeeded ){
                   heap.pos = adjustPos( heap.pos );
               }
               heaps.put( heap.pos, heap );
           }
	}

	collection = bundle.getCollection( HAZARDS );
	for (Bundlable z : collection) {
           Hazard hazard = (Hazard)z;
           if (hazard != null){
               if( resizingNeeded ){
                   hazard.pos = adjustPos( hazard.pos );
               }
               hazards.add( hazard );
           }
	}

	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();
}
 
Example 13
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 14
Source File: Level.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {

	scripts = new HashSet<>();
	mobs = new HashSet<>();
	heaps = new SparseArray<>();
	blobs = new HashMap<>();

	width = bundle.optInt(WIDTH, 32); // old levels compat
	height = bundle.optInt(HEIGHT, 32);

	initSizeDependentStuff();

	map = bundle.getIntArray(MAP);

	for(LayerId layerId: LayerId.values()) {
		int [] layer = bundle.getIntArray(layerId.name());
		if(layer.length == map.length) {
			customLayers.put(layerId, layer);
		}
	}

	visited = bundle.getBooleanArray(VISITED);
	mapped = bundle.getBooleanArray(MAPPED);

	entrance = bundle.getInt(ENTRANCE);
	compassTarget = bundle.optInt(COMPASS_TARGET, INVALID_CELL);

	int[] exits = bundle.getIntArray(EXIT);
	if (exits.length > 0) {
		for (int i = 0; i < exits.length; ++i) {
			setExit(exits[i], i);
		}
	} else {
		setExit(bundle.getInt(EXIT), 0);
		int secondaryExit = bundle.optInt(SECONDARY_EXIT, INVALID_CELL);
		if (cellValid(secondaryExit)) {
			setExit(secondaryExit, 1);
		}
	}

	weakFloorCreated = false;

	for (Heap heap : bundle.getCollection(HEAPS, Heap.class)) {
		heaps.put(heap.pos, heap);
	}


	///Pre 28.6 saves compatibility
	for (Plant plant : bundle.getCollection(PLANTS, Plant.class)) {
		putLevelObject(plant);
	}

	for (LevelObject object : bundle.getCollection(OBJECTS, LevelObject.class)) {
		putLevelObject(object);
	}

	var loadedMobs = bundle.getCollection(MOBS, Mob.class);

	for (Mob mob : loadedMobs) {
		if (mob != null && cellValid(mob.getPos())) {
			mobs.add(mob);
		}
	}

	for (Blob blob : bundle.getCollection(BLOBS, Blob.class)) {
		blobs.put(blob.getClass(), blob);
	}

	for (ScriptedActor actor : bundle.getCollection(SCRIPTS, ScriptedActor.class)) {
		addScriptedActor(actor);
	}

	buildFlagMaps();
	cleanWalls();
}
 
Example 15
Source File: NewTengu.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);
	direction = bundle.getInt( DIRECTION );
	curCells = bundle.getIntArray( CUR_CELLS );
}
 
Example 16
Source File: NewTengu.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);
	direction = bundle.getInt( DIRECTION );
	curCells = bundle.getIntArray( CUR_CELLS );
}
 
Example 17
Source File: Level.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@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();
}
 
Example 18
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 );
		}
	}
}