@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
94 lines • 2.76 kB
TypeScript
/**
* ECS wrapper around a {@link Behavior} tree. Allows complex scripting behavior, including parallelization.
* Requires {@link BehaviorSystem} to be registered on {@link EntityManager}.
*
* @example
* new Entity()
* .add(BehaviorComponent.from(
* SequenceBehavior.from([
* DelayBehavior.from(10),
* DieBehavior.create(),
* ])
* ))
* .build(ecd); // entity will self-destruct after 10 seconds
*
* @author Alex Goldring
* @copyright Company Named Limited (c) 2025
*/
export class BehaviorComponent {
/**
* Executes input function every update cycle.
* Will run forever, or until function throws.
* @param {function(time_delta_seconds:number)} action function to loop over
* @param {*} [thisArg]
* @returns {BehaviorComponent}
*/
static loop(action: any, thisArg?: any): BehaviorComponent;
/**
*
* @param {Behavior} b
* @returns {BehaviorComponent}
*/
static from(b: Behavior): BehaviorComponent;
/**
* What clock should be used for ticking associated behavior.
* Some behaviors need to run at the world's simulated time, while others will need to be executed in real-world time.
* @type {ClockChannelType|number}
*/
clock: ClockChannelType | number;
/**
*
* @type {number}
*/
flags: number;
/**
* Associated behavior tree
* @type {Behavior|null}
* @private
*/
private __behavior;
/**
*
* @param {number|BehaviorComponentFlag} flag
* @returns {void}
*/
setFlag(flag: number | BehaviorComponentFlag): void;
/**
*
* @param {number|BehaviorComponentFlag} flag
* @returns {void}
*/
clearFlag(flag: number | BehaviorComponentFlag): void;
/**
*
* @param {number|BehaviorComponentFlag} flag
* @param {boolean} value
*/
writeFlag(flag: number | BehaviorComponentFlag, value: boolean): void;
/**
*
* @param {number|BehaviorComponentFlag} flag
* @returns {boolean}
*/
getFlag(flag: number | BehaviorComponentFlag): boolean;
/**
* Note that swapping behaviors during simulation may have unintended consequences
* @param {Behavior} v
*/
set behavior(arg: any);
/**
*
* @returns {Behavior|null}
*/
get behavior(): any;
}
export namespace BehaviorComponent {
import fromOne = BehaviorComponent.from;
export { fromOne };
import looping_function = BehaviorComponent.loop;
export { looping_function };
export let serializable: boolean;
export let typeName: string;
}
import { ClockChannelType } from "./ClockChannelType.js";
//# sourceMappingURL=BehaviorComponent.d.ts.map