public class SequentialBehaviour extends SerialBehaviour
CompositeBehaviour
that executes its children behaviours
in sequential order, and terminates when its last child has ended.Constructor and Description |
---|
SequentialBehaviour()
Default constructor.
|
SequentialBehaviour(Agent a)
This constructor sets the owner agent for this behaviour.
|
Modifier and Type | Method and Description |
---|---|
void |
addSubBehaviour(Behaviour b)
Add a sub behaviour to this
SequentialBehaviour |
protected boolean |
checkTermination(boolean currentDone,
int currentResult)
Check whether this
SequentialBehaviour must terminate. |
Collection |
getChildren()
Return a Collection view of the children of
this
SequentialBehaviour |
protected Behaviour |
getCurrent()
Get the current child
|
void |
removeSubBehaviour(Behaviour b)
Remove a sub behaviour from this
SequentialBehaviour |
void |
reset()
Puts a
CompositeBehaviour back in initial state. |
protected void |
scheduleFirst()
Prepare the first child for execution
|
protected void |
scheduleNext(boolean currentDone,
int currentResult)
Sequential policy for children scheduling.
|
action, done, resetChildren, setAgent
block, block, getAgent, getBehaviourName, getDataStore, getParent, isRunnable, onEnd, onStart, restart, root, setBehaviourName, setDataStore
public SequentialBehaviour()
public SequentialBehaviour(Agent a)
a
- The agent this behaviour belongs to.protected void scheduleFirst()
scheduleFirst
in class CompositeBehaviour
CompositeBehaviour.scheduleFirst()
protected void scheduleNext(boolean currentDone, int currentResult)
scheduleNext
in class CompositeBehaviour
currentDone
- a flag indicating whether the just executed
child has completed or not.currentResult
- the termination value (as returned by
onEnd()
) of the just executed child in the case this
child has completed (otherwise this parameter is meaningless)CompositeBehaviour.scheduleNext(boolean, int)
protected boolean checkTermination(boolean currentDone, int currentResult)
SequentialBehaviour
must terminate.checkTermination
in class CompositeBehaviour
currentDone
- a flag indicating whether the just executed
child has completed or not.currentResult
- the termination value (as returned by
onEnd()
) of the just executed child in the case this
child has completed (otherwise this parameter is meaningless)CompositeBehaviour.checkTermination(boolean, int)
protected Behaviour getCurrent()
getCurrent
in class CompositeBehaviour
CompositeBehaviour.getCurrent()
public Collection getChildren()
SequentialBehaviour
getChildren
in class CompositeBehaviour
CompositeBehaviour.getChildren()
public void addSubBehaviour(Behaviour b)
SequentialBehaviour
public void removeSubBehaviour(Behaviour b)
SequentialBehaviour
public void reset()
CompositeBehaviour
CompositeBehaviour
back in initial state. The
internal state is cleaned up and reset()
is
recursively called for each child behaviour.reset
in class CompositeBehaviour