mudlet-map-editor 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist-lib/editor/reader/EditorMapReader.d.ts +6 -0
- package/dist-lib/index.js +46 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -74,4 +74,6 @@ Binary .dat file
|
|
|
74
74
|
→ MapRenderer (Konva canvas) + LiveEffect overlays
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
All map mutations go through a command system (`applyCommand`) that records operations for undo/redo. State is managed in a single centralized store.
|
|
77
|
+
All map mutations go through a command system (`applyCommand`) that records operations for undo/redo. State is managed in a single centralized store.
|
|
78
|
+
|
|
79
|
+
Bulk operations (multi-room delete, move rooms to area, undo/redo of the above) go through optimized paths in `EditorMapReader` that perform a single `rebuildPlanes`/`rebuildExits` per affected area rather than one per room, keeping large selections responsive.
|
|
@@ -75,6 +75,7 @@ export declare class EditorArea {
|
|
|
75
75
|
getLinkExits(zIndex: number): EditorExit[];
|
|
76
76
|
setLabels(labels: any[]): void;
|
|
77
77
|
addRoomLive(room: LiveRoom): void;
|
|
78
|
+
addRoomsLive(newRooms: LiveRoom[]): void;
|
|
78
79
|
removeRoomById(id: number): void;
|
|
79
80
|
removeRoomsById(ids: Set<number>): void;
|
|
80
81
|
rebuildPlanes(): void;
|
|
@@ -121,6 +122,11 @@ export declare class EditorMapReader {
|
|
|
121
122
|
setUserDataEntry(id: number, key: string, value: string | null): void;
|
|
122
123
|
/** Add a raw room (expected `raw.rooms[id]` already set or not, we set it). */
|
|
123
124
|
addRoom(id: number, rawRoom: MudletRoom): void;
|
|
125
|
+
/** Bulk-add many rooms. Does one rebuildPlanes/rebuildExits per affected area. */
|
|
126
|
+
addRooms(rooms: Array<{
|
|
127
|
+
id: number;
|
|
128
|
+
room: MudletRoom;
|
|
129
|
+
}>): void;
|
|
124
130
|
setSpecialExit(roomId: number, name: string, toId: number): void;
|
|
125
131
|
removeSpecialExit(roomId: number, name: string): void;
|
|
126
132
|
setDoor(roomId: number, dir: Direction, value: number): void;
|
package/dist-lib/index.js
CHANGED
|
@@ -2684,6 +2684,22 @@ function Ee(e, t, n) {
|
|
|
2684
2684
|
}
|
|
2685
2685
|
return { structural: !1 };
|
|
2686
2686
|
case "batch": {
|
|
2687
|
+
if (n?.reader && t.cmds.length > 1 && t.cmds.every((e) => e.kind === "deleteRoom")) {
|
|
2688
|
+
let r = t.cmds;
|
|
2689
|
+
for (let t of r) {
|
|
2690
|
+
e.rooms[t.id] = { ...t.room };
|
|
2691
|
+
let n = e.areas[t.areaId];
|
|
2692
|
+
n && !n.rooms.includes(t.id) && n.rooms.push(t.id);
|
|
2693
|
+
}
|
|
2694
|
+
for (let t of r) for (let n of t.neighborEdits) {
|
|
2695
|
+
let t = e.rooms[n.roomId];
|
|
2696
|
+
t && (t[n.dir] = n.was);
|
|
2697
|
+
}
|
|
2698
|
+
return n.reader.addRooms(r.map((t) => ({
|
|
2699
|
+
id: t.id,
|
|
2700
|
+
room: e.rooms[t.id]
|
|
2701
|
+
}))), { structural: !0 };
|
|
2702
|
+
}
|
|
2687
2703
|
let r = !1;
|
|
2688
2704
|
for (let i of [...t.cmds].reverse()) Ee(e, i, n).structural && (r = !0);
|
|
2689
2705
|
return { structural: r };
|
|
@@ -9862,6 +9878,9 @@ var Hn = class {
|
|
|
9862
9878
|
addRoomLive(e) {
|
|
9863
9879
|
this.rooms.push(e), this.rebuildPlanes(), this.rebuildExits(), this.markDirty();
|
|
9864
9880
|
}
|
|
9881
|
+
addRoomsLive(e) {
|
|
9882
|
+
this.rooms.push(...e), this.rebuildPlanes(), this.rebuildExits(), this.markDirty();
|
|
9883
|
+
}
|
|
9865
9884
|
removeRoomById(e) {
|
|
9866
9885
|
this.rooms = this.rooms.filter((t) => t.id !== e), this.rebuildPlanes(), this.rebuildExits(), this.markDirty();
|
|
9867
9886
|
}
|
|
@@ -10027,6 +10046,21 @@ var Gn = {
|
|
|
10027
10046
|
let r = Fn(e, t);
|
|
10028
10047
|
this.rooms[e] = r, this.areas[t.area]?.addRoomLive(r);
|
|
10029
10048
|
}
|
|
10049
|
+
addRooms(e) {
|
|
10050
|
+
let t = /* @__PURE__ */ new Map();
|
|
10051
|
+
for (let { id: n, room: r } of e) {
|
|
10052
|
+
this.raw.rooms[n] = r;
|
|
10053
|
+
let e = this.raw.areas[r.area];
|
|
10054
|
+
e && !e.rooms.includes(n) && e.rooms.push(n);
|
|
10055
|
+
let i = Fn(n, r);
|
|
10056
|
+
this.rooms[n] = i;
|
|
10057
|
+
let a = t.get(r.area);
|
|
10058
|
+
a || (a = [], t.set(r.area, a)), a.push(i);
|
|
10059
|
+
}
|
|
10060
|
+
let n = new Set(t.keys());
|
|
10061
|
+
for (let [e, n] of t) this.areas[e]?.addRoomsLive(n);
|
|
10062
|
+
for (let e of this.getAreas()) n.has(e.getAreaId()) || (e.rebuildExits(), e.markDirty());
|
|
10063
|
+
}
|
|
10030
10064
|
setSpecialExit(e, t, n) {
|
|
10031
10065
|
let r = this.raw.rooms[e];
|
|
10032
10066
|
r && (r.mSpecialExits[t] = n, this.areas[r.area]?.markDirty());
|
|
@@ -10126,22 +10160,18 @@ var Gn = {
|
|
|
10126
10160
|
delete this.raw.areas[e], delete this.raw.areaNames[e], delete this.areas[e];
|
|
10127
10161
|
}
|
|
10128
10162
|
moveRoomsToArea(e, t, n) {
|
|
10129
|
-
let r = this.areas[t], i = this.areas[n], a = [
|
|
10130
|
-
for (let
|
|
10131
|
-
let
|
|
10132
|
-
if (!
|
|
10133
|
-
|
|
10134
|
-
let
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
let c = this.rooms[e];
|
|
10142
|
-
c && (r?.removeRoomById(e), i?.addRoomLive(c));
|
|
10143
|
-
}
|
|
10144
|
-
r?.markDirty();
|
|
10163
|
+
let r = this.areas[t], i = this.areas[n], a = new Set(e), o = [];
|
|
10164
|
+
for (let t of e) {
|
|
10165
|
+
let e = this.raw.rooms[t];
|
|
10166
|
+
if (!e) continue;
|
|
10167
|
+
e.area = n;
|
|
10168
|
+
let r = this.raw.areas[n];
|
|
10169
|
+
r && !r.rooms.includes(t) && r.rooms.push(t);
|
|
10170
|
+
let i = this.rooms[t];
|
|
10171
|
+
i && o.push(i);
|
|
10172
|
+
}
|
|
10173
|
+
let s = this.raw.areas[t];
|
|
10174
|
+
s && (s.rooms = s.rooms.filter((e) => !a.has(e))), r && r.removeRoomsById(a), i && i.addRoomsLive(o), r?.markDirty();
|
|
10145
10175
|
}
|
|
10146
10176
|
renameArea(e, t) {
|
|
10147
10177
|
this.raw.areaNames[e] = t;
|