UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

62 lines 1.79 kB
/** * Picks a random behavior to execute. * The selection is done during initialization, and that selected behavior will then run to completion. * NOTE: Weights are relative, so they don't need to add up to any specific value. * * @example * const behavior = WeightedRandomBehavior.from([ * WeightedElement.from(A, 1), // A is some behavior * WeightedElement.from(B, 70), // B is some behavior * ]); // B will be 70 times more likely to be picked than A * * @author Alex Goldring * @copyright Company Named Limited (c) 2025 */ export class WeightedRandomBehavior extends Behavior<any> { /** * * @param {WeightedElement<Behavior>[]} elements * @returns {WeightedRandomBehavior} */ static from(elements: WeightedElement<Behavior<any>>[]): WeightedRandomBehavior; constructor(); /** * * @type {WeightedElement<Behavior>[]} elements * @private */ private __elements; /** * * @type {function(): number} * @private */ private __random; /** * * @type {Behavior|undefined} * @private */ private __selected; /** * * @param {number} v */ setRandomSeed(v: number): void; /** * * @param {WeightedElement<Behavior>[]} elements Must not be empty */ setElements(elements: WeightedElement<Behavior<any>>[]): void; /** * * @param {WeightedElement<Behavior>} e */ addElement(e: WeightedElement<Behavior<any>>): void; __select(): void; initialize(context: any): void; tick(timeDelta: any): import("../BehaviorStatus.js").BehaviorStatus; } import { Behavior } from "../Behavior.js"; import { WeightedElement } from "./WeightedElement.js"; //# sourceMappingURL=WeightedRandomBehavior.d.ts.map