Drag[en]gine Script Module DragonScript
1.23
|
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 | Instance |
Behavior instance. More... | |
Public Member Functions | |
void | addActionConditionFactory (ActionConditionFactory factory) |
Add action and condition factory. More... | |
void | addActionConditionFactory (Block factory) |
Add action and condition factory using block receiving Instance as parameter. More... | |
ECBehaviorInstance | createInstance (BehaviorElement element) |
Create Behavior instance. More... | |
void | dispose () |
Dispose of behavior. More... | |
void | forEachActionConditionFactory (Block ablock) |
Visit listener factories with block with argument ActionConditionFactory. More... | |
ECPStateMachine | getStateMachine () |
State machine. More... | |
Instance | instance (BehaviorElement element) |
Get instance in element from owner element class. More... | |
ECBehaviorStateMachine | new (BehaviorElementClass eclass) |
Create behavior element class. More... | |
ECBehaviorStateMachine | new (BehaviorElementClass eclass, Loaders loaders) |
Create behavior element class. More... | |
ECBehaviorStateMachine | new (BehaviorElementClass eclass, Loaders loaders, String id) |
Create behavior element class. More... | |
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. More... | |
ECBehaviorStateMachine | new (BehaviorElementClass eclass, String id, String prefix) |
Create behavior element class. More... | |
Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior | |
void | assignInstanceIndex (int instanceIndex) |
Assign instance index. 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... | |
Static Public Member Functions | |
static Array | getAllBehaviorsIn (BehaviorElementClass eclass) |
Get list of all behaviors in element. More... | |
static Array | getAllInstancesIn (BehaviorElement element) |
Get list of all instances in element. More... | |
static ECBehaviorStateMachine | getBehaviorIn (BehaviorElementClass eclass) |
Get behavior in element class or null if absent. More... | |
static ECBehaviorStateMachine | getBehaviorIn (BehaviorElementClass eclass, String id) |
Get behavior with id in element class or null if absent. More... | |
static Instance | getInstanceIn (BehaviorElement element) |
Get instance in element or null if absent. More... | |
static Instance | getInstanceIn (BehaviorElement element, String id) |
Get instance with id in element or null if absent. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehavior | |
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... | |
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.
ECBehaviorInstance Dragengine.Scenery.ECBehaviorStateMachine.createInstance | ( | BehaviorElement | element | ) |
Create Behavior instance.
Implements Dragengine.Scenery.ECBehavior.
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 list of all behaviors in element.
Returns list contains ECBehaviorStateMachine behaviors in the order they have been created in the element.
|
static |
Get list of all instances in element.
Returns list contains ECBehaviorStateMachine.Instance instances in the order they have been created in the element.
|
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.
|
static |
Get behavior with id in element class or null if absent.
Use this method to check if a particular BehaviorElementClass contains a behavior of type ECBehaviorStateMachine with specific identifier.
|
static |
Get instance in element or null if absent.
Use this method to check if a particular BehaviorElement contains a behavior instance of type ECBehaviorStateMachine.Instance . If more than one instance is present returns the first instance.
|
static |
Get instance with id in element or null if absent.
Use this method to check if a particular BehaviorElement contains a behavior instance of type ECBehaviorStateMachine.Instance with specific identifier.
ECPStateMachine Dragengine.Scenery.ECBehaviorStateMachine.getStateMachine | ( | ) |
State machine.
Instance Dragengine.Scenery.ECBehaviorStateMachine.instance | ( | BehaviorElement | element | ) |
Get instance in element from owner element class.
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.