blueshell
Version:
A Behavior Tree implementation in modern Javascript
50 lines (49 loc) • 1.37 kB
TypeScript
import { Parent } from './Parent';
import { BlueshellState, ResultCode, BaseNode } from '../models';
/**
* Base class for all Composite Nodes (nodes which have an array of children).
* Includes support for latching and keeping track of running status.
* @author Joshua Chaitin-Pollak
*/
export declare abstract class Composite<S extends BlueshellState, E> extends Parent<S, E> {
private _children;
private _latched;
/**
* @constructor
* @param name
* @param _children Children Nodes.
* @param _latched
*/
constructor(name: string, _children: BaseNode<S, E>[], _latched?: boolean);
getChildren(): BaseNode<S, E>[];
get latched(): boolean;
/**
* Return an empty object
* @ignore
* @param state
* @param event
*/
protected _beforeEvent(state: S, event: E): {};
/**
* Logging
* @ignore
* @param res
* @param state
* @param event
*/
protected _afterEvent(res: ResultCode, state: S, event: E): ResultCode;
/**
* Invokes `handleChild` for each child.
* @override
* @param state
* @param event
*/
protected onEvent(state: S, event: E): ResultCode;
/**
* @abstract
* @param state
* @param event
* @param i
*/
protected abstract handleChild(state: S, event: E, i: number): ResultCode;
}