import { CopyProps, copyEntityAttrib } from "../../shared"; import { Poi, PoiAttrib } from "./poi"; export class EditPoi extends Poi { mounted(): void { super.enableMouseAct(this.actShape); super.enableDrag({ readyHandler: () => { this.container.bus.emit("dataChangeBefore"); }, moveHandler: (move) => { this.attrib.x = move[0]; this.attrib.y = move[1]; }, endHandler: () => { this.container.bus.emit("dataChangeAfter"); }, }); } del() { const pois = this.container.getSameLevelData(this); if (pois) { pois.splice(pois.indexOf(this.attrib), 1); } this.container.bus.emit("dataChange"); } copy(props: Pick = {}) { copyEntityAttrib({ ...props, entity: this, size: this.actShape.getSize(), factoryAttrib: (pos) => ({ x: pos[0], y: pos[1], type: this.attrib.type, }), }); this.container.bus.emit("dataChange"); } }