123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import { CopyProps, copyEntityAttrib } from "../../shared";
- import { Poi, PoiAttrib } from "./poi";
- export class EditPoi<T extends PoiAttrib = PoiAttrib> extends Poi<T> {
- mounted(): void {
- super.enableMouseAct(this.actShape);
- this.bus.on("shapeStatusChange", (data) => {
- if (data.type === "click") {
- if (data.current === "active") {
- this.container.bus.emit("active", { active: true, entity: this });
- } else {
- this.container.bus.emit("active", { active: false, entity: this });
- }
- }
- });
- 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");
- },
- });
- super.mounted();
- }
- del() {
- const pois = this.container.getSameLevelData(this);
- if (pois) {
- pois.splice(pois.indexOf(this.attrib), 1);
- }
- this.container.bus.emit("dataChange");
- }
- copy(props: Pick<CopyProps, "count" | "dire"> = {}) {
- 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");
- }
- }
|