|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gecco.server.actionprocessor.ActionProcessor
The action processor handles the scheduling and execution of actions for the units in the ongoing game.
Field Summary | |
private TreeSet |
actionQueue
Description of the Field |
private Client |
comClient
Description of the Field |
private UnitManager |
unitManager
Description of the Field |
private VisibilityManager |
visibilityManager
Description of the Field |
Constructor Summary | |
ActionProcessor(UnitManager _unitManager,
VisibilityManager _visibilityManager,
Client _comClient)
Constructor for the ActionProcessor object |
Method Summary | |
boolean |
abortAction(String fromRole,
int actionHandle)
Aborts an ongoing action for a unit. |
private void |
addUpdateToQueue(QueuedAction qA,
long msToExecution)
Adds an action to the action queue, with a given execution time. |
private void |
checkActionBlocklist(Unit u)
Checks the ongoing actions of a given unit and notify the roles (clients) that commands the role about any updates. |
private void |
checkActionReturn(QueuedAction qA,
Unit u,
ActionReturn actRet)
Check if a given action, executed by a given unit, is completed, aborted or still ongoing, and take the necessary steps in each case. |
private void |
checkChangedPosition(double oldx,
double oldy,
Unit u)
Check if a given unit has changed from a known last position. |
private void |
checkChangedProperties(Unit u)
Checks all properties of the given unit, and notify all roles (clients) that observes the unit about any updates. |
private static void |
debug(String s)
Outputs a debug message to the server log, as well as to the stdout of the server. |
void |
executeInstantaneousAction(Action action)
Executes an instantaneous action. |
TreeSet |
getActionQueue()
Returns the TreeSet object which is the queue that holds
the current scheduled actions for the units in the game. |
long |
getCurrentTime()
Simply returns the current system time. |
void |
handleAutomatonUnitEvent(int x,
int y,
UnitEvent unitEvent)
This method handles an incoming UnitEvent coming from the
automaton-layer, most probably due to a change of state in the automaton
at position (x, y). |
void |
handleUnitToUnitEvent(Unit unit,
UnitEvent unitEvent)
This method handles an incoming UnitEvent which originates from another unit in the game. |
void |
initiateAction(String fromRole,
Action action)
Initiates an action for a unit. |
private static void |
log(String s)
Outputs a message to the server log. |
void |
run()
Main processing method for the execution of actions. |
private void |
sendUnitMessageToAll(Unit unit,
String unitMessage)
Sends a message to all observers of a given unit. |
private void |
sendUnitMessageToAllButCommander(Unit unit,
String unitMessage)
Sends a message to all observers, except the commander, of a given unit. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private TreeSet actionQueue
private UnitManager unitManager
private VisibilityManager visibilityManager
private Client comClient
Constructor Detail |
public ActionProcessor(UnitManager _unitManager, VisibilityManager _visibilityManager, Client _comClient)
_unitManager
- An instance of the unit manager_visibilityManager
- An instance of the visibility manager_comClient
- An instance of the communication client
interfaceMethod Detail |
public TreeSet getActionQueue()
TreeSet
object which is the queue that holds
the current scheduled actions for the units in the game. This method is
primarily used when another thread wants to synchronize on the queue
object, preventing any other thread to add a new action to the queue.public long getCurrentTime()
public void initiateAction(String fromRole, Action action)
fromRole
- The commanding role which initiated the action.action
- The Action class itself.public void executeInstantaneousAction(Action action)
checkPoint()
method in the action class.action
- The class representing the instantaneous action.public void handleAutomatonUnitEvent(int x, int y, UnitEvent unitEvent)
UnitEvent
coming from the
automaton-layer, most probably due to a change of state in the automaton
at position (x, y).x
- The x-coordinate of the automaton.y
- The y-coordinate of the automaton.unitEvent
- The UnitEvent class.public void handleUnitToUnitEvent(Unit unit, UnitEvent unitEvent)
unit
- The affected unit.unitEvent
- The UnitEvent class.public boolean abortAction(String fromRole, int actionHandle)
fromRole
- The commanding roleactionHandle
- The actionHandletrue
if the action was found and
removed, false
otherwise.public void run()
run
in interface Runnable
private void addUpdateToQueue(QueuedAction qA, long msToExecution)
qA
- The action to be added.msToExecution
- The time until execution.private void checkChangedPosition(double oldx, double oldy, Unit u)
oldx
- The last known x coordinateoldy
- The last known x coordinateu
- The unit.private void checkActionBlocklist(Unit u)
u
- The unit to check.private void checkChangedProperties(Unit u)
u
- The unit to check.private void checkActionReturn(QueuedAction qA, Unit u, ActionReturn actRet)
qA
- The action to check.u
- The unit executing the action.actRet
- The return from the last checkpoint call.private void sendUnitMessageToAllButCommander(Unit unit, String unitMessage)
unit
- The unit.unitMessage
- The message to send.private void sendUnitMessageToAll(Unit unit, String unitMessage)
unit
- The unit.unitMessage
- The message to send.private static void log(String s)
s
- The message to output.private static void debug(String s)
s
- The message to output.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |