Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Scenery.ECBehaviorTimers Class Reference

Behavior element behavior adding timer support to behavior trees and state machines. More...

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

Classes

class  Factory
 Behavior factory. More...
class  Instance
 Behavior instance. More...
class  TrackedTimer
 Timer. More...

Additional Inherited Members

Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
void assignInstanceIndex (int instanceIndex)
 Assign instance index.
void dispose ()
 Dispose of behavior.
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.
Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
DefaultECBehavior new (BehaviorElementClass eclass)
 Create default composeable behavior with empty identifier.
DefaultECBehavior new (BehaviorElementClass eclass, String id)
 Create default composeable behavior.
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>".

Detailed Description

Behavior element behavior adding timer support to behavior trees and state machines.

Version
1.35

Behavior adds actions, conditions and events allowing behavior trees and state machines to start, stop and wait for multiple independent timers.

This behavior can be added only once to an element class.

The following actions are added:

Action "timers.update"

Update timer. The following parameters are supported:

Parameter Value Description
start string Start named timer.
timeout 0 or larger Seconds until the timer elapses.
timeout.lower 0 or larger Minimum seconds of random timeout.
timeout.upper 0 or larger Maximum seconds of random timeout.
stop string Stop named timer.

This is an example of starting a timer:

<action name='timers.update'>
<parameter name='start'>myTimer</parameter>
<parameter name='timeout'>1.5</parameter>
</action>

This is an example of starting a timer using random timeout:

<action name='timers.update'>
<parameter name='start'>myTimer</parameter>
<parameter name='timeout.lower'>1.5</parameter>
<parameter name='timeout.upper'>2.5</parameter>
</action>

This is an example of stopping a timer:

<action name='timers.update'>
<parameter name='stop'>myTimer</parameter>
</action>
Action "timers.check"

Check for timer condition. Not existing timers are considered stopped. The following parameters are supported:

Parameter Value Description
timer string Name of the timer to check.
running true,false Timer is running.
remaining.less 0 or larger Remaining seconds is less than value.
remaining.greater 0 or larger Remaining seconds is greater than value.
wait If present action returns BTResult.running instead of BTResult.failed.

This is an example of checking if a timer is running:

<action name='timers.check' id='waiting'>
<parameter name='timer'>myTimer</parameter>
<parameter name='running'>true</parameter>
</action>
Condition "timers.check"

Check for timer condition. Not existing timers are considered stopped. The following parameters are supported:

Parameter Value Description
timers.timer string Name of the timer to check.
timers.running true,false Timer is running.
timers.remaining.less 0 or larger Remaining seconds is less than value.
timers.remaining.greater 0 or larger Remaining seconds is greater than value.

This is an example of an action that can only run if the timer "myTimer" is running:

<action name='myAction' id='doing something'>
<condition>timers.check</condition>
<parameter name='timers.timer'>myTimer</parameter>
<parameter name='timers.running'>true</parameter>
</action>
Event "timers.elapsed:<name>"

Send to state machines if timer has elapsed. The name of the timer that has elapsed is appended to the event name.

This is an example of an transition that can only run if the timer "myTimer" has elapsed:

<transition event='timers.elapsed:myTimer' state='nextState'>
</transition>
See also
https://developer.dragondreams.ch/wiki/doku.php/dragengine:modules:dragonscript:behavior_timers

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