UNPKG

blueshell

Version:

A Behavior Tree implementation in modern Javascript

28 lines (27 loc) 1.1 kB
import { Composite } from './Composite'; import { BlueshellState, ResultCode, BaseNode } from '../models'; /** * Base Class for all Decorator Nodes. Can only have one child. * Decorators intercept and can modify the event sent to or the result from the child. * They should do this by overriding one or more of the methods decorateEvent, decorateCall, or decorateResult. * @author Joshua Chaitin-Pollak */ export declare class Decorator<S extends BlueshellState, E> extends Composite<S, E> { /** * Can only pass in one child. * @constructor * @param name * @param child */ constructor(name: string, child: BaseNode<S, E>, latched?: boolean); get child(): BaseNode<S, E>; /** * Passthrough to child Node. * @param state * @param event */ protected handleChild(state: S, event: E): ResultCode; protected decorateEvent(event: E, state?: S): E; protected decorateCall(handleEvent: (state: S, event: E) => ResultCode, state: S, event: E): ResultCode; protected decorateResult(res: ResultCode, state: S, event: E): ResultCode; }