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

The following examples show how to use com.watabou.utils.Bundle#getEnum() . 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: Armor.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);
	usesLeftToID = bundle.getInt( USES_LEFT_TO_ID );
	availableUsesToID = bundle.getInt( AVAILABLE_USES );
	inscribe((Glyph) bundle.get(GLYPH));
	curseInfusionBonus = bundle.getBoolean( CURSE_INFUSION_BONUS );
	seal = (BrokenSeal)bundle.get(SEAL);
	
	//pre-0.7.2 saves
	if (bundle.contains( "unfamiliarity" )){
		usesLeftToID = bundle.getInt( "unfamiliarity" );
		availableUsesToID = USES_TO_ID/2f;
	}
	
	augment = bundle.getEnum(AUGMENT, Augment.class);
}
 
Example 2
Source File: Armor.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);
	usesLeftToID = bundle.getInt( USES_LEFT_TO_ID );
	availableUsesToID = bundle.getInt( AVAILABLE_USES );
	inscribe((Glyph) bundle.get(GLYPH));
	curseInfusionBonus = bundle.getBoolean( CURSE_INFUSION_BONUS );
	seal = (BrokenSeal)bundle.get(SEAL);
	
	//pre-0.7.2 saves
	if (bundle.contains( "unfamiliarity" )){
		usesLeftToID = bundle.getInt( "unfamiliarity" );
		availableUsesToID = USES_TO_ID/2f;
	}
	
	augment = bundle.getEnum(AUGMENT, Augment.class);
}
 
Example 3
Source File: OldPrisonBossLevel.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);
	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.MAZE) {
		tengu = (OldTengu)bundle.get( TENGU );
	} else {
		for (Mob mob : mobs){
			if (mob instanceof OldTengu) {
				tengu = (OldTengu) mob;
				break;
			}
		}
	}

	for (Bundlable item : bundle.getCollection(STORED_ITEMS)){
		storedItems.add( (Item)item );
	}
}
 
Example 4
Source File: Berserk.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);
	//pre-0.6.5 saves
	if (bundle.contains("exhaustion")){
		state = State.RECOVERING;
	} else {
		state = bundle.getEnum(STATE, State.class);
	}
	if (bundle.contains(POWER)){
		power = bundle.getFloat(POWER);
	} else {
		power = 1f;
	}
	if (state == State.RECOVERING) levelRecovery = bundle.getFloat(LEVEL_RECOVERY);
}
 
Example 5
Source File: Weapon.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 );
	usesLeftToID = bundle.getInt( USES_LEFT_TO_ID );
	availableUsesToID = bundle.getInt( AVAILABLE_USES );
	enchantment = (Enchantment)bundle.get( ENCHANTMENT );
	curseInfusionBonus = bundle.getBoolean( CURSE_INFUSION_BONUS );
	
	//pre-0.7.2 saves
	if (bundle.contains( "unfamiliarity" )){
		usesLeftToID = bundle.getInt( "unfamiliarity" );
		availableUsesToID = USES_TO_ID/2f;
	}
	
	augment = bundle.getEnum(AUGMENT, Augment.class);
}
 
Example 6
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 7
Source File: OldPrisonBossLevel.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.MAZE) {
		tengu = (OldTengu)bundle.get( TENGU );
	} else {
		for (Mob mob : mobs){
			if (mob instanceof OldTengu) {
				tengu = (OldTengu) mob;
				break;
			}
		}
	}

	for (Bundlable item : bundle.getCollection(STORED_ITEMS)){
		storedItems.add( (Item)item );
	}
}
 
Example 8
Source File: Berserk.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);
	//pre-0.6.5 saves
	if (bundle.contains("exhaustion")){
		state = State.RECOVERING;
	} else {
		state = bundle.getEnum(STATE, State.class);
	}
	if (bundle.contains(POWER)){
		power = bundle.getFloat(POWER);
	} else {
		power = 1f;
	}
	if (state == State.RECOVERING) levelRecovery = bundle.getFloat(LEVEL_RECOVERY);
}
 
Example 9
Source File: Ghost.java    From 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.getEnum( TYPE, Type.class );
		if (type == Type.ILLEGAL) {
			type = node.getBoolean( ALTERNATIVE ) ? Type.RAT : Type.ROSE;
		}
		if (type == Type.ROSE) {
			left2kill = node.getInt( LEFT2KILL );
		}
		
		given	= node.getBoolean( GIVEN );
		depth	= node.getInt( DEPTH );
		processed	= node.getBoolean( PROCESSED );
		
		weapon	= (Weapon)node.get( WEAPON );
		armor	= (Armor)node.get( ARMOR );
	} else {
		reset();
	}
}
 
Example 10
Source File: Wandmaker.java    From 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.getEnum( TYPE, Type.class );
				if (type == Type.ILLEGAL) {
					type = node.getBoolean( ALTERNATIVE ) ? Type.DUST : Type.BERRY;
				}
				
				given = node.getBoolean( GIVEN );
				
				wand1 = (Wand)node.get( WAND1 );
				wand2 = (Wand)node.get( WAND2 );
			} else {
				reset();
			}
		}
 
Example 11
Source File: Weapon.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);
	if ((hitsToKnow = bundle.getInt( UNFAMILIRIARITY )) == 0) {
		hitsToKnow = HITS_TO_KNOW;
	}
	enchantment = (Enchantment)bundle.get( ENCHANTMENT );
	imbue = bundle.getEnum( IMBUE, Imbue.class );
}
 
Example 12
Source File: Bee.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 );
	spawn( bundle.getInt( LEVEL ) );
	potPos = bundle.getInt( POTPOS );
	potHolder = bundle.getInt( POTHOLDER );
	if (bundle.contains(ALIGMNENT)) alignment = bundle.getEnum( ALIGMNENT, Alignment.class);
}
 
Example 13
Source File: Bee.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 );
	spawn( bundle.getInt( LEVEL ) );
	potPos = bundle.getInt( POTPOS );
	potHolder = bundle.getInt( POTHOLDER );
	if (bundle.contains(ALIGMNENT)) alignment = bundle.getEnum( ALIGMNENT, Alignment.class);
}
 
Example 14
Source File: Weapon.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	super.restoreFromBundle( bundle );
	if ((hitsToKnow = bundle.getInt( UNFAMILIRIARITY )) == 0) {
		hitsToKnow = HITS_TO_KNOW;
	}
	enchantment = (Enchantment)bundle.get( ENCHANTMENT );
	imbue = bundle.getEnum( IMBUE, Imbue.class );
}
 
Example 15
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 16
Source File: Room.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void restoreFromBundle(Bundle bundle) {
	x = bundle.getInt("x");
	y = bundle.getInt("y");
	type = bundle.getEnum("type", Type.class);
}
 
Example 17
Source File: Pylon.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);
	alignment = bundle.getEnum(ALIGNMENT, Alignment.class);
	targetNeighbor = bundle.getInt(TARGET_NEIGHBOUR);
}
 
Example 18
Source File: Room.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void restoreFromBundle( Bundle bundle ) {
	type   = bundle.getEnum("type", Type.class, Type.STANDARD);
}
 
Example 19
Source File: Weapon.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 );
	imbue = bundle.getEnum( IMBUE, Imbue.class );
}
 
Example 20
Source File: Room.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) {
	x = bundle.getInt("x");
	y = bundle.getInt("y");
	type = bundle.getEnum("type", Type.class);
}