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

Helper class supporting both behavior tree and state machine actions and conditions. More...

Inheritance diagram for Dragengine.Utils.BTSMActionCondition:
Dragengine.BehaviorTreeSystem.BTAction Dragengine.BehaviorTreeSystem.BTCondition Dragengine.StateMachineSystem.SMAction Dragengine.StateMachineSystem.SMCondition Dragengine.Utils.BTSMCondition

Public Member Functions

bool evaluateCondition (BTContext context, Dictionary parameters)
 Evaluate condition.
bool evaluateCondition (SMContext context, Dictionary parameters)
 Evaluate condition.
bool evaluateConditionShared (Object context, Dictionary parameters)
 Evaluate condition.
BTSMActionCondition new ()
 Create shared behavior tree and state machine action and condition.
BTResult runAction (BTContext context, Dictionary parameters)
 Run action.
void runAction (SMContext context, Dictionary parameters)
 Run action.
BTResult runActionShared (Object context, Dictionary parameters)
 Run action shared.

Detailed Description

Helper class supporting both behavior tree and state machine actions and conditions.

Version
1.26

This class is useful to use the same set of actions and conditions for both behavior trees and state machines. State machine actions throw an exception if the shared action returns BTResult#failure.

To use actions overwrite BTSMActionCondition.runActionShared(). To use conditions overwrite BTSMActionCondition.evaluateConditionShared().

Typical usage looks like this (inside an Scenery.DefaultECBehaviorInstance subclass):

class BTSMAUpdate extends BTSMActionCondition
var Instance pInstance
func new(Instance instance)
pInstance = instance
end
func BTResult runActionShared(Object context, Dictionary parameters)
var Object value = parameters.getAt("parameterName", null)
if value != null
pInstance.doSomethingWith(value cast String)
end
return BTResult.success
end
end
Helper class supporting both behavior tree and state machine actions and conditions.
Definition BTSMActionCondition.ds:69
BTResult runActionShared(Object context, Dictionary parameters)
Run action shared.
BTSMActionCondition new()
Create shared behavior tree and state machine action and condition.

And adding it to ECComposeBTSM.Instance like this (in Scenery.DefaultECBehaviorInstance.init()):

if pECBehavior.getBTSMs().hasAny()
var String prefix = pECBehavior.getPrefix()
var ECComposeBTSM.Instance btsms = ECComposeBTSM.Instance.new(getElement(), pECBehavior.getBTSMs())
btsms.addAllAction(prefix, "update", BTSMAUpdate.new(this))
end

Member Function Documentation

◆ evaluateCondition() [1/2]

bool Dragengine.Utils.BTSMActionCondition.evaluateCondition ( BTContext context,
Dictionary parameters )

Evaluate condition.

Parameters
parametersDictionary with parameters of type String key and String value. Do not change the content of the dictionary as it is shared.

Implements Dragengine.BehaviorTreeSystem.BTCondition.

References runAction().

Referenced by evaluateCondition().

◆ evaluateCondition() [2/2]

bool Dragengine.Utils.BTSMActionCondition.evaluateCondition ( SMContext context,
Dictionary parameters )

Evaluate condition.

Parameters
parametersDictionary with parameters of type String key and String value. Do not change the content of the dictionary as it is shared.

Implements Dragengine.StateMachineSystem.SMCondition.

References evaluateCondition(), evaluateConditionShared(), new(), runAction(), and runActionShared().

◆ evaluateConditionShared()

bool Dragengine.Utils.BTSMActionCondition.evaluateConditionShared ( Object context,
Dictionary parameters )

Evaluate condition.

Context which can be either BTContext or SMContext.

Default implementation returns false.

Reimplemented in Dragengine.Utils.BTSMCondition.

Referenced by evaluateCondition(), Dragengine.Scenery.ECBehaviorInteractionElement.Instance.BTAUpdate.CCInteract.evaluateQuery(), and runAction().

◆ new()

BTSMActionCondition Dragengine.Utils.BTSMActionCondition.new ( )

Create shared behavior tree and state machine action and condition.

References new().

Referenced by evaluateCondition(), and new().

◆ runAction() [1/2]

BTResult Dragengine.Utils.BTSMActionCondition.runAction ( BTContext context,
Dictionary parameters )

Run action.

Parameters
parametersDictionary with parameters of type String key and String value. Do not change the content of the dictionary as it is shared.

Implements Dragengine.BehaviorTreeSystem.BTAction.

References evaluateConditionShared().

Referenced by evaluateCondition(), and evaluateCondition().

◆ runAction() [2/2]

void Dragengine.Utils.BTSMActionCondition.runAction ( SMContext context,
Dictionary parameters )

Run action.

Parameters
parametersDictionary with parameters of type String key and String value. Do not change the content of the dictionary as it is shared.

Implements Dragengine.StateMachineSystem.SMAction.

◆ runActionShared()

BTResult Dragengine.Utils.BTSMActionCondition.runActionShared ( Object context,
Dictionary parameters )

Run action shared.

For state machine use exception is thrown if the returned value is BTResult#failure. Default implementation returns BTResult#failure.

Context which can be either BTContext or SMContext.

Reimplemented in Dragengine.Utils.BTSMCondition.

References runActionShared().

Referenced by evaluateCondition(), and runActionShared().


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