Behavior Sequence
Behavior sequence is a class derived from Behavior which stores a collection of subbehaviors and executes them in a given sequence.
Important methods
Add Behavior
User can call this method to add a new subbehavior to the end of the sequence.
For example:
-
C++
-
C#
grail::BehaviorSequence sequence{};
sequence.AddBehavior<MoveBehavior>(position); //In C++ we forward constructor arguments to construct behavior in place.
sequence.AddBehavior<FightBehavior>(enemy);
var sequence = new Grail.BehaviorSequence();
sequence.AddBehavior(new MoveBehavior(position));
sequence.AddBehavior(new FightBehavior(enemy));
Is Finished
A overridden method from Behavior class. Returns true if all subbehaviors have finished.
Is Legal
A overridden method from Behavior class. The default implementation allows a sequence to execute itself only if its current subbehavior is legal. This method can be overridden by the user to define different sequence legality logic.
Is Interruptible
A overridden method from Behavior class. Default implementation allows sequence to be interrupted only if current subbehavior is interruptible. This method can be overridden by user to define different sequence interruption logic.