|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--monrovia.server.platform.GameObject | +--monrovia.server.platform.Command
Abstract base class for commands. All commands must be inherited from this class.
The command execution goes as follows:
Requested argument type is located in parameter "command arg". You
can also set this in the command implementation method
addParameters()
or checkParameters()
.
Field Summary | |
static IntPoint[] |
DIRADDS
|
static java.lang.String[] |
DIRTEXTS
|
Constructor Summary | |
Command()
|
Method Summary | |
void |
addParameters(ParameterMap pParameters)
This method will be called to initialize the parameters. |
abstract void |
execute()
Place to do the actual execution. |
Creature |
getCommander()
|
int[] |
getIntArgs()
|
java.lang.String |
getStringArg()
|
boolean |
isExecute()
Returns true, if this command is about to execute. |
void |
postExecute()
Post execute hook. |
void |
preExecute()
Pre execute hook. |
boolean |
setExecute(boolean pExecute)
Set whether this command is about to execute. |
void |
setIntArgs(int[] pIntArgs)
|
void |
setStringArg(java.lang.String pStringArg)
|
abstract boolean |
tryExecution()
Check and set marks to see whether this command conflicts with any other command. |
Methods inherited from class monrovia.server.platform.GameObject |
addParameter, checkParameters, clearCommandMarks, create, getArea, getCommandMark, getGI, getID, getLocation, getName, getNeededParameters, getOptionalParameters, getParameter, initialize, removeParameter, resetObject, resetParameters, setCommandMark, setParameter, toString |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String[] DIRTEXTS
public static final IntPoint[] DIRADDS
Constructor Detail |
public Command()
Method Detail |
public void addParameters(ParameterMap pParameters)
GameObject
addParameters
in class GameObject
monrovia.server.platform.GameObject
pParameters
- Add the parameters herepublic Creature getCommander()
public void preExecute()
public abstract boolean tryExecution()
First check whether the mark is already there. If it is our mark, then it is fine. If it is someone others mark, then we have a conflict. If there is no mark, just put the mark there.
With conflict there first find out which one is the stronger. If it is us, then we must override the mark. If it is not us, then we can't do what we wanted to.
There are also other kind of things that can conflict with a command. For example, if we are moving, someone or something can be in the way. To cope with conflicts you can also add new commands. In the case of previous example, we can for example add a new command to move the guy in front of us out of our way.
You should use setExecute()
to tell whether the
execution of the command is successful.
public abstract void execute()
public void postExecute()
public boolean isExecute()
public boolean setExecute(boolean pExecute)
public int[] getIntArgs()
public void setIntArgs(int[] pIntArgs)
public java.lang.String getStringArg()
public void setStringArg(java.lang.String pStringArg)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |