API Documentation for:
Show:

BaseNode

Defined in: BaseNode:4
Module: b3

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.

Methods

_close

(
  • tick
)
protected

Defined in _close:178

Wrapper for close method.

Parameters:

  • tick Tick

    A tick instance.

_enter

(
  • tick
)
protected

Defined in _enter:143

Wrapper for enter method.

Parameters:

  • tick Tick

    A tick instance.

_execute

(
  • tick
)
Constant protected

Defined in _execute:108

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:

  • tick Tick

    A tick instance.

Returns:

Constant:

The tick state.

_exit

(
  • tick
)
protected

Defined in _exit:190

Wrapper for exit method.

Parameters:

  • tick Tick

    A tick instance.

_open

(
  • tick
)
protected

Defined in _open:154

Wrapper for open method.

Parameters:

  • tick Tick

    A tick instance.

_tick

(
  • tick
)
Constant protected

Defined in _tick:166

Wrapper for tick method.

Parameters:

  • tick Tick

    A tick instance.

Returns:

Constant:

A state constant.

close

(
  • tick
)

Defined in close:231

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:

  • tick Tick

    A tick instance.

enter

(
  • tick
)

Defined in enter:201

Enter method, override this to use. It is called every time a node is asked to execute, before the tick itself.

Parameters:

  • tick Tick

    A tick instance.

exit

(
  • tick
)

Defined in exit:241

Exit method, override this to use. Called every time in the end of the execution.

Parameters:

  • tick Tick

    A tick instance.

initialize

()

Defined in initialize:95

Initialization method.

open

(
  • tick
)

Defined in open:210

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:

  • tick Tick

    A tick instance.

tick

(
  • tick
)

Defined in tick:221

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:

  • tick Tick

    A tick instance.

Properties

category

CONSTANT

Defined in category:44

Node category. Must be COMPOSITE, DECORATOR, ACTION or CONDITION. This is defined automatically be inheriting the correspondent class.

description

String

Defined in description:62

Node description.

id

String

Defined in id:28

Node ID.

name

String

Defined in name:35

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

Defined in parameters:70

Deprecated: since 0.2.0.

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

Defined in properties:85

A dictionary (key, value) describing the node properties. Useful for defining custom variables inside the visual editor.

title

String

Defined in title:54

Node title.