Versatile Java game engine with pluggable backends (this was used in Rogue, I think)
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.

55 lines
746 B

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