package mightypork.gamecore.core.events;
import mightypork.gamecore.core.App;
import mightypork.utils.eventbus.BusEvent;
import mightypork.utils.eventbus.EventBus;
import mightypork.utils.logging.Log;
/**
* Shutdown event.
* This event is dispatched when the App.shutdown()
method is
* called. If no client consumes it, the shutdown will immediately follow.
* This is a way to allow clients to abort the shutdown (ie. ask to save game).
*
* @author Ondřej Hruška (MightyPork)
*/
public class ShutdownRequest extends BusEvent {
@Override
protected void handleBy(ShutdownRequestListener handler)
{
handler.onShutdownRequested(this);
}
@Override
public void onDispatchComplete(EventBus bus)
{
if (!isConsumed()) {
Log.i("Shutting down...");
App.shutdown();
} else {
Log.i("Shutdown aborted.");
}
}
}