Rogue: Savage Rats, a retro-themed dungeon crawler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
rogue-savage-rats/src/mightypork/rogue/world/events/WorldPauseRequest.java

53 lines
755 B

package mightypork.rogue.world.events;
import mightypork.rogue.world.World;
import mightypork.utils.eventbus.BusEvent;
/**
* Toggle world pause state
*
* @author Ondřej Hruška (MightyPork)
*/
public class WorldPauseRequest extends BusEvent<World> {
public static enum PauseAction
{
PAUSE, RESUME, TOGGLE;
}
private final PauseAction op;
public WorldPauseRequest(PauseAction op)
{
super();
this.op = op;
}
@Override
protected void handleBy(World handler)
{
if (op == PauseAction.PAUSE) {
handler.pause();
return;
}
if (op == PauseAction.RESUME) {
handler.resume();
return;
}
// else
// toggle paused state
if (!handler.isPaused()) {
handler.pause();
} else {
handler.resume();
}
}
}