@edv4h/usketch-plugin-map 0.4.0 → 0.5.0
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/dist/base/base-layer.d.ts.map +1 -1
- package/dist/base/base-layer.js +30 -6
- package/dist/base/base-layer.js.map +1 -1
- package/dist/base/base-map-shape.d.ts +6 -6
- package/dist/base/base-map-shape.d.ts.map +1 -1
- package/dist/base/base-map-shape.js +6 -28
- package/dist/base/base-map-shape.js.map +1 -1
- package/dist/base/base-ops.d.ts +16 -23
- package/dist/base/base-ops.d.ts.map +1 -1
- package/dist/base/base-ops.js +101 -101
- package/dist/base/base-ops.js.map +1 -1
- package/dist/base/base-state.d.ts +3 -2
- package/dist/base/base-state.d.ts.map +1 -1
- package/dist/base/base-state.js +4 -3
- package/dist/base/base-state.js.map +1 -1
- package/dist/base/enter-banner.d.ts.map +1 -1
- package/dist/base/enter-banner.js +5 -2
- package/dist/base/enter-banner.js.map +1 -1
- package/dist/base/territory.d.ts +9 -0
- package/dist/base/territory.d.ts.map +1 -0
- package/dist/base/territory.js +128 -0
- package/dist/base/territory.js.map +1 -0
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +25 -5
- package/dist/generate.js.map +1 -1
- package/dist/hud/register-map-hud.d.ts.map +1 -1
- package/dist/hud/register-map-hud.js +0 -0
- package/dist/hud/register-map-hud.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/map-icon-shape.d.ts +3 -0
- package/dist/map-icon-shape.d.ts.map +1 -1
- package/dist/map-icon-shape.js.map +1 -1
- package/dist/map-tool.d.ts.map +1 -1
- package/dist/map-tool.js +57 -61
- package/dist/map-tool.js.map +1 -1
- package/dist/range-erase-state.d.ts +0 -2
- package/dist/range-erase-state.d.ts.map +1 -1
- package/dist/range-erase-state.js +2 -2
- package/dist/range-erase-state.js.map +1 -1
- package/dist/range-erase.d.ts +2 -2
- package/dist/range-erase.d.ts.map +1 -1
- package/dist/range-erase.js +28 -55
- package/dist/range-erase.js.map +1 -1
- package/dist/tilemap-shape.d.ts +7 -0
- package/dist/tilemap-shape.d.ts.map +1 -1
- package/dist/tilemap-shape.js +1 -0
- package/dist/tilemap-shape.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-layer.d.ts","sourceRoot":"","sources":["../../src/base/base-layer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"base-layer.d.ts","sourceRoot":"","sources":["../../src/base/base-layer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAyGpE,wBAAgB,aAAa,CAAC,EAC7B,KAAK,EACL,UAAU,GACV,EAAE;IACF,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,CAAC,EAAE,UAAU,CAAC;CACxB,sCAiHA"}
|
package/dist/base/base-layer.js
CHANGED
|
@@ -2,10 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { exposedEdges, parseCellKey } from "../autotile.js";
|
|
4
4
|
import { blockFactor, downsampleCells, tileDetail } from "../lod.js";
|
|
5
|
+
import { MAP_ICON_TYPE } from "../map-icon-shape.js";
|
|
5
6
|
import { visibleCellRange, visibleWorldRect } from "../map-layer.js";
|
|
6
7
|
import { MAP_TOOL_ID } from "../map-tool-id.js";
|
|
7
8
|
import { useMapToolState } from "../tool-state.js";
|
|
8
9
|
import { baseRegionAnchors, getBaseMap } from "./base-ops.js";
|
|
10
|
+
import { useBaseState } from "./base-state.js";
|
|
11
|
+
import { computeTerritory } from "./territory.js";
|
|
9
12
|
const FILL_OPACITY = 0.24;
|
|
10
13
|
const BORDER_RATIO = 0.16; // border strip thickness, fraction of a tile
|
|
11
14
|
const BORDER_OPACITY = 0.85;
|
|
@@ -71,6 +74,7 @@ function renderCoarse(owner, bases, tile, screenTilePx, visible) {
|
|
|
71
74
|
}
|
|
72
75
|
export function BaseAreaLayer({ store, renderMode, }) {
|
|
73
76
|
const tool = useMapToolState();
|
|
77
|
+
const baseState = useBaseState();
|
|
74
78
|
const [, force] = useState(0);
|
|
75
79
|
const rafRef = useRef(0);
|
|
76
80
|
useEffect(() => {
|
|
@@ -91,19 +95,39 @@ export function BaseAreaLayer({ store, renderMode, }) {
|
|
|
91
95
|
if (!inBaseMode)
|
|
92
96
|
return null;
|
|
93
97
|
const base = getBaseMap(store);
|
|
94
|
-
if (!base
|
|
98
|
+
if (!base)
|
|
99
|
+
return null;
|
|
100
|
+
const tile = base.tile;
|
|
101
|
+
// Territory is DERIVED from beacons + terrain paint (memoised in territory.ts).
|
|
102
|
+
const territory = computeTerritory(store, tile, new Set(baseState.excludeTerrains));
|
|
103
|
+
if (Object.keys(territory).length === 0)
|
|
95
104
|
return null;
|
|
96
105
|
const vp = store.getViewport();
|
|
97
106
|
const visible = visibleWorldRect(store);
|
|
98
|
-
const tile = base.tile;
|
|
99
107
|
const screenTilePx = tile * vp.zoom;
|
|
100
108
|
const detail = tileDetail(screenTilePx, renderMode);
|
|
101
109
|
const cells = detail === "full"
|
|
102
|
-
? renderFull(
|
|
103
|
-
: renderCoarse(
|
|
110
|
+
? renderFull(territory, base.bases, tile, visible)
|
|
111
|
+
: renderCoarse(territory, base.bases, tile, screenTilePx, visible);
|
|
104
112
|
// Labels: HTML chips at screen coords (crisp, constant size). Hidden when coarse.
|
|
105
|
-
const anchors = detail === "full" ? baseRegionAnchors(
|
|
106
|
-
|
|
113
|
+
const anchors = detail === "full" ? baseRegionAnchors(territory, base.bases, tile) : [];
|
|
114
|
+
// Radius rings for beacon icons. Full detail only; radius comes from the base.
|
|
115
|
+
const rings = [];
|
|
116
|
+
if (detail === "full") {
|
|
117
|
+
for (const [, s] of store.getShapes()) {
|
|
118
|
+
if (s.type !== MAP_ICON_TYPE)
|
|
119
|
+
continue;
|
|
120
|
+
const meta = s.meta;
|
|
121
|
+
if (!meta?.baseId)
|
|
122
|
+
continue;
|
|
123
|
+
const info = base.bases[meta.baseId];
|
|
124
|
+
if (!info)
|
|
125
|
+
continue;
|
|
126
|
+
const color = info.color;
|
|
127
|
+
rings.push(_jsx("circle", { cx: s.x + s.width / 2, cy: s.y + s.height / 2, r: info.radius * tile, fill: "none", stroke: color, strokeWidth: 2, strokeDasharray: "8 6", opacity: 0.7, vectorEffect: "non-scaling-stroke" }, `ring-${s.id}`));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return (_jsxs("div", { style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden" }, children: [_jsx("svg", { width: "100%", height: "100%", style: { display: "block", overflow: "visible" }, children: _jsxs("g", { transform: `translate(${vp.x} ${vp.y}) scale(${vp.zoom})`, children: [cells, rings] }) }), anchors.map((a) => (_jsxs("div", { style: {
|
|
107
131
|
position: "absolute",
|
|
108
132
|
left: a.x * vp.zoom + vp.x,
|
|
109
133
|
top: a.y * vp.zoom + vp.y,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-layer.js","sourceRoot":"","sources":["../../src/base/base-layer.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAc,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAmB,UAAU,EAAE,MAAM,WAAW,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,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AAY,EAAE,KAAK;4BACnB,UAAU,EAAE,CAAC,CAAC,KAAK;4BACnB,IAAI,EAAE,MAAM;yBACZ,GACA,EACD,CAAC,CAAC,IAAI,KA5BF,CAAC,CAAC,MAAM,CA6BR,CACN,CAAC,IACG,CACN,CAAC;AACH,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ShapeData, ShapeDefinition } from "@edv4h/usketch-shared";
|
|
2
2
|
export declare const BASE_MAP_TYPE = "base-map";
|
|
3
3
|
export interface BaseInfo {
|
|
4
4
|
name: string;
|
|
5
5
|
color: string;
|
|
6
|
+
/** Territory radius in tiles around the beacon (the core is always owned). */
|
|
7
|
+
radius: number;
|
|
8
|
+
/** The single beacon: the map-icon whose position seeds this base's core. */
|
|
9
|
+
beaconIconId?: string;
|
|
6
10
|
}
|
|
7
|
-
|
|
8
|
-
export type OwnerMap = Record<string, string>;
|
|
11
|
+
export declare const DEFAULT_BASE_RADIUS = 5;
|
|
9
12
|
export interface BaseMapShapeData extends ShapeData {
|
|
10
13
|
type: "base-map";
|
|
11
14
|
tile: number;
|
|
12
15
|
bases: Record<string, BaseInfo>;
|
|
13
|
-
owner: OwnerMap;
|
|
14
16
|
}
|
|
15
17
|
export declare function isBaseMap(shape: ShapeData): shape is BaseMapShapeData;
|
|
16
18
|
export declare function makeBaseMap(tile: number): BaseMapShapeData;
|
|
17
|
-
/** Bounds of all owned cells (keys are cellKeys). */
|
|
18
|
-
export declare function ownerBounds(owner: OwnerMap, tile: number): BoundingBox;
|
|
19
19
|
export declare function createBaseMapShapeDefinition(tile?: number): ShapeDefinition;
|
|
20
20
|
//# sourceMappingURL=base-map-shape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-map-shape.d.ts","sourceRoot":"","sources":["../../src/base/base-map-shape.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-map-shape.d.ts","sourceRoot":"","sources":["../../src/base/base-map-shape.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAe,SAAS,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIrF,eAAO,MAAM,aAAa,aAAa,CAAC;AAExC,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IAClD,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAChC;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,IAAI,gBAAgB,CAErE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAa1D;AAED,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,MAAqB,GAAG,eAAe,CA4BzF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { generateId } from "@edv4h/usketch-shared";
|
|
3
|
-
import { cellKey, cellsBounds, parseCellKey } from "../autotile.js";
|
|
4
3
|
import { DEFAULT_TILE } from "../tilemap-shape.js";
|
|
5
4
|
export const BASE_MAP_TYPE = "base-map";
|
|
5
|
+
export const DEFAULT_BASE_RADIUS = 5;
|
|
6
6
|
export function isBaseMap(shape) {
|
|
7
7
|
return shape.type === BASE_MAP_TYPE;
|
|
8
8
|
}
|
|
@@ -17,56 +17,34 @@ export function makeBaseMap(tile) {
|
|
|
17
17
|
style: { fill: "transparent", stroke: "transparent", strokeWidth: 0, opacity: 1 },
|
|
18
18
|
tile,
|
|
19
19
|
bases: {},
|
|
20
|
-
owner: {},
|
|
21
20
|
locked: true,
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
|
-
/** Bounds of all owned cells (keys are cellKeys). */
|
|
25
|
-
export function ownerBounds(owner, tile) {
|
|
26
|
-
// cellsBounds only reads keys, so the value type is irrelevant here.
|
|
27
|
-
return cellsBounds(owner, tile);
|
|
28
|
-
}
|
|
29
23
|
export function createBaseMapShapeDefinition(tile = DEFAULT_TILE) {
|
|
30
24
|
return {
|
|
31
25
|
render: () => _jsx("g", {}),
|
|
32
26
|
renderTarget: "svg",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
27
|
+
// The registry itself has no geometry; the territory (derived) is drawn by
|
|
28
|
+
// the BaseAreaLayer, not this substrate.
|
|
29
|
+
getBounds: () => ({ x: 0, y: 0, width: 0, height: 0 }),
|
|
37
30
|
hitTest: () => false,
|
|
38
31
|
resizable: false,
|
|
39
32
|
resize: (data) => data,
|
|
40
33
|
createDefault: (params) => ({ ...makeBaseMap(tile), id: params.id }),
|
|
41
|
-
move: (data, dx, dy) => {
|
|
42
|
-
const d = data;
|
|
43
|
-
const t = d.tile ?? tile;
|
|
44
|
-
const dc = Math.round(dx / t);
|
|
45
|
-
const dr = Math.round(dy / t);
|
|
46
|
-
if (dc === 0 && dr === 0)
|
|
47
|
-
return {};
|
|
48
|
-
const next = {};
|
|
49
|
-
for (const [key, baseId] of Object.entries(d.owner)) {
|
|
50
|
-
const [c, r] = parseCellKey(key);
|
|
51
|
-
next[cellKey(c + dc, r + dr)] = baseId;
|
|
52
|
-
}
|
|
53
|
-
return { owner: next, ...ownerBounds(next, t) };
|
|
54
|
-
},
|
|
55
34
|
serializeForAi: (data) => {
|
|
56
35
|
const d = data;
|
|
57
36
|
return {
|
|
58
37
|
kind: "base-map",
|
|
59
38
|
baseCount: Object.keys(d.bases ?? {}).length,
|
|
60
|
-
|
|
39
|
+
bases: Object.values(d.bases ?? {}).map((b) => b.name),
|
|
61
40
|
};
|
|
62
41
|
},
|
|
63
42
|
debugFields: (data) => {
|
|
64
43
|
const d = data;
|
|
65
44
|
return {
|
|
66
45
|
bases: Object.values(d.bases ?? {})
|
|
67
|
-
.map((
|
|
46
|
+
.map((b) => b.name)
|
|
68
47
|
.join(", "),
|
|
69
|
-
ownedCells: Object.keys(d.owner ?? {}).length,
|
|
70
48
|
};
|
|
71
49
|
},
|
|
72
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-map-shape.js","sourceRoot":"","sources":["../../src/base/base-map-shape.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"base-map-shape.js","sourceRoot":"","sources":["../../src/base/base-map-shape.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;AAWxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAQrC,MAAM,UAAU,SAAS,CAAC,KAAgB;IACzC,OAAO,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO;QACN,EAAE,EAAE,UAAU,EAAE;QAChB,IAAI,EAAE,UAAU;QAChB,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,CAAC;QACJ,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;QACjF,IAAI;QACJ,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,IAAI;KACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,IAAI,GAAW,YAAY;IACvE,OAAO;QACN,MAAM,EAAE,GAAG,EAAE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 @@
|
|
|
1
1
|
import type { BoardStore, CommandRegistry } from "@edv4h/usketch-shared";
|
|
2
|
-
import { type
|
|
3
|
-
import
|
|
2
|
+
import { type BaseInfo, type BaseMapShapeData } from "./base-map-shape.js";
|
|
3
|
+
import type { Territory } from "./territory.js";
|
|
4
4
|
export interface BaseDeps {
|
|
5
5
|
store: BoardStore;
|
|
6
6
|
commands: CommandRegistry;
|
|
7
7
|
tile: number;
|
|
8
8
|
}
|
|
9
9
|
/** Base id owning the cell at a world point, or null. */
|
|
10
|
-
export declare function baseIdAtWorld(
|
|
11
|
-
/**
|
|
12
|
-
* Connected land region (4-neighbour) starting at a cell — all cells reachable
|
|
13
|
-
* without crossing water/empty. `terrainCells` is the tilemap's cells; a cell is
|
|
14
|
-
* land when it exists and isn't "water". Returns the cell keys (empty if the
|
|
15
|
-
* start isn't land).
|
|
16
|
-
*/
|
|
17
|
-
export declare function landRegionFrom(terrainCells: Cells, startCol: number, startRow: number): string[];
|
|
18
|
-
/** Shallow equality of two ownership maps (same keys + base ids). */
|
|
19
|
-
export declare function ownersEqual(a: OwnerMap, b: OwnerMap): boolean;
|
|
10
|
+
export declare function baseIdAtWorld(territory: Territory, x: number, y: number, tile: number): string | null;
|
|
20
11
|
export interface BaseRegionAnchor {
|
|
21
12
|
baseId: string;
|
|
22
13
|
name: string;
|
|
@@ -27,24 +18,26 @@ export interface BaseRegionAnchor {
|
|
|
27
18
|
count: number;
|
|
28
19
|
}
|
|
29
20
|
/** One label anchor per base that owns at least one cell. */
|
|
30
|
-
export declare function baseRegionAnchors(
|
|
21
|
+
export declare function baseRegionAnchors(territory: Territory, bases: Record<string, BaseInfo>, tile: number): BaseRegionAnchor[];
|
|
31
22
|
/** The single shared base-map, creating it (live) if none exists yet. */
|
|
32
23
|
export declare function resolveBaseMap(store: BoardStore, tile: number): {
|
|
33
24
|
id: string;
|
|
34
25
|
created: boolean;
|
|
35
26
|
};
|
|
36
27
|
export declare function getBaseMap(store: BoardStore): BaseMapShapeData | undefined;
|
|
37
|
-
/** Create a new base (name +
|
|
28
|
+
/** Create a new base (name + colour, default radius); returns its id. Undoable. */
|
|
38
29
|
export declare function createBase(deps: BaseDeps, name: string, color: string): string;
|
|
39
|
-
/** Live owner snapshot (copy) of the base-map. */
|
|
40
|
-
export declare function currentOwner(store: BoardStore, id: string): OwnerMap;
|
|
41
|
-
/** Live update (non-undoable) used during a paint stroke. */
|
|
42
|
-
export declare function applyOwner(store: BoardStore, id: string, owner: OwnerMap, tile: number): void;
|
|
43
|
-
/** Commit an owner change as one undoable command (undo restores `prevOwner`). */
|
|
44
|
-
export declare function commitOwner(deps: BaseDeps, id: string, prevOwner: OwnerMap): void;
|
|
45
30
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
31
|
+
* Make `iconId` the (single) beacon of `baseId`. Enforces 1:1 — the base's prior
|
|
32
|
+
* beacon icon and any other base that referenced `iconId` are detached. Records
|
|
33
|
+
* `meta.baseId` on the involved icons for the radius ring. Undoable. No-op if the
|
|
34
|
+
* base or icon is missing, or the icon is already this base's beacon.
|
|
35
|
+
*/
|
|
36
|
+
export declare function setBeacon(deps: BaseDeps, iconId: string, baseId: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Remove a base from the registry (its derived territory disappears). Also clears
|
|
39
|
+
* `meta.baseId` on the base's beacon icon, if any — the icon itself is kept.
|
|
40
|
+
* Undoable. No-op if the base doesn't exist.
|
|
48
41
|
*/
|
|
49
|
-
export declare function
|
|
42
|
+
export declare function deleteBase(deps: BaseDeps, baseId: string): void;
|
|
50
43
|
//# sourceMappingURL=base-ops.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-ops.d.ts","sourceRoot":"","sources":["../../src/base/base-ops.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAW,eAAe,EAAa,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"base-ops.d.ts","sourceRoot":"","sources":["../../src/base/base-ops.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,MAAM,GAAG,MAAM,CAe9E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CA6C9E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAoC/D"}
|
package/dist/base/base-ops.js
CHANGED
|
@@ -1,64 +1,17 @@
|
|
|
1
1
|
import { generateId } from "@edv4h/usketch-shared";
|
|
2
2
|
import { cellKey, parseCellKey, worldToCell } from "../autotile.js";
|
|
3
|
-
import {
|
|
4
|
-
import { isBaseMap, makeBaseMap,
|
|
5
|
-
const MAX_ISLAND_CELLS = 100_000; // safety bound for the flood
|
|
3
|
+
import { MAP_ICON_TYPE } from "../map-icon-shape.js";
|
|
4
|
+
import { DEFAULT_BASE_RADIUS, isBaseMap, makeBaseMap, } from "./base-map-shape.js";
|
|
6
5
|
// ── Pure ─────────────────────────────────────────────────────────────────────
|
|
7
6
|
/** Base id owning the cell at a world point, or null. */
|
|
8
|
-
export function baseIdAtWorld(
|
|
7
|
+
export function baseIdAtWorld(territory, x, y, tile) {
|
|
9
8
|
const [c, r] = worldToCell(x, y, tile);
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Connected land region (4-neighbour) starting at a cell — all cells reachable
|
|
14
|
-
* without crossing water/empty. `terrainCells` is the tilemap's cells; a cell is
|
|
15
|
-
* land when it exists and isn't "water". Returns the cell keys (empty if the
|
|
16
|
-
* start isn't land).
|
|
17
|
-
*/
|
|
18
|
-
export function landRegionFrom(terrainCells, startCol, startRow) {
|
|
19
|
-
const isLand = (c, r) => {
|
|
20
|
-
const t = terrainCells[cellKey(c, r)];
|
|
21
|
-
return t !== undefined && t !== "water";
|
|
22
|
-
};
|
|
23
|
-
if (!isLand(startCol, startRow))
|
|
24
|
-
return [];
|
|
25
|
-
const out = [];
|
|
26
|
-
const seen = new Set();
|
|
27
|
-
const stack = [[startCol, startRow]];
|
|
28
|
-
while (stack.length) {
|
|
29
|
-
// Cap hit → the region is too large to own atomically; abort rather than
|
|
30
|
-
// assign only a truncated part of the landmass.
|
|
31
|
-
if (out.length >= MAX_ISLAND_CELLS)
|
|
32
|
-
return [];
|
|
33
|
-
const next = stack.pop();
|
|
34
|
-
if (!next)
|
|
35
|
-
break;
|
|
36
|
-
const [c, r] = next;
|
|
37
|
-
const key = cellKey(c, r);
|
|
38
|
-
if (seen.has(key))
|
|
39
|
-
continue;
|
|
40
|
-
if (!isLand(c, r))
|
|
41
|
-
continue;
|
|
42
|
-
seen.add(key);
|
|
43
|
-
out.push(key);
|
|
44
|
-
stack.push([c + 1, r], [c - 1, r], [c, r + 1], [c, r - 1]);
|
|
45
|
-
}
|
|
46
|
-
return out;
|
|
47
|
-
}
|
|
48
|
-
/** Shallow equality of two ownership maps (same keys + base ids). */
|
|
49
|
-
export function ownersEqual(a, b) {
|
|
50
|
-
const ak = Object.keys(a);
|
|
51
|
-
if (ak.length !== Object.keys(b).length)
|
|
52
|
-
return false;
|
|
53
|
-
for (const k of ak)
|
|
54
|
-
if (a[k] !== b[k])
|
|
55
|
-
return false;
|
|
56
|
-
return true;
|
|
9
|
+
return territory[cellKey(c, r)] ?? null;
|
|
57
10
|
}
|
|
58
11
|
/** One label anchor per base that owns at least one cell. */
|
|
59
|
-
export function baseRegionAnchors(
|
|
12
|
+
export function baseRegionAnchors(territory, bases, tile) {
|
|
60
13
|
const acc = new Map();
|
|
61
|
-
for (const [key, baseId] of Object.entries(
|
|
14
|
+
for (const [key, baseId] of Object.entries(territory)) {
|
|
62
15
|
const [c, r] = parseCellKey(key);
|
|
63
16
|
const a = acc.get(baseId);
|
|
64
17
|
if (!a)
|
|
@@ -94,9 +47,9 @@ export function resolveBaseMap(store, tile) {
|
|
|
94
47
|
if (isBaseMap(s))
|
|
95
48
|
return { id: s.id, created: false };
|
|
96
49
|
}
|
|
97
|
-
const
|
|
98
|
-
store.addShape(
|
|
99
|
-
return { id:
|
|
50
|
+
const bm = makeBaseMap(tile);
|
|
51
|
+
store.addShape(bm);
|
|
52
|
+
return { id: bm.id, created: true };
|
|
100
53
|
}
|
|
101
54
|
export function getBaseMap(store) {
|
|
102
55
|
for (const [, s] of store.getShapes())
|
|
@@ -104,19 +57,16 @@ export function getBaseMap(store) {
|
|
|
104
57
|
return s;
|
|
105
58
|
return undefined;
|
|
106
59
|
}
|
|
107
|
-
|
|
108
|
-
for (const [, s] of store.getShapes())
|
|
109
|
-
if (isTileMap(s))
|
|
110
|
-
return s;
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
/** Create a new base (name + color); returns its id. Undoable. */
|
|
60
|
+
/** Create a new base (name + colour, default radius); returns its id. Undoable. */
|
|
114
61
|
export function createBase(deps, name, color) {
|
|
115
62
|
const { id } = resolveBaseMap(deps.store, deps.tile);
|
|
116
63
|
const shape = deps.store.getShape(id);
|
|
117
64
|
const baseId = generateId();
|
|
118
65
|
const prevBases = { ...(shape?.bases ?? {}) };
|
|
119
|
-
const nextBases = {
|
|
66
|
+
const nextBases = {
|
|
67
|
+
...prevBases,
|
|
68
|
+
[baseId]: { name, color, radius: DEFAULT_BASE_RADIUS },
|
|
69
|
+
};
|
|
120
70
|
const command = {
|
|
121
71
|
execute: () => deps.store.updateShape(id, { bases: nextBases }),
|
|
122
72
|
undo: () => deps.store.updateShape(id, { bases: prevBases }),
|
|
@@ -124,52 +74,102 @@ export function createBase(deps, name, color) {
|
|
|
124
74
|
deps.commands.execute(command);
|
|
125
75
|
return baseId;
|
|
126
76
|
}
|
|
127
|
-
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
export function
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
/** Commit an owner change as one undoable command (undo restores `prevOwner`). */
|
|
137
|
-
export function commitOwner(deps, id, prevOwner) {
|
|
77
|
+
/**
|
|
78
|
+
* Make `iconId` the (single) beacon of `baseId`. Enforces 1:1 — the base's prior
|
|
79
|
+
* beacon icon and any other base that referenced `iconId` are detached. Records
|
|
80
|
+
* `meta.baseId` on the involved icons for the radius ring. Undoable. No-op if the
|
|
81
|
+
* base or icon is missing, or the icon is already this base's beacon.
|
|
82
|
+
*/
|
|
83
|
+
export function setBeacon(deps, iconId, baseId) {
|
|
84
|
+
const { id } = resolveBaseMap(deps.store, deps.tile);
|
|
138
85
|
const shape = deps.store.getShape(id);
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
return;
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
86
|
+
const base = shape?.bases[baseId];
|
|
87
|
+
if (!shape || !base)
|
|
88
|
+
return;
|
|
89
|
+
const icon = deps.store.getShape(iconId);
|
|
90
|
+
if (!icon || icon.type !== MAP_ICON_TYPE)
|
|
91
|
+
return;
|
|
92
|
+
if (base.beaconIconId === iconId)
|
|
93
|
+
return; // no change
|
|
94
|
+
const prevBases = shape.bases;
|
|
95
|
+
const prevBeaconId = base.beaconIconId;
|
|
96
|
+
// New registry: set this base's beacon, and clear `iconId` from any other base.
|
|
97
|
+
const nextBases = {};
|
|
98
|
+
for (const [bid, info] of Object.entries(prevBases)) {
|
|
99
|
+
if (bid === baseId)
|
|
100
|
+
nextBases[bid] = { ...info, beaconIconId: iconId };
|
|
101
|
+
else if (info.beaconIconId === iconId)
|
|
102
|
+
nextBases[bid] = { ...info, beaconIconId: undefined };
|
|
103
|
+
else
|
|
104
|
+
nextBases[bid] = info;
|
|
105
|
+
}
|
|
106
|
+
// Icon meta edits: link the new beacon; unlink the base's previous beacon.
|
|
107
|
+
const edits = [
|
|
108
|
+
{ id: iconId, prev: icon.meta, next: { ...icon.meta, baseId } },
|
|
109
|
+
];
|
|
110
|
+
if (prevBeaconId && prevBeaconId !== iconId) {
|
|
111
|
+
const prevIcon = deps.store.getShape(prevBeaconId);
|
|
112
|
+
if (prevIcon) {
|
|
113
|
+
edits.push({
|
|
114
|
+
id: prevBeaconId,
|
|
115
|
+
prev: prevIcon.meta,
|
|
116
|
+
next: { ...prevIcon.meta, baseId: undefined },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
145
120
|
const command = {
|
|
146
|
-
execute: () =>
|
|
147
|
-
|
|
121
|
+
execute: () => {
|
|
122
|
+
deps.store.updateShape(id, { bases: nextBases });
|
|
123
|
+
for (const e of edits)
|
|
124
|
+
deps.store.updateShape(e.id, { meta: e.next });
|
|
125
|
+
},
|
|
126
|
+
undo: () => {
|
|
127
|
+
deps.store.updateShape(id, { bases: prevBases });
|
|
128
|
+
for (const e of edits)
|
|
129
|
+
deps.store.updateShape(e.id, { meta: e.prev });
|
|
130
|
+
},
|
|
148
131
|
};
|
|
149
132
|
deps.commands.execute(command);
|
|
150
133
|
}
|
|
151
134
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
135
|
+
* Remove a base from the registry (its derived territory disappears). Also clears
|
|
136
|
+
* `meta.baseId` on the base's beacon icon, if any — the icon itself is kept.
|
|
137
|
+
* Undoable. No-op if the base doesn't exist.
|
|
154
138
|
*/
|
|
155
|
-
export function
|
|
156
|
-
const tilemap = findTilemap(deps.store);
|
|
157
|
-
if (!tilemap)
|
|
158
|
-
return;
|
|
159
|
-
const [c, r] = worldToCell(x, y, tilemap.tile ?? deps.tile);
|
|
160
|
-
const keys = landRegionFrom(tilemap.cells, c, r);
|
|
161
|
-
if (keys.length === 0)
|
|
162
|
-
return;
|
|
139
|
+
export function deleteBase(deps, baseId) {
|
|
163
140
|
const { id } = resolveBaseMap(deps.store, deps.tile);
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
const
|
|
141
|
+
const shape = deps.store.getShape(id);
|
|
142
|
+
const base = shape?.bases[baseId];
|
|
143
|
+
if (!shape || !base)
|
|
144
|
+
return;
|
|
145
|
+
const prevBases = shape.bases;
|
|
146
|
+
const nextBases = {};
|
|
147
|
+
for (const [bid, info] of Object.entries(prevBases)) {
|
|
148
|
+
if (bid !== baseId)
|
|
149
|
+
nextBases[bid] = info;
|
|
150
|
+
}
|
|
151
|
+
const edits = [];
|
|
152
|
+
if (base.beaconIconId) {
|
|
153
|
+
const icon = deps.store.getShape(base.beaconIconId);
|
|
154
|
+
if (icon && icon.type === MAP_ICON_TYPE) {
|
|
155
|
+
edits.push({
|
|
156
|
+
id: base.beaconIconId,
|
|
157
|
+
prev: icon.meta,
|
|
158
|
+
next: { ...icon.meta, baseId: undefined },
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
170
162
|
const command = {
|
|
171
|
-
execute: () =>
|
|
172
|
-
|
|
163
|
+
execute: () => {
|
|
164
|
+
deps.store.updateShape(id, { bases: nextBases });
|
|
165
|
+
for (const e of edits)
|
|
166
|
+
deps.store.updateShape(e.id, { meta: e.next });
|
|
167
|
+
},
|
|
168
|
+
undo: () => {
|
|
169
|
+
deps.store.updateShape(id, { bases: prevBases });
|
|
170
|
+
for (const e of edits)
|
|
171
|
+
deps.store.updateShape(e.id, { meta: e.prev });
|
|
172
|
+
},
|
|
173
173
|
};
|
|
174
174
|
deps.commands.execute(command);
|
|
175
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-ops.js","sourceRoot":"","sources":["../../src/base/base-ops.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"base-ops.js","sourceRoot":"","sources":["../../src/base/base-ops.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAyB,MAAM,sBAAsB,CAAC;AAC5E,OA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C,IAAI,KAAK;gBAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAwB,CAAC,CAAC;QAC7F,CAAC;QACD,IAAI,EAAE,GAAG,EAAE;YACV,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAwB,CAAC,CAAC;YACvE,KAAK,MAAM,CAAC,IAAI,KAAK;gBAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAwB,CAAC,CAAC;QAC7F,CAAC;KACD,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TerrainKey } from "../terrain.js";
|
|
2
2
|
export interface BaseToolState {
|
|
3
3
|
/** Currently selected base id, or null when none is chosen yet. */
|
|
4
4
|
activeBaseId: string | null;
|
|
5
|
-
|
|
5
|
+
/** Terrains that block territory growth (e.g. water). Global for all bases. */
|
|
6
|
+
excludeTerrains: TerrainKey[];
|
|
6
7
|
}
|
|
7
8
|
export declare const baseStateStore: import("../reactive-store.js").ReactiveStore<BaseToolState>;
|
|
8
9
|
export declare function useBaseState(): BaseToolState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-state.d.ts","sourceRoot":"","sources":["../../src/base/base-state.ts"],"names":[],"mappings":"AAMA,
|
|
1
|
+
{"version":3,"file":"base-state.d.ts","sourceRoot":"","sources":["../../src/base/base-state.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC7B,mEAAmE;IACnE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,+EAA+E;IAC/E,eAAe,EAAE,UAAU,EAAE,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,6DAGzB,CAAC;AAEH,wBAAgB,YAAY,IAAI,aAAa,CAE5C"}
|