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

BTSMActionCondition tailored for condition use (action behaves as condition). More...

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

Public Member Functions

bool evaluateConditionShared (Object context, Dictionary parameters)
 Evaluate condition.
bool evaluateConditionShared (String prefix, Object context, Dictionary parameters)
 Evaluate condition.
String getPrefix ()
 Prefix for condition parameter names.
String getWaitParameterName ()
 Parameter name for wait.
BTSMCondition new (String prefix)
 Create shared behavior tree and state machine action and condition.
BTSMCondition new (String prefix, String waitParameter)
 Create shared behavior tree and state machine action and condition.
BTResult runActionShared (Object context, Dictionary parameters)
 Run action shared.
Public Member Functions inherited from Dragengine.Utils.BTSMActionCondition
bool evaluateCondition (BTContext context, Dictionary parameters)
 Evaluate condition.
bool evaluateCondition (SMContext 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.

Public Attributes

String pPrefix

Detailed Description

BTSMActionCondition tailored for condition use (action behaves as condition).

Version
1.35

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.

Overwrite BTSMCondition.evaluateConditionShared(String,Object,Dictionary).

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

class BTACheck extends BTSMCondition
var Instance pInstance
func new(Instance instance, String prefix) super(prefix)
pInstance = instance
end
func bool evaluateConditionShared(String prefix, Object context, Dictionary parameters)
var bool result = true
var Object value = parameters.getAt(prefix + "parameterName", null)
if value != null
result &= pInstance.getSomething() == value.equals("true")
end
return result
end
end
BTSMActionCondition tailored for condition use (action behaves as condition).
Definition BTSMCondition.ds:71
BTSMCondition new(String prefix)
Create shared behavior tree and state machine action and condition.
bool evaluateConditionShared(String prefix, Object context, Dictionary parameters)
Evaluate 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.addAllActionCondition(prefix, "check", BTACheck.new(this, prefix))
end

Member Function Documentation

◆ evaluateConditionShared() [1/2]

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

Evaluate condition.

Context which can be either BTContext or SMContext.

Default implementation returns false.

Reimplemented from Dragengine.Utils.BTSMActionCondition.

References evaluateConditionShared(), and runActionShared().

◆ evaluateConditionShared() [2/2]

bool Dragengine.Utils.BTSMCondition.evaluateConditionShared ( String prefix,
Object context,
Dictionary parameters )

Evaluate condition.

Context which can be either BTContext or SMContext. Prefix has to be prepended to parameter names. For action use prefix is empty string. For condition use prefix is getPrefix().

Default implementation returns false.

Referenced by evaluateConditionShared().

◆ getPrefix()

String Dragengine.Utils.BTSMCondition.getPrefix ( )

Prefix for condition parameter names.

Version
1.35

References pPrefix.

Referenced by runActionShared().

◆ getWaitParameterName()

String Dragengine.Utils.BTSMCondition.getWaitParameterName ( )

Parameter name for wait.

Version
1.35

Referenced by runActionShared().

◆ new() [1/2]

BTSMCondition Dragengine.Utils.BTSMCondition.new ( String prefix)

Create shared behavior tree and state machine action and condition.

Prefix is typically the behavior element behavior prefix. For example for Scenery.ECBehaviorSpeaker the prefix would be "speaker.".

References new().

Referenced by new(), and new().

◆ new() [2/2]

BTSMCondition Dragengine.Utils.BTSMCondition.new ( String prefix,
String waitParameter )

Create shared behavior tree and state machine action and condition.

References new().

◆ runActionShared()

BTResult Dragengine.Utils.BTSMCondition.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 from Dragengine.Utils.BTSMActionCondition.

References getPrefix(), getWaitParameterName(), and pPrefix.

Referenced by evaluateConditionShared().

Member Data Documentation

◆ pPrefix

String Dragengine.Utils.BTSMCondition.pPrefix

Referenced by getPrefix(), and runActionShared().


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