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

The following examples show how to use com.watabou.utils.Bundle#getBooleanArray() . 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: NewPrisonBossLevel.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);
	state = bundle.getEnum( STATE, State.class );
	
	//in some states tengu won't be in the world, in others he will be.
	if (state == State.START || state == State.TRAP_MAZES || state == State.FIGHT_PAUSE) {
		tengu = (NewTengu)bundle.get( TENGU );
	} else {
		for (Mob mob : mobs){
			if (mob instanceof NewTengu) {
				tengu = (NewTengu) mob;
				break;
			}
		}
	}
	
	for (Bundlable item : bundle.getCollection(STORED_ITEMS)){
		storedItems.add( (Item)item );
	}
	
	triggered = bundle.getBooleanArray(TRIGGERED);
	
}
 
Example 2
Source File: QuickSlot.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void restorePlaceholders(Bundle bundle){
	Collection<Bundlable> placeholders = bundle.getCollection(PLACEHOLDERS);
	boolean[] placements = bundle.getBooleanArray( PLACEMENTS );

	int i = 0;
	for (Bundlable item : placeholders){
		while (!placements[i]) i++;
		setSlot( i, (Item)item );
		i++;
	}

}
 
Example 3
Source File: QuickSlot.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void restorePlaceholders(Bundle bundle){
	Collection<Bundlable> placeholders = bundle.getCollection(PLACEHOLDERS);
	boolean[] placements = bundle.getBooleanArray( PLACEMENTS );

	int i = 0;
	for (Bundlable item : placeholders){
		while (!placements[i]) i++;
		setSlot( i, (Item)item );
		i++;
	}

}
 
Example 4
Source File: NewPrisonBossLevel.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);
	state = bundle.getEnum( STATE, State.class );
	
	//in some states tengu won't be in the world, in others he will be.
	if (state == State.START || state == State.TRAP_MAZES) {
		tengu = (NewTengu)bundle.get( TENGU );
	} else {
		for (Mob mob : mobs){
			if (mob instanceof NewTengu) {
				tengu = (NewTengu) mob;
				break;
			}
		}
	}
	
	for (Bundlable item : bundle.getCollection(STORED_ITEMS)){
		storedItems.add( (Item)item );
	}
	
	triggered = bundle.getBooleanArray(TRIGGERED);
	
	//compatibility with pre-0.7.5a saves
	if (state == State.WON){
		int cell = pointToCell(endStart);
		int i = 0;
		while (cell < length()){
			System.arraycopy(endMap, i, map, cell, 14);
			i += 14;
			cell += width();
		}
		exit = pointToCell(levelExit);
	}
}
 
Example 5
Source File: QuickSlot.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public void restorePlaceholders(Bundle bundle){
	Collection<Bundlable> placeholders = bundle.getCollection(PLACEHOLDERS);
	boolean[] placements = bundle.getBooleanArray( PLACEMENTS );

	int i = 0;
	for (Bundlable item : placeholders){
		while (!placements[i]) i++;
		setSlot( i, (Item)item );
		i++;
	}

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