|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sourceforge.worldsaver.rp.RpBase | +--net.sourceforge.worldsaver.rp.Action
This is the abstract superclass of all actions. The subclasses must provide the methods isRunnable(), execute(), step() and createActionTree(). Since the creation of the action class is the most complicated task in this framework, it's better to put even slightly different actions in extra classes. It makes the communication and the handling greatly easier.
Fields inherited from interface net.sourceforge.worldsaver.util.MiscUtils |
CONSOLE_WIDTH, NEWLINE, RANDOM |
Constructor Summary | |
Action(java.util.HashMap loaded)
Creates a new action of a loaded String. |
|
Action(RpBase father,
java.lang.String name)
Creates a new action with a father and a name. |
Method Summary | |
abstract void |
createActionTree(ActionParticle top)
Sets the ActionTree that shall be used for the action. |
abstract void |
execute()
Prepares the action for execution. |
protected ActionParticle |
getActionTree()
Returns the top of the actiontree (used for saving purposes). |
java.lang.String[] |
getDecisionMessage()
If the action is running, this gets the current decision messages. |
Area |
getLocation()
This returns the current location the running action takes place. |
void |
getReferencesRight(java.util.HashMap pool,
IDGenerator gen)
Must set the references right by getting the real objects out of the pool. |
java.lang.String |
getSaveableString()
Returns a saveable String describing this object. |
Area |
getStartLocation()
Returns the current start location. |
java.lang.String |
getText()
This returns (when running) the text explaining the current situation. |
abstract boolean |
isRunnable()
Returns whether the action is prepared to be executed. |
boolean |
isRunning()
If the execute() method is invoked and running, this returns true. |
void |
setStartLocation(Area loc)
Sets the new location where the action starts. loc may be null if the location doesn't matter. |
abstract void |
step(int index)
Causes the action to do a step in a specific direction. |
Methods inherited from class net.sourceforge.worldsaver.rp.RpBase |
addChild, addDescription, copy, getChilds, getDescription, getFather, getID, getName, setDescription, setFather, setName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Action(RpBase father, java.lang.String name)
father
- the father objectname
- the namepublic Action(java.util.HashMap loaded)
loaded
- the HashMap containing the valuesgen
- the ID-GeneratorRpBase.RpBase(net.sourceforge.worldsaver.rp.RpBase, java.lang.String)
Method Detail |
public void getReferencesRight(java.util.HashMap pool, IDGenerator gen)
Saveable
getReferencesRight
in interface Saveable
getReferencesRight
in class RpBase
net.sourceforge.worldsaver.rp.Saveable
pool
- the objects that could be referencedgen
- the ID-Generator for this objectpublic java.lang.String getSaveableString() throws java.io.IOException
getSaveableString
in interface Saveable
getSaveableString
in class RpBase
java.io.IOException
- if the objects are not validRpBase.getSaveableString()
public boolean isRunning()
public void setStartLocation(Area loc)
loc
- the new start location or nullpublic Area getStartLocation()
public java.lang.String[] getDecisionMessage()
public java.lang.String getText()
public Area getLocation()
protected ActionParticle getActionTree()
public abstract boolean isRunnable()
public abstract void execute()
public abstract void step(int index)
index
- the indexpublic abstract void createActionTree(ActionParticle top)
top
- the ActionParticle that builds the top of the tree
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |