BaseNode
The BaseNode class is used as super class to all nodes in BehaviorJS. It comprises all common variables and methods that a node must have to execute.
IMPORTANT: Do not inherit from this class, use Composite,
Decorator, Action or Condition, instead.
The attributes are specially designed to serialization of the node in a
JSON format. In special, the parameters attribute can be set into the
visual editor (thus, in the JSON file), and it will be used as parameter
on the node initialization at BehaviorTree.load.
BaseNode also provide 5 callback methods, which the node implementations
can override. They are enter, open, tick, close and exit. See
their documentation to know more. These callbacks are called inside the
_execute method, which is called in the tree traversal.
Item Index
Properties
- category
- description
- id
- name
- parameters deprecated
- properties
- title
Methods
_execute
-
tick
This is the main method to propagate the tick signal to this node. This
method calls all callbacks: enter, open, tick, close, and
exit. It only opens a node if it is not already open. In the same
way, this method only close a node if the node returned a status
different of RUNNING.
Parameters:
-
tickTickA tick instance.
Returns:
The tick state.
_tick
-
tick
Wrapper for tick method.
Parameters:
-
tickTickA tick instance.
Returns:
A state constant.
close
-
tick
Close method, override this to use. This method is called after the tick
callback, and only if the tick return a state different from
RUNNING.
Parameters:
-
tickTickA tick instance.
enter
-
tick
Enter method, override this to use. It is called every time a node is asked to execute, before the tick itself.
Parameters:
-
tickTickA tick instance.
exit
-
tick
Exit method, override this to use. Called every time in the end of the execution.
Parameters:
-
tickTickA tick instance.
initialize
()
Initialization method.
open
-
tick
Open method, override this to use. It is called only before the tick callback and only if the not isn't closed.
Note: a node will be closed if it returned RUNNING in the tick.
Parameters:
-
tickTickA tick instance.
tick
-
tick
Tick method, override this to use. This method must contain the real execution of node (perform a task, call children, etc.). It is called every time a node is asked to execute.
Parameters:
-
tickTickA tick instance.
Properties
category
CONSTANT
Node category. Must be COMPOSITE, DECORATOR, ACTION or
CONDITION. This is defined automatically be inheriting the
correspondent class.
description
String
Node description.
id
String
Node ID.
name
String
Node name. Must be a unique identifier, preferable the same name of the class. You have to set the node name in the prototype.
parameters
Object
deprecated
A dictionary (key, value) describing the node parameters. Useful for defining parameter values in the visual editor. Note: this is only useful for nodes when loading trees from JSON files.
Deprecated since 0.2.0. This is too similar to the properties
attribute, thus, this attribute is deprecated in favor to
properties.
properties
Object
A dictionary (key, value) describing the node properties. Useful for defining custom variables inside the visual editor.
title
String
Node title.
