|
Drag[en]gine Script Module DragonScript 1.32.1
|
Behavior element behavior adding StateMachine support. More...
Classes | |
| interface | ActionConditionFactory |
| Factory assigining actions and conditions to state machine. More... | |
| class | BlockActionConditionFactory |
| Factory assigining actions and conditions to state machine using a block. More... | |
| class | Factory |
| Behavior factory. More... | |
| class | Instance |
| Behavior instance. More... | |
Public Member Functions | |
| void | addActionConditionFactory (ActionConditionFactory factory) |
| Add action and condition factory. | |
| void | addActionConditionFactory (Block factory) |
| Add action and condition factory using block receiving Instance as parameter. | |
| void | dispose () |
| Dispose of behavior. | |
| void | forEachActionConditionFactory (Block ablock) |
| Visit listener factories with block with argument ActionConditionFactory. | |
| ECBehaviorBehaviorTree | getBehaviorTree () |
| Behavior tree or null. | |
| ECPString | getDebug () |
| Debug mode prefix. | |
| String | getPrefix () |
| Prefix. | |
| ECPStateMachine | getStateMachine () |
| State machine. | |
| ECBehaviorStateMachine | new (BehaviorElementClass eclass) |
| Create behavior element class. | |
| ECBehaviorStateMachine | new (BehaviorElementClass eclass, Loaders loaders) |
| Create behavior element class. | |
| ECBehaviorStateMachine | new (BehaviorElementClass eclass, Loaders loaders, String id) |
| Create behavior element class. | |
| ECBehaviorStateMachine | new (BehaviorElementClass eclass, Loaders loaders, String id, String subID) |
| ECBehaviorStateMachine | new (BehaviorElementClass eclass, Loaders loaders, String id, String subID, String prefix) |
| ECBehaviorStateMachine | new (BehaviorElementClass eclass, String id) |
| Create behavior element class. | |
| ECBehaviorStateMachine | new (BehaviorElementClass eclass, String id, String prefix) |
| Create behavior element class. | |
| void | setActionsConditions (Instance instance) |
| Assign actions and conditions to behavior instance. | |
| void | setBehaviorTree (ECBehaviorBehaviorTree behaviorTree) |
| Set behavior tree or null. | |
Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior | |
| void | assignInstanceIndex (int instanceIndex) |
| Assign instance index. | |
| String | getBehaviorID () |
| Unique identifier of behavior. | |
| String | getID () |
| Identifier. | |
| int | getInstanceIndex () |
| Instance index. | |
| void | loadSupportedData (String identifier, PersistencyEnvironment env, FileReader reader, ECBehaviorInstance instance) |
| Load instance data of another behavior. | |
| bool | supportsBehaviorID (String identifier) |
| Behavior supports loading instance data of another behavior. | |
Public Member Functions inherited from Dragengine.Scenery.ECBehavior | |
| ECBehaviorInstance | createInstance (BehaviorElement element) |
| Create Behavior instance. | |
Static Public Member Functions | |
| static ECBehaviorStateMachine | getBehaviorIn (BehaviorElementClass eclass) |
| Get behavior in element class or null if absent. | |
Public Attributes | |
| Array | pActionConditionFactories |
| ECBehaviorBehaviorTree | pBehaviorTree |
| ECPString | pDebug |
| String | pPrefix |
| ECPStateMachine | pStateMachine |
Additional Inherited Members | |
Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehavior | |
| void | setBehaviorID (String identifier) |
| Set behavior identifier. | |
| void | useClassNameAsBehaviorID () |
| Set behavior identifier to "<class-name>:<identifier>". | |
| void | useFullyQualifiedClassNameAsBehaviorID () |
| Set behavior identifier to "<fully-qualified-class-name>:<identifier>". | |
Behavior element behavior adding StateMachine support.
Loads state machine from file and creates a SMContext. Other behaviors can add actions and conditions to this state machine allowing to compose state machine actions and conditions easily.
This behavior can be used in different ways depending on the needs.
This is the most simple solution where only one state machine is used. For many situations this is enough and is the most simple solution to use. Add one ECBehaviorStateMachine with no ID to the element and as many other behaviors adding actions and conditions as required. Set the "stateMachine.path" property to define the state machine to load. Then use behavior listeners to run events on the state machine at the appropriate time. This is an example code for such a setup:
You can add multiple instances of ECBehaviorStateMachine to the element to load and use multiple state machines. This can be for using multiple state machines together to model complex logic. In this situation behaviors assigining actions and conditions do add them to all instances of ECBehaviorStateMachine. This is usually not a problem since the state machines are written to use only the actions and conditions making sense to be used. This is an example code for such a setup:
The above example loads and runs two state machines. The first one is running specific state machine. The second state machine provides two separate state machines able to handle multiple logic at the same time. By writing the state machines properly the two state machienes do not interfere with each other and allow to split up state machines into multiple ones which can help create complex logic more simple and stable.
You can assign actions and conditions without using other behaviors by using one or more factories. The factories are added to the behavior. Upon creating the behavior instances the factories are asked to create and assign SMAction and SMCondition. The example below shows how to use a factory to add a condition checking for a trigger and an action manipulating a trigger.
This behavior does require the element class to be persistable (setPersistable) only if the context is run by the behavior itself.
| void Dragengine.Scenery.ECBehaviorStateMachine.addActionConditionFactory | ( | ActionConditionFactory | factory | ) |
Add action and condition factory.
| void Dragengine.Scenery.ECBehaviorStateMachine.addActionConditionFactory | ( | Block | factory | ) |
Add action and condition factory using block receiving Instance as parameter.
This is a convenience method for using BlockActionConditionFactory.
| void Dragengine.Scenery.ECBehaviorStateMachine.dispose | ( | ) |
Dispose of behavior.
Reimplemented from Dragengine.Scenery.DefaultECBehavior.
| void Dragengine.Scenery.ECBehaviorStateMachine.forEachActionConditionFactory | ( | Block | ablock | ) |
Visit listener factories with block with argument ActionConditionFactory.
|
static |
Get behavior in element class or null if absent.
Use this method to check if a particular BehaviorElementClass contains a behavior of type ECBehaviorCollider.
| ECBehaviorBehaviorTree Dragengine.Scenery.ECBehaviorStateMachine.getBehaviorTree | ( | ) |
Behavior tree or null.
| ECPString Dragengine.Scenery.ECBehaviorStateMachine.getDebug | ( | ) |
Debug mode prefix.
If not empty string enables debug mode with prefix to locate log messages easily.
| String Dragengine.Scenery.ECBehaviorStateMachine.getPrefix | ( | ) |
Prefix.
| ECPStateMachine Dragengine.Scenery.ECBehaviorStateMachine.getStateMachine | ( | ) |
State machine.
| ECBehaviorStateMachine Dragengine.Scenery.ECBehaviorStateMachine.new | ( | BehaviorElementClass | eclass | ) |
Create behavior element class.
Reimplemented from Dragengine.Scenery.DefaultECBehavior.
| ECBehaviorStateMachine Dragengine.Scenery.ECBehaviorStateMachine.new | ( | BehaviorElementClass | eclass, |
| Loaders | loaders | ||
| ) |
Create behavior element class.
| ECBehaviorStateMachine Dragengine.Scenery.ECBehaviorStateMachine.new | ( | BehaviorElementClass | eclass, |
| Loaders | loaders, | ||
| String | id | ||
| ) |
Create behavior element class.
| ECBehaviorStateMachine Dragengine.Scenery.ECBehaviorStateMachine.new | ( | BehaviorElementClass | eclass, |
| Loaders | loaders, | ||
| String | id, | ||
| String | subID | ||
| ) |
| ECBehaviorStateMachine Dragengine.Scenery.ECBehaviorStateMachine.new | ( | BehaviorElementClass | eclass, |
| Loaders | loaders, | ||
| String | id, | ||
| String | subID, | ||
| String | prefix | ||
| ) |
| ECBehaviorStateMachine Dragengine.Scenery.ECBehaviorStateMachine.new | ( | BehaviorElementClass | eclass, |
| String | id | ||
| ) |
Create behavior element class.
Reimplemented from Dragengine.Scenery.DefaultECBehavior.
| ECBehaviorStateMachine Dragengine.Scenery.ECBehaviorStateMachine.new | ( | BehaviorElementClass | eclass, |
| String | id, | ||
| String | prefix | ||
| ) |
Create behavior element class.
| void Dragengine.Scenery.ECBehaviorStateMachine.setActionsConditions | ( | Instance | instance | ) |
Assign actions and conditions to behavior instance.
| void Dragengine.Scenery.ECBehaviorStateMachine.setBehaviorTree | ( | ECBehaviorBehaviorTree | behaviorTree | ) |
Set behavior tree or null.
| Array Dragengine.Scenery.ECBehaviorStateMachine.pActionConditionFactories |
| ECBehaviorBehaviorTree Dragengine.Scenery.ECBehaviorStateMachine.pBehaviorTree |
| ECPString Dragengine.Scenery.ECBehaviorStateMachine.pDebug |
| String Dragengine.Scenery.ECBehaviorStateMachine.pPrefix |
| ECPStateMachine Dragengine.Scenery.ECBehaviorStateMachine.pStateMachine |