Drag[en]gine Script Module DragonScript  1.21
Dragengine.Scenery.ECBehaviorBehaviorTreeFlags Class Reference

Behavior element behavior adding flags support to behavior tree support. More...

Inheritance diagram for Dragengine.Scenery.ECBehaviorBehaviorTreeFlags:
Dragengine.Scenery.DefaultECBehavior Dragengine.Scenery.ECBehavior Dragengine.Scenery.BehaviorCompatiblePersistency

Classes

class  Instance
 Behavior instance. More...
 

Additional Inherited Members

- Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
void assignInstanceIndex (int instanceIndex)
 Assign instance index. More...
 
void dispose ()
 Dispose of behavior. More...
 
String getBehaviorID ()
 Unique identifier of behavior. More...
 
String getID ()
 Identifier. More...
 
int getInstanceIndex ()
 Instance index. More...
 
void loadSupportedData (String identifier, PersistencyEnvironment env, FileReader reader, ECBehaviorInstance instance)
 Load instance data of another behavior. More...
 
bool supportsBehaviorID (String identifier)
 Behavior supports loading instance data of another behavior. More...
 
- Public Member Functions inherited from Dragengine.Scenery.ECBehavior
ECBehaviorInstance createInstance (BehaviorElement element)
 Create Behavior instance. More...
 
- Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
DefaultECBehavior new (BehaviorElementClass eclass)
 Create default composeable behavior with empty identifier. More...
 
DefaultECBehavior new (BehaviorElementClass eclass, String id)
 Create default composeable behavior. More...
 
void setBehaviorID (String identifier)
 Set behavior identifier. More...
 
void useClassNameAsBehaviorID ()
 Set behavior identifier to "<class-name>:<identifier>". More...
 
void useFullyQualifiedClassNameAsBehaviorID ()
 Set behavior identifier to "<fully-qualified-class-name>:<identifier>". More...
 

Detailed Description

Behavior element behavior adding flags support to behavior tree support.

Behavior adds behavior tree actions and conditions to an ECBehaviorBehaviorTree allowing scripts and behavior trees to set, clear and check flags. This can be used to signal events to behavior trees that can be processed at an appropriate time. This behavior can be added multiple times to an element for each ECBehaviorBehaviorTree. Each instance creates an own set of behavior tree actions, conditions and flags. Hence to use more than one behavior tree use code like this in your subclass constructor:

class MyElement extends BehaviorElementClass
public func new()
var ECBehaviorBehaviorTree btree = ECBehaviorBehaviorTree.new(this)
var ECBehaviorBehaviorTree btree2 = ECBehaviorBehaviorTree.new(this, "bt2")
ECBehaviorBehaviorTreeFlags.new(this, btree)
ECBehaviorBehaviorTreeFlags.new(this, btree, "bt2")
end
end
DefaultECBehavior new(BehaviorElementClass eclass)
Create default composeable behavior with empty identifier.

The following actions are added to the behavior tree:

Action "flags.set"

Set a flag. As parameter use "flag" to select the flag to set. Use optional parameter "clear" to clear flag. This action immediately returns and does not require a rule identifier.

This is an example of using this action:

<action name='flags.set'>
<parameter name='flag'>arrived at target</parameter>
</action>

This is an example of using this action to clear flag:

<action name='flags.set'>
<parameter name='flag'>arrived at target</parameter>
<parameter name='clear'/>
</action>
Action "flags.check"

Checks if flag is set. Use as parameter "flag" to select the flag to check. Use as optional parameter "cleared" to check for flag to be cleared instead of set. Use the optional parameter "wait" to wait until the flag is set or cleared. If not waiting the action returns immediately with BTResult.success if the flag is set otherwise BTResult.failure . If waiting the action keeps running until the flags becomes set or cleared then returns BTResult.success . A flag that has not been used so far is in cleared state. Use the optional parameter "reset" to toggle the flag if condition is finished. Hence if "reset" is used and the flag is set it is reset. This can be used for waiting and not waiting.

This is an example of using this action to check if a flag is set right now:

<action name='flags.check'>
<parameter name='flag'>arrived at target</parameter>
</action>

This is an example of using this action to check if a flag is cleared right now:

<action name='flags.check'>
<parameter name='flag'>arrived at target</parameter>
<parameter name='cleared'/>
</action>

This is an example of using this action waiting until the flag is set:

<action name='flags.check' id='waiting'>
<parameter name='flag'>arrived at target</parameter>
<parameter name='wait'/>
</action>

This is an example of using this action waiting until the flag is set and then clear it:

<action name='flags.check' id='waiting'>
<parameter name='flag'>arrived at target</parameter>
<parameter name='wait'>
<parameter name='reset'>
</action>
Condition "flags.state"

Determines if flag is set. Use as parameter "flag" to select the flag to check. Use optional parameter "flags.cleared" to check if the flag is cleared instead of set.

This is an example of an action that can only run if the flag "arrived at target" is set:

<action name='myAction' id='doing something'>
<parameter name='flag'>arrived at target</parameter>
<condition>flags.state</condition>
</action>

This is an example of an action that can only run if the flag "arrived at target" is cleared:

<action name='myAction' id='doing something'>
<parameter name='flag'>arrived at target</parameter>
<parameter name='flags.cleared'/>
<condition>flags.state</condition>
</action>

The documentation for this class was generated from the following file: