blueshell
Version:
A Behavior Tree implementation in modern Javascript
41 lines (40 loc) • 1.56 kB
TypeScript
import { Parent } from './Parent';
import { BlueshellState, ResultCode, BaseNode, Conditional } from '../models';
/**
* If-Else Conditional Composite Node.
*
* If `conditional(state: S, event: E)` returns true,
* control is passed to the consequent node.
*
* If `conditional(state: S, event: E)` returns false,
* control is passed to the alternative node, or
* if alternative is a result code, that is returned, or
* if one is not provided, 'FAILURE' is returned.
*
* 5/29/16
* @author Joshua Chaitin-Pollak
*/
export declare class IfElse<S extends BlueshellState, E> extends Parent<S, E> {
private conditional;
private consequent;
private alternative?;
private children;
constructor(name: string, conditional: Conditional<S, E>, consequent: BaseNode<S, E>, alternative?: BaseNode<S, E> | ResultCode);
/**
* Returns the children of this node, i.e. the `consequent` and the optional `alternative`.
* this is to support the DOT & Archy visualizers
* see Composite<S,E>.addEventCounterToChildren
*/
getChildren(): BaseNode<S, E>[];
/**
* If `conditional` resolves to `true`, then the `consequent` node handles the event.
* Otherwise, the `alternative` node handles the event.
* If no `alternative` is provided, this node resolves to `FAILURE`
* @override
* @param state The state when the event occured.
* @param event The event to handle.
* @param i The child index.
*/
protected onEvent(state: S, event: E): ResultCode;
get symbol(): string;
}