UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

44 lines (37 loc) 779 B
/** * @template S */ export class MoveEdge { constructor() { /** * * @type {null|StateNode} */ this.target = null; } /** * Move that leads from source state to the target state * @param {S} inputState * @returns S output state */ move(inputState) { throw new Error("Abstract method, needs to be overridden"); } /** * * @returns {boolean} */ isTargetMaterialized() { return this.target !== null; } /** * @template S * @param {function(S):S} f * @return {MoveEdge<S>} */ static fromFunction(f) { const r = new MoveEdge(); r.move = f; return r; } }