Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/excaliburjs/Excalibur. 🎮 Your friendly TypeScript 2D game engine for the web 🗡️ excaliburjs.com
excalibur excaliburjs game-development game-engine game-framework gamedev games html5-canvas typescript
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445import type { Entity } from '../../entity-component-system';import type { Action } from '../action';import { nextActionId } from '../action';import { ActionContext } from '../action-context';import type { ActionQueue } from '../action-queue';
/** * Action that can represent a sequence of actions, this can be useful in conjunction with * {@apilink ParallelActions} to run multiple sequences in parallel. */export class ActionSequence implements Action { id = nextActionId(); private _actionQueue: ActionQueue; private _stopped: boolean = false; private _sequenceContext: ActionContext; private _sequenceBuilder: (actionContext: ActionContext) => any; constructor(entity: Entity, actionBuilder: (actionContext: ActionContext) => any) { this._sequenceBuilder = actionBuilder; this._sequenceContext = new ActionContext(entity); this._actionQueue = this._sequenceContext.getQueue(); this._sequenceBuilder(this._sequenceContext); }
public update(elapsed: number): void { this._actionQueue.update(elapsed); }
public isComplete(): boolean { return this._stopped || this._actionQueue.isComplete(); }
public stop(): void { this._stopped = true; }
public reset(): void { this._stopped = false; this._actionQueue.reset(); }
public clone(entity: Entity) { return new ActionSequence(entity, this._sequenceBuilder); }}