@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
35 lines (26 loc) • 854 B
JavaScript
import { Action } from "../../../src/core/process/undo/Action.js";
class ComponentRemoveAction extends Action {
constructor(entity, componentType) {
super();
this.entity = entity;
this.componentType = componentType;
this.component = null;
}
async apply(editor) {
/**
* @type {Engine}
*/
const engine = editor.engine;
const em = engine.entityManager;
/**
* @type {EntityComponentDataset}
*/
const ecd = em.dataset;
this.component = ecd.removeComponentFromEntity(this.entity, this.componentType);
}
async revert(editor) {
const em = editor.engine.entityManager;
em.addComponentToEntity(this.entity, this.component);
}
}
export default ComponentRemoveAction;