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/gamecore/gui/Action.java

51 lines
684 B

package mightypork.gamecore.gui;
/**
* Triggered action
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class Action implements Runnable, Enableable {
private boolean enabled = true;
/**
* Enable the action
*
* @param enable true to enable
*/
@Override
public final void setEnabled(boolean enable)
{
this.enabled = enable;
}
/**
* @return true if this action is enabled.
*/
@Override
public final boolean isEnabled()
{
return enabled;
}
/**
* Run the action, if it's enabled.
*/
@Override
public final void run()
{
if (enabled) execute();
}
/**
* Do the work.
*/
protected abstract void execute();
}