UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

45 lines (35 loc) 945 B
import { Action } from "../../../src/core/process/undo/Action.js"; class EntityCreateAction extends Action { constructor() { super(); /** * * @type {number|null} */ this.entity = null; /** * * @type {EntityComponentDataset} */ this.ecd = null; } async apply(editor) { if (this.ecd === null) { /** * @type {EntityManager} */ const em = editor.engine.entityManager; const ecd = em.dataset; this.ecd = ecd; } if (this.entity === null) { this.entity = this.ecd.createEntity(); } else { this.ecd.createEntitySpecific(this.entity); } } async revert(editor) { this.ecd.removeEntity(this.entity); } } export default EntityCreateAction;