UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

104 lines 2.88 kB
export type ParallelBehaviorPolicy = number; export namespace ParallelBehaviorPolicy { let RequireOne: number; let RequireAll: number; } /** * Executes all contained behaviors in parallel. * * @example * ParallelBehavior.from([ * ActionBehavior.from(()=> console.log("A")), * ActionBehavior.from(()=> console.log("B")), * ActionBehavior.from(()=> console.log("C")), * ]); // will print A, B and C in console in a single tick * * @author Alex Goldring * @copyright Company Named Limited (c) 2025 */ export class ParallelBehavior extends CompositeBehavior { /** * Default policies are fine for most use cases. * @param {Behavior[]} children * @param {ParallelBehaviorPolicy} [success] how should successful completion be determined? * @param {ParallelBehaviorPolicy} [failure] how should failing completion be determined * @returns {ParallelBehavior} */ static from(children: Behavior[], success?: ParallelBehaviorPolicy, failure?: ParallelBehaviorPolicy): ParallelBehavior; /** * * @param {ParallelBehaviorPolicy} successPolicy * @param {ParallelBehaviorPolicy} failurePolicy */ constructor(successPolicy: ParallelBehaviorPolicy, failurePolicy: ParallelBehaviorPolicy); /** * @private * @type {ParallelBehaviorPolicy} */ private successPolicy; /** * @private * @type {ParallelBehaviorPolicy} */ private failurePolicy; /** * Which child behaviors are currently running? * @readonly * @private * @type {BitSet} */ private readonly activeSet; /** * @private * @type {number} */ private successCount; /** * @private * @type {number} */ private failureCount; /** * * @return {ParallelBehaviorPolicy} */ getSuccessPolicy(): ParallelBehaviorPolicy; /** * * @param {ParallelBehaviorPolicy|number} policy */ setSuccessPolicy(policy: ParallelBehaviorPolicy | number): void; /** * * @return {ParallelBehaviorPolicy} */ getFailurePolicy(): ParallelBehaviorPolicy; /** * * @param {ParallelBehaviorPolicy|number} policy */ setFailurePolicy(policy: ParallelBehaviorPolicy | number): void; /** * * @param {number} timeDelta * @returns {BehaviorStatus|number} */ tick(timeDelta: number): BehaviorStatus | number; initialize(context: any): void; /** * * @private */ private __finalizeActiveChildren; /** * @readonly * @type {boolean} */ readonly isParallelBehavior: boolean; } export namespace ParallelBehavior { let typeName: string; } import { CompositeBehavior } from "./CompositeBehavior.js"; import { BehaviorStatus } from "../BehaviorStatus.js"; //# sourceMappingURL=ParallelBehavior.d.ts.map