|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgecco.server.core.Action
This class represents an Action that a unit can execute, and every real action should be a subclass of this class. There are several kinds of actions. First, there is normal actions, that are executed one after another in a queue, only one at a time, and there are instantaneous actions, that are executed at once, even if there are some other normal action ongoing. The normal actions typically span some interval in time, like movement of units, and the instantaneous don't, they are just instantaneous. :-) Second, actions can have different arguments. At the moment, the arguments can be a unit, a point on the map, or nothing. Normal actions are executed over a time interval, and at some points in time the action has checkpoints when the method with the same name is called by the game engine. That method is where most of the code of the action is placed, for example code to check if the action is completed, and code to update any status of the unit executing the action, and so on.
Constructor Summary | |
Action()
Constructor for the Action object |
Method Summary | |
protected boolean |
canSeePosition(double x,
double y)
Determines if the unit that executes the action can see a certain position, or rather if the units commander can. |
abstract ActionReturn |
checkPoint()
This method is called periodically by the game engine. |
ActionDefinition |
getActionDefinition()
Gets the definition of the Action object |
int |
getActionHandle()
Gets the handle of the Action object |
Unit |
getArgumentUnit()
Gets the unit that is the target of this action. |
double |
getArgumentX()
Gets the x coordinate of the point that is the target of this action. |
double |
getArgumentY()
Gets the y coordinate of the point that is the target of this action. |
protected int |
getAutomatonState(int x,
int y)
Gets the state of the given automaton. |
Unit[] |
getCooperativeUnits()
|
String |
getId()
Gets the id of the Action object |
static int |
getNewActionHandle()
Returns a increasing nuber each time |
Unit |
getUnit()
Gets the unit that executes this action |
int |
getUnitHandle()
Gets the handle of the unit that executes this action |
void |
initiate(int _actionHandle,
int _unitHandle)
Initialise the action without any arguments. |
void |
initiate(int _actionHandle,
int _unitHandle,
double _argX,
double _argY)
Initialise the action with a point as argument. |
void |
initiate(int _actionHandle,
int _unitHandle,
int _argUnitHandle)
Initialise the action with a unit as argument. |
void |
initiate(int _actionHandle,
int _unitHandle,
int _argUnitHandle,
int[] _argCooperativeUnitsHandle)
Initialise the action with a unit and cooperative units as arguments. |
boolean |
isInstantaneous()
Gets the Instantaneous flag of the Action object |
protected static boolean |
isOutsideMap(double x,
double y)
Determines whether or not a given point is outside the map or not. |
void |
prepareAbortion()
Called from ActionProcessor when Action is aborted, lets Action abort gracefully |
protected void |
sendEventToAutomaton(int x,
int y,
String eventName,
int factor)
Sends an event to a given automaton. |
protected void |
sendEventToUnit(Unit unit,
String eventName,
int factor)
Sends an event to a given unit. |
void |
setActionDefinition(ActionDefinition def)
Sets the definition of the Action object |
protected void |
setArgumentUnit(Unit u)
|
protected void |
setArgumentX(double x)
|
protected void |
setArgumentY(double y)
|
void |
setInstantaneous(boolean b)
Sets the Instantaneous flag of the Action object |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Action()
Method Detail |
public void setInstantaneous(boolean b)
b
- The new Instantaneous valuepublic boolean isInstantaneous()
public int getActionHandle()
public ActionDefinition getActionDefinition()
public String getId()
public void setActionDefinition(ActionDefinition def)
def
- The definitionpublic int getUnitHandle()
public Unit getUnit()
public Unit getArgumentUnit()
protected void setArgumentUnit(Unit u)
public double getArgumentX()
protected void setArgumentX(double x)
public double getArgumentY()
protected void setArgumentY(double y)
public Unit[] getCooperativeUnits()
public void initiate(int _actionHandle, int _unitHandle)
_actionHandle
- A unique handle that should identify this action._unitHandle
- The handle of the executing unit.public void initiate(int _actionHandle, int _unitHandle, double _argX, double _argY)
_actionHandle
- A unique handle that should identify this action._unitHandle
- The handle of the executing unit._argX
- The x coordinate of the target point._argY
- The y coordinate of the target point.public void initiate(int _actionHandle, int _unitHandle, int _argUnitHandle)
_actionHandle
- A unique handle that should identify this action._unitHandle
- The handle of the executing unit._argUnitHandle
- The handle of the target unit.public void initiate(int _actionHandle, int _unitHandle, int _argUnitHandle, int[] _argCooperativeUnitsHandle)
_actionHandle
- A unique handle that should identify this action._unitHandle
- The handle of the executing unit._argUnitHandle
- The handle of the target unit._argCooperativeUnitsHandle
- public abstract ActionReturn checkPoint()
protected int getAutomatonState(int x, int y)
x
- The x coordinate of the automaton.y
- The y coordinate of the automaton.
protected static boolean isOutsideMap(double x, double y)
x
- X coordinate.y
- Y coordinate.
protected void sendEventToAutomaton(int x, int y, String eventName, int factor)
x
- The x coordinate of the automaton.y
- The y coordinate of the automaton.eventName
- The name of the event.factor
- The factor of the event.protected void sendEventToUnit(Unit unit, String eventName, int factor)
unit
- The unit that should recieve the event.eventName
- The name of the event.factor
- The factor of the event.protected boolean canSeePosition(double x, double y)
x
- The x coordinate of the position.y
- The y coordinate of the position.
public void prepareAbortion()
public static int getNewActionHandle()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |