UNPKG

blueshell

Version:

A Behavior Tree implementation in modern Javascript

28 lines (27 loc) 978 B
import { Parent } from './Parent'; import { BlueshellState, ResultCode, BaseNode, Conditional } from '../models'; export interface SwitchEntry<S extends BlueshellState, E> { conditional?: Conditional<S, E>; child: BaseNode<S, E> | ResultCode; } interface AdaptedSwitchEntry<S extends BlueshellState, E> { conditional: Conditional<S, E>; child: BaseNode<S, E>; } /** * Executes the child action associated with the first matching conditional. * Returns defaultResult if no conditionals match. * * 11/9/21 * @author Timothy Deignan */ export declare class Switch<S extends BlueshellState, E> extends Parent<S, E> { protected readonly defaultResult: ResultCode; private children; protected entries: AdaptedSwitchEntry<S, E>[]; constructor(name: string, entries: SwitchEntry<S, E>[], defaultResult?: ResultCode); protected onEvent(state: S, event: E): ResultCode; getChildren(): BaseNode<S, E>[]; get symbol(): string; } export {};