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

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

	String state = bundle.getString(STATE);
	setState(state);

	fraction = Fraction.values()[bundle.optInt(FRACTION, Fraction.DUNGEON.ordinal())];

	if (bundle.contains(LOOT)) {
		loot = bundle.get(LOOT);
		lootChance = 1;
	}
}
 
Example 2
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 3
Source File: MultiKindMob.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);
	kind = bundle.optInt(KIND_TAG, 0);
}
 
Example 4
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();
}