dsh-game-material-master 0.9.2 → 0.10.1
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.en.md +66 -39
- package/README.md +56 -34
- package/lib/bitmap.js +2 -2
- package/lib/client.js +1839 -2016
- package/lib/config.js +25 -3
- package/lib/imagegen.js +3 -3
- package/lib/imageprovider.js +28 -0
- package/lib/index.js +176 -302
- package/lib/isocompose.js +256 -0
- package/lib/isodoc.js +705 -0
- package/lib/isoexport.js +140 -0
- package/lib/isogen.js +1479 -0
- package/lib/isogeom.js +359 -0
- package/lib/isorender.js +471 -0
- package/lib/isosamplegen.js +296 -0
- package/lib/isotiles.js +243 -0
- package/lib/links.js +13 -12
- package/lib/mapexport.js +1 -1
- package/lib/mapgeom.js +1 -1
- package/lib/maprender.js +1 -1
- package/lib/musicguide.js +1 -1
- package/lib/musicscoreguide.js +4 -4
- package/lib/riggen.js +6 -6
- package/lib/seqgen.js +7 -7
- package/lib/sfxgen.js +3 -3
- package/lib/store.js +1 -1
- package/lib/toapis.js +338 -0
- package/lib/toolguides.js +488 -0
- package/lib/tools.js +448 -417
- package/lib/videogen.js +15 -1
- package/lib/wire.js +110 -70
- package/package.json +6 -3
- package/lib/tilegen.js +0 -1699
- package/lib/tilegeom.js +0 -1392
- package/lib/tilemap.js +0 -560
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 45° 地图编辑器(模块五 · iso)的**内置示例素材**生成器。
|
|
3
|
+
*
|
|
4
|
+
* 纯程序化、确定性、零外部请求、零计费。每次生成同一份输入 → 逐字节一致,
|
|
5
|
+
* 所以「恢复默认素材」不会因为时间 / 随机数变出另一套画风。
|
|
6
|
+
*
|
|
7
|
+
* 约定与 `isotiles` 完全一致:
|
|
8
|
+
* - 地面:每格一张图,菱形在单元格里居中;
|
|
9
|
+
* - 自动连接:严格 4×4 = 16 块,行优先 mask 0..15,N=1 / E=2 / S=4 / W=8;
|
|
10
|
+
* - 物件:一张完整图,透明背景,底面中心在图片底边中点,可以高出单元格。
|
|
11
|
+
*/
|
|
12
|
+
import { encodePng } from "./png.js";
|
|
13
|
+
import { DEFAULT_ISO_CELL } from "./isogeom.js";
|
|
14
|
+
function makeBitmap(width, height) {
|
|
15
|
+
return { width, height, rgba: Buffer.alloc(width * height * 4) };
|
|
16
|
+
}
|
|
17
|
+
function hash(x, y, seed) {
|
|
18
|
+
let h = (x * 374761393 + y * 668265263 + seed * 1442695040888963407) >>> 0;
|
|
19
|
+
h = Math.imul(h ^ (h >>> 13), 1274126177) >>> 0;
|
|
20
|
+
return (h ^ (h >>> 16)) >>> 0;
|
|
21
|
+
}
|
|
22
|
+
function setPixel(bitmap, x, y, color, alpha = 255) {
|
|
23
|
+
if (x < 0 || y < 0 || x >= bitmap.width || y >= bitmap.height || alpha <= 0)
|
|
24
|
+
return;
|
|
25
|
+
const offset = (Math.floor(y) * bitmap.width + Math.floor(x)) * 4;
|
|
26
|
+
const a = Math.min(1, alpha / 255);
|
|
27
|
+
const inv = 1 - a;
|
|
28
|
+
bitmap.rgba[offset] = Math.round(color.r * a + bitmap.rgba[offset] * inv);
|
|
29
|
+
bitmap.rgba[offset + 1] = Math.round(color.g * a + bitmap.rgba[offset + 1] * inv);
|
|
30
|
+
bitmap.rgba[offset + 2] = Math.round(color.b * a + bitmap.rgba[offset + 2] * inv);
|
|
31
|
+
bitmap.rgba[offset + 3] = Math.max(bitmap.rgba[offset + 3], Math.round(a * 255));
|
|
32
|
+
}
|
|
33
|
+
function inDiamond(x, y, cell) {
|
|
34
|
+
const cx = cell.width / 2;
|
|
35
|
+
const cy = cell.height / 2;
|
|
36
|
+
return Math.abs(x + 0.5 - cx) / (cell.width / 2) + Math.abs(y + 0.5 - cy) / (cell.width / 4) <= 1;
|
|
37
|
+
}
|
|
38
|
+
function fillDiamond(bitmap, cell, originX, originY, color, shade) {
|
|
39
|
+
const cx = originX + cell.width / 2;
|
|
40
|
+
const cy = originY + cell.height / 2;
|
|
41
|
+
const halfW = cell.width / 2;
|
|
42
|
+
const halfH = cell.width / 4;
|
|
43
|
+
for (let y = Math.floor(cy - halfH); y <= Math.ceil(cy + halfH); y++) {
|
|
44
|
+
for (let x = Math.floor(cx - halfW); x <= Math.ceil(cx + halfW); x++) {
|
|
45
|
+
const d = Math.abs(x + 0.5 - cx) / halfW + Math.abs(y + 0.5 - cy) / halfH;
|
|
46
|
+
// 多铺 1%:相邻菱形共享的那条边必须两边都盖到,否则会留一条透明缝
|
|
47
|
+
// (真机表现就是水面上每一格都有一圈深色网格线)。
|
|
48
|
+
if (d > 1.01)
|
|
49
|
+
continue;
|
|
50
|
+
const edge = shade !== undefined && d > 0.9;
|
|
51
|
+
setPixel(bitmap, x, y, edge ? shade : color, 255);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function fillTriangle(bitmap, points, color, alpha = 255) {
|
|
56
|
+
const minX = Math.floor(Math.min(...points.map((point) => point[0])));
|
|
57
|
+
const maxX = Math.ceil(Math.max(...points.map((point) => point[0])));
|
|
58
|
+
const minY = Math.floor(Math.min(...points.map((point) => point[1])));
|
|
59
|
+
const maxY = Math.ceil(Math.max(...points.map((point) => point[1])));
|
|
60
|
+
const edge = (a, b, px, py) => (px - a[0]) * (b[1] - a[1]) - (py - a[1]) * (b[0] - a[0]);
|
|
61
|
+
const [a, b, c] = points;
|
|
62
|
+
const area = edge(a, b, c[0], c[1]);
|
|
63
|
+
if (area === 0)
|
|
64
|
+
return;
|
|
65
|
+
for (let y = minY; y <= maxY; y++) {
|
|
66
|
+
for (let x = minX; x <= maxX; x++) {
|
|
67
|
+
const px = x + 0.5;
|
|
68
|
+
const py = y + 0.5;
|
|
69
|
+
const e0 = edge(a, b, px, py);
|
|
70
|
+
const e1 = edge(b, c, px, py);
|
|
71
|
+
const e2 = edge(c, a, px, py);
|
|
72
|
+
if ((e0 >= 0 && e1 >= 0 && e2 >= 0) || (e0 <= 0 && e1 <= 0 && e2 <= 0))
|
|
73
|
+
setPixel(bitmap, x, y, color, alpha);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function fillRect(bitmap, x, y, width, height, color, alpha = 255) {
|
|
78
|
+
for (let yy = Math.floor(y); yy < Math.ceil(y + height); yy++) {
|
|
79
|
+
for (let xx = Math.floor(x); xx < Math.ceil(x + width); xx++)
|
|
80
|
+
setPixel(bitmap, xx, yy, color, alpha);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function fillEllipse(bitmap, cx, cy, rx, ry, color, alpha = 255) {
|
|
84
|
+
for (let y = Math.floor(cy - ry); y <= Math.ceil(cy + ry); y++) {
|
|
85
|
+
for (let x = Math.floor(cx - rx); x <= Math.ceil(cx + rx); x++) {
|
|
86
|
+
const dx = (x + 0.5 - cx) / rx;
|
|
87
|
+
const dy = (y + 0.5 - cy) / ry;
|
|
88
|
+
if (dx * dx + dy * dy <= 1)
|
|
89
|
+
setPixel(bitmap, x, y, color, alpha);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const COLORS = {
|
|
94
|
+
grass: { r: 96, g: 168, b: 84 },
|
|
95
|
+
grassDark: { r: 62, g: 124, b: 60 },
|
|
96
|
+
grassLight: { r: 142, g: 198, b: 96 },
|
|
97
|
+
dirt: { r: 166, g: 126, b: 82 },
|
|
98
|
+
dirtDark: { r: 122, g: 88, b: 56 },
|
|
99
|
+
stone: { r: 142, g: 146, b: 152 },
|
|
100
|
+
stoneDark: { r: 96, g: 100, b: 108 },
|
|
101
|
+
water: { r: 64, g: 128, b: 198 },
|
|
102
|
+
waterDark: { r: 38, g: 92, b: 158 },
|
|
103
|
+
sand: { r: 214, g: 192, b: 132 },
|
|
104
|
+
sandDark: { r: 178, g: 154, b: 96 },
|
|
105
|
+
trunk: { r: 112, g: 76, b: 48 },
|
|
106
|
+
leaf: { r: 58, g: 132, b: 66 },
|
|
107
|
+
leafDark: { r: 38, g: 96, b: 50 },
|
|
108
|
+
roof: { r: 158, g: 78, b: 58 },
|
|
109
|
+
roofDark: { r: 112, g: 52, b: 42 },
|
|
110
|
+
wall: { r: 206, g: 194, b: 166 },
|
|
111
|
+
wallDark: { r: 160, g: 148, b: 122 }
|
|
112
|
+
};
|
|
113
|
+
/** 一张地面图的单个格子(带一点确定性纹理,避免纯色看起来像塑料)。 */
|
|
114
|
+
function drawGroundTile(bitmap, cell, originX, originY, base, dark, seed) {
|
|
115
|
+
// 地面是「一整片」而不是一块块铺的:**不要给每格加边线**,否则相邻两格各压一道
|
|
116
|
+
// 深色边,拼起来就是一张网格。纹理也只在内部随机,不碰菱形边。
|
|
117
|
+
fillDiamond(bitmap, cell, originX, originY, base);
|
|
118
|
+
const cx = originX + cell.width / 2;
|
|
119
|
+
const cy = originY + cell.height / 2;
|
|
120
|
+
const count = Math.max(8, Math.round(cell.width * 0.7));
|
|
121
|
+
for (let i = 0; i < count; i++) {
|
|
122
|
+
const angle = (hash(i, seed, 1) % 10000) / 10000;
|
|
123
|
+
const q = (hash(i, seed, 2) % 10000) / 10000;
|
|
124
|
+
const dx = (q - 0.5) * cell.width * 0.7;
|
|
125
|
+
const dy = (angle - 0.5) * cell.width * 0.34;
|
|
126
|
+
const x = Math.floor(cx + dx + dy * 2);
|
|
127
|
+
const y = Math.floor(cy + dy - dx * 0.5);
|
|
128
|
+
if (!inDiamond(x, y, cell))
|
|
129
|
+
continue;
|
|
130
|
+
const light = (hash(i, seed, 3) & 1) === 0;
|
|
131
|
+
setPixel(bitmap, x, y, light ? COLORS.grassLight : dark, 180);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function drawWaterTile(bitmap, cell, originX, originY, frame) {
|
|
135
|
+
/**
|
|
136
|
+
* 内置水面用**整块同色**,只按帧轻微变色。
|
|
137
|
+
*
|
|
138
|
+
* 为什么不做条纹 / 波纹:单块图块要在所有格子上重复,任何「只有内部有、边缘没有」
|
|
139
|
+
* 的纹理都会在相邻两格之间留下一条底色边;等距菱形上就连成一张深色网格线
|
|
140
|
+
* (真机截图:「素材拼起来有缝」)。整块同色在任意拼接下都没有接缝。
|
|
141
|
+
*/
|
|
142
|
+
const shade = frame % 2 === 0 ? { r: 64, g: 128, b: 198 } : { r: 74, g: 140, b: 208 };
|
|
143
|
+
fillDiamond(bitmap, cell, originX, originY, shade);
|
|
144
|
+
}
|
|
145
|
+
function drawAutotileTile(bitmap, cell, originX, originY, mask) {
|
|
146
|
+
fillDiamond(bitmap, cell, originX, originY, COLORS.sand, COLORS.sandDark);
|
|
147
|
+
const cx = originX + cell.width / 2;
|
|
148
|
+
const cy = originY + cell.height / 2;
|
|
149
|
+
const top = [cx, cy - cell.width / 4];
|
|
150
|
+
const right = [cx + cell.width / 2, cy];
|
|
151
|
+
const bottom = [cx, cy + cell.width / 4];
|
|
152
|
+
const left = [cx - cell.width / 2, cy];
|
|
153
|
+
const center = [cx, cy];
|
|
154
|
+
if ((mask & 1) !== 0)
|
|
155
|
+
fillTriangle(bitmap, [top, right, center], COLORS.water);
|
|
156
|
+
if ((mask & 2) !== 0)
|
|
157
|
+
fillTriangle(bitmap, [right, bottom, center], COLORS.water);
|
|
158
|
+
if ((mask & 4) !== 0)
|
|
159
|
+
fillTriangle(bitmap, [bottom, left, center], COLORS.water);
|
|
160
|
+
if ((mask & 8) !== 0)
|
|
161
|
+
fillTriangle(bitmap, [left, top, center], COLORS.water);
|
|
162
|
+
// 岸线:水与沙之间压一道深色,避免两种纯色直接相接。
|
|
163
|
+
for (let y = Math.floor(cy - cell.width / 4); y <= Math.ceil(cy + cell.width / 4); y++) {
|
|
164
|
+
for (let x = Math.floor(cx - cell.width / 2); x <= Math.ceil(cx + cell.width / 2); x++) {
|
|
165
|
+
if (!inDiamond(x, y, cell))
|
|
166
|
+
continue;
|
|
167
|
+
const offset = (Math.floor(y) * bitmap.width + Math.floor(x)) * 4;
|
|
168
|
+
if (bitmap.rgba[offset + 3] === 0)
|
|
169
|
+
continue;
|
|
170
|
+
const nearWater = [[1, 0], [-1, 0], [0, 1], [0, -1]].some(([dx, dy]) => {
|
|
171
|
+
const nx = Math.floor(x) + dx;
|
|
172
|
+
const ny = Math.floor(y) + dy;
|
|
173
|
+
if (nx < 0 || ny < 0 || nx >= bitmap.width || ny >= bitmap.height)
|
|
174
|
+
return false;
|
|
175
|
+
const no = (ny * bitmap.width + nx) * 4;
|
|
176
|
+
return bitmap.rgba[no + 3] > 0 && bitmap.rgba[no + 2] > bitmap.rgba[no] + 20;
|
|
177
|
+
});
|
|
178
|
+
if (nearWater && bitmap.rgba[offset + 2] <= bitmap.rgba[offset] + 20)
|
|
179
|
+
setPixel(bitmap, x, y, COLORS.sandDark, 200);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function drawTree(bitmap, cell, footprint) {
|
|
184
|
+
const width = cell.width * footprint.cols;
|
|
185
|
+
const height = Math.round(cell.height * 1.35);
|
|
186
|
+
// bitmap 已由调用方按 width×height 建好
|
|
187
|
+
const base = height;
|
|
188
|
+
fillRect(bitmap, width / 2 - Math.max(3, Math.round(cell.width * 0.07)), base - Math.round(cell.width * 0.62), Math.max(6, Math.round(cell.width * 0.14)), Math.round(cell.width * 0.62), COLORS.trunk);
|
|
189
|
+
fillEllipse(bitmap, width / 2, base - Math.round(cell.width * 0.78), cell.width * 0.34, cell.width * 0.26, COLORS.leafDark);
|
|
190
|
+
fillEllipse(bitmap, width / 2 - cell.width * 0.16, base - Math.round(cell.width * 0.82), cell.width * 0.25, cell.width * 0.2, COLORS.leaf);
|
|
191
|
+
fillEllipse(bitmap, width / 2 + cell.width * 0.16, base - Math.round(cell.width * 0.8), cell.width * 0.24, cell.width * 0.2, COLORS.leaf);
|
|
192
|
+
fillEllipse(bitmap, width / 2, base - Math.round(cell.width * 0.98), cell.width * 0.28, cell.width * 0.22, COLORS.leaf);
|
|
193
|
+
return new Array(footprint.cols * footprint.rows).fill(1);
|
|
194
|
+
}
|
|
195
|
+
function drawRock(bitmap, cell, footprint) {
|
|
196
|
+
const width = cell.width * footprint.cols;
|
|
197
|
+
const height = Math.round(cell.height * 0.72);
|
|
198
|
+
fillEllipse(bitmap, width / 2, height - cell.width * 0.18, cell.width * 0.32, cell.width * 0.2, COLORS.stoneDark);
|
|
199
|
+
fillEllipse(bitmap, width / 2 - cell.width * 0.05, height - cell.width * 0.22, cell.width * 0.26, cell.width * 0.17, COLORS.stone);
|
|
200
|
+
fillRect(bitmap, width / 2 - cell.width * 0.22, height - cell.width * 0.16, cell.width * 0.44, cell.width * 0.08, COLORS.stoneDark);
|
|
201
|
+
return new Array(footprint.cols * footprint.rows).fill(1);
|
|
202
|
+
}
|
|
203
|
+
function drawBush(bitmap, cell, footprint) {
|
|
204
|
+
const width = cell.width * footprint.cols;
|
|
205
|
+
const height = Math.round(cell.height * 0.62);
|
|
206
|
+
fillEllipse(bitmap, width / 2, height - cell.width * 0.18, cell.width * 0.3, cell.width * 0.18, COLORS.leafDark);
|
|
207
|
+
fillEllipse(bitmap, width / 2 - cell.width * 0.12, height - cell.width * 0.22, cell.width * 0.2, cell.width * 0.14, COLORS.leaf);
|
|
208
|
+
fillEllipse(bitmap, width / 2 + cell.width * 0.12, height - cell.width * 0.22, cell.width * 0.18, cell.width * 0.13, COLORS.leaf);
|
|
209
|
+
return new Array(footprint.cols * footprint.rows).fill(1);
|
|
210
|
+
}
|
|
211
|
+
function drawBarrel(bitmap, cell, footprint) {
|
|
212
|
+
const width = cell.width * footprint.cols;
|
|
213
|
+
const height = Math.round(cell.height * 0.6);
|
|
214
|
+
fillRect(bitmap, width / 2 - cell.width * 0.18, height - cell.width * 0.42, cell.width * 0.36, cell.width * 0.42, COLORS.dirtDark);
|
|
215
|
+
fillRect(bitmap, width / 2 - cell.width * 0.18, height - cell.width * 0.36, cell.width * 0.36, cell.width * 0.05, COLORS.stoneDark);
|
|
216
|
+
fillRect(bitmap, width / 2 - cell.width * 0.18, height - cell.width * 0.22, cell.width * 0.36, cell.width * 0.05, COLORS.stoneDark);
|
|
217
|
+
return new Array(footprint.cols * footprint.rows).fill(1);
|
|
218
|
+
}
|
|
219
|
+
function drawHouse(bitmap, cell, footprint) {
|
|
220
|
+
const width = cell.width * footprint.cols;
|
|
221
|
+
const height = Math.round(cell.height * 1.65);
|
|
222
|
+
const wallW = width * 0.62;
|
|
223
|
+
const wallH = height * 0.42;
|
|
224
|
+
const left = (width - wallW) / 2;
|
|
225
|
+
const wallTop = height - wallH;
|
|
226
|
+
fillRect(bitmap, left, wallTop, wallW, wallH, COLORS.wall);
|
|
227
|
+
fillRect(bitmap, left, wallTop + wallH - cell.width * 0.06, wallW, cell.width * 0.06, COLORS.wallDark);
|
|
228
|
+
// 屋顶:一个梯形 + 深色檐口
|
|
229
|
+
for (let y = 0; y < Math.round(wallH * 0.9); y++) {
|
|
230
|
+
const t = y / Math.max(1, wallH * 0.9);
|
|
231
|
+
const half = (wallW * (0.62 + 0.38 * t)) / 2;
|
|
232
|
+
fillRect(bitmap, width / 2 - half, wallTop - Math.round(wallH * 0.9) + y, half * 2, 1, t > 0.82 ? COLORS.roofDark : COLORS.roof);
|
|
233
|
+
}
|
|
234
|
+
fillRect(bitmap, width / 2 - cell.width * 0.07, height - wallH - cell.width * 0.02, cell.width * 0.14, wallH * 0.5, COLORS.roofDark);
|
|
235
|
+
fillRect(bitmap, left + wallW * 0.16, wallTop + wallH * 0.22, wallW * 0.16, wallH * 0.22, COLORS.waterDark);
|
|
236
|
+
fillRect(bitmap, left + wallW * 0.68, wallTop + wallH * 0.22, wallW * 0.16, wallH * 0.22, COLORS.waterDark);
|
|
237
|
+
return new Array(footprint.cols * footprint.rows).fill(1);
|
|
238
|
+
}
|
|
239
|
+
function sample(name, file, kind, cell, bitmap, extra) {
|
|
240
|
+
return {
|
|
241
|
+
name,
|
|
242
|
+
file,
|
|
243
|
+
kind,
|
|
244
|
+
cell,
|
|
245
|
+
builtin: true,
|
|
246
|
+
bytes: encodePng(bitmap.rgba, bitmap.width, bitmap.height),
|
|
247
|
+
...extra
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/** 生成整套内置素材。同一 `cell` 两次生成逐字节一致。 */
|
|
251
|
+
export function renderIsoSamples(cell = DEFAULT_ISO_CELL) {
|
|
252
|
+
const out = [];
|
|
253
|
+
// 地面:静态 2 个变体;水面 2 个变体 × 2 帧。
|
|
254
|
+
const groundDefs = [
|
|
255
|
+
{ name: "草地", file: "iso-grass.png", base: COLORS.grass, dark: COLORS.grassDark, frames: 1, animRows: false },
|
|
256
|
+
{ name: "泥土", file: "iso-dirt.png", base: COLORS.dirt, dark: COLORS.dirtDark, frames: 1, animRows: false },
|
|
257
|
+
{ name: "石地", file: "iso-stone.png", base: COLORS.stone, dark: COLORS.stoneDark, frames: 1, animRows: false },
|
|
258
|
+
{ name: "水面", file: "iso-water.png", base: COLORS.water, dark: COLORS.waterDark, frames: 2, animRows: true, water: true }
|
|
259
|
+
];
|
|
260
|
+
for (const [index, def] of groundDefs.entries()) {
|
|
261
|
+
const columns = 2;
|
|
262
|
+
const bitmap = makeBitmap(cell.width * columns, cell.height * def.frames);
|
|
263
|
+
for (let frame = 0; frame < def.frames; frame++) {
|
|
264
|
+
for (let column = 0; column < columns; column++) {
|
|
265
|
+
if (def.water === true)
|
|
266
|
+
drawWaterTile(bitmap, cell, column * cell.width, frame * cell.height, frame + column);
|
|
267
|
+
else
|
|
268
|
+
drawGroundTile(bitmap, cell, column * cell.width, frame * cell.height, def.base, def.dark, index * 10 + column);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
out.push(sample(def.name, def.file, "ground", cell, bitmap, { frames: def.frames, animRows: def.animRows }));
|
|
272
|
+
}
|
|
273
|
+
// 自动连接:4×4,行优先 mask 0..15。
|
|
274
|
+
{
|
|
275
|
+
const bitmap = makeBitmap(cell.width * 4, cell.height * 4);
|
|
276
|
+
for (let mask = 0; mask < 16; mask++) {
|
|
277
|
+
drawAutotileTile(bitmap, cell, (mask % 4) * cell.width, Math.floor(mask / 4) * cell.height, mask);
|
|
278
|
+
}
|
|
279
|
+
out.push(sample("水岸", "iso-shore.png", "autotile", cell, bitmap, { frames: 1, animRows: false }));
|
|
280
|
+
}
|
|
281
|
+
// 物件:底面中心在图片底边中点。
|
|
282
|
+
const objects = [
|
|
283
|
+
{ name: "松树", file: "iso-tree.png", footprint: { cols: 1, rows: 1 }, height: Math.round(cell.height * 1.35), draw: drawTree },
|
|
284
|
+
{ name: "石头", file: "iso-rock.png", footprint: { cols: 1, rows: 1 }, height: Math.round(cell.height * 0.72), draw: drawRock },
|
|
285
|
+
{ name: "灌木", file: "iso-bush.png", footprint: { cols: 1, rows: 1 }, height: Math.round(cell.height * 0.62), draw: drawBush },
|
|
286
|
+
{ name: "木桶", file: "iso-barrel.png", footprint: { cols: 1, rows: 1 }, height: Math.round(cell.height * 0.6), draw: drawBarrel },
|
|
287
|
+
{ name: "石屋", file: "iso-house.png", footprint: { cols: 2, rows: 2 }, height: Math.round(cell.height * 1.65), draw: drawHouse }
|
|
288
|
+
];
|
|
289
|
+
for (const def of objects) {
|
|
290
|
+
const width = cell.width * def.footprint.cols;
|
|
291
|
+
const bitmap = makeBitmap(width, def.height);
|
|
292
|
+
const pass = def.draw(bitmap, cell, def.footprint);
|
|
293
|
+
out.push(sample(def.name, def.file, "object", cell, bitmap, { frames: 1, animRows: false, footprint: def.footprint, pass }));
|
|
294
|
+
}
|
|
295
|
+
return out;
|
|
296
|
+
}
|
package/lib/isotiles.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 45° 地图编辑器(模块五 · iso)的**素材模型与切分**。
|
|
3
|
+
*
|
|
4
|
+
* 三种用法,几何都由本文件定:
|
|
5
|
+
*
|
|
6
|
+
* | kind | 图片排布 | 切出来是什么 |
|
|
7
|
+
* |---|---|---|
|
|
8
|
+
* | `ground` | 网格,每格一块 | 静态时每块一个笔刷;`animRows` 时每列一个笔刷、每行一帧 |
|
|
9
|
+
* | `autotile` | 严格 4×4 = 16 块 | 按 N=1 / E=2 / S=4 / W=8 的 mask 0..15(行优先) |
|
|
10
|
+
* | `object` | 一张完整图(多帧竖排) | 每帧一个整图 rect;占格 / 锚点 / 通行性单独记 |
|
|
11
|
+
*
|
|
12
|
+
* ## 为什么不复用 `MapTileset.shape` 的 a2quad / stamp
|
|
13
|
+
*
|
|
14
|
+
* 模块六的 A2 是「2×2 小格拼一个逻辑块」,整图是「把一张画切成 N×M 格」。
|
|
15
|
+
* 等距物件不能被切成格子:它是一张完整图,必须按底面中心整张摆放,否则
|
|
16
|
+
* 高处(屋顶 / 树冠)会被切碎。所以物件在这里是**自己的切分**,只借用
|
|
17
|
+
* `MapTile` 的 `rect` 与全局序号思路。
|
|
18
|
+
*
|
|
19
|
+
* 地面 / 自动连接则直接复用 `maptiles.buildTiles`:形状顺序、序号顺序、
|
|
20
|
+
* 按矩形 id 保留人工元数据这些约定,两边没有理由各写一份。
|
|
21
|
+
*/
|
|
22
|
+
import { buildTiles, parseAssetFps, parseAssetLoop, parseClarity, tileIdFor, flatTiles } from "./maptiles.js";
|
|
23
|
+
import { normalizeFootprint } from "./isogeom.js";
|
|
24
|
+
export const ISO_TILESET_KINDS = ["ground", "autotile", "object"];
|
|
25
|
+
export function isIsoTilesetKind(value) {
|
|
26
|
+
return value === "ground" || value === "autotile" || value === "object";
|
|
27
|
+
}
|
|
28
|
+
/** 界面 / 工具面传上来的用法收口:不合法**明确报错**,不静默改成别的值。 */
|
|
29
|
+
export function parseIsoTilesetKind(value) {
|
|
30
|
+
if (value === undefined || value === null || value === "")
|
|
31
|
+
return "ground";
|
|
32
|
+
if (!isIsoTilesetKind(value))
|
|
33
|
+
throw new Error(`未知素材用法:${String(value)}(可选 ground / autotile / object)`);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
/** 物件大小的上下限(界面与宿主共用同一口径)。 */
|
|
37
|
+
export const ISO_OBJECT_SCALE_MIN = 0.1;
|
|
38
|
+
export const ISO_OBJECT_SCALE_MAX = 4;
|
|
39
|
+
/**
|
|
40
|
+
* 「新增素材」里物件大小的收口:`1` = 图片宽度正好占满占格。
|
|
41
|
+
*
|
|
42
|
+
* 不合法**明确报错**(别静默夹成边界值 —— 用户会以为自己的输入生效了)。
|
|
43
|
+
*/
|
|
44
|
+
export function parseIsoObjectScale(value) {
|
|
45
|
+
if (value === undefined || value === null || value === "")
|
|
46
|
+
return undefined;
|
|
47
|
+
const n = Number(value);
|
|
48
|
+
if (!Number.isFinite(n)) {
|
|
49
|
+
throw new Error(`物件大小必须是 ${ISO_OBJECT_SCALE_MIN * 100}%~${ISO_OBJECT_SCALE_MAX * 100}% 之间的数字,收到 ${String(value)}`);
|
|
50
|
+
}
|
|
51
|
+
if (n < ISO_OBJECT_SCALE_MIN || n > ISO_OBJECT_SCALE_MAX) {
|
|
52
|
+
throw new Error(`物件大小必须在 ${ISO_OBJECT_SCALE_MIN * 100}%~${ISO_OBJECT_SCALE_MAX * 100}% 之间,收到 ${Math.round(n * 100)}%`);
|
|
53
|
+
}
|
|
54
|
+
return Math.round(n * 1000) / 1000;
|
|
55
|
+
}
|
|
56
|
+
/** 由 kind 推 buildTiles 用的形状。 */
|
|
57
|
+
export function shapeOfKind(kind) {
|
|
58
|
+
return kind === "autotile" ? "corner16" : "plain";
|
|
59
|
+
}
|
|
60
|
+
/** 自动连接的位序(与模块六 / AsLib 同一套:N=1 E=2 S=4 W=8)。 */
|
|
61
|
+
export const ISO_AUTOTILE_MASKS = Array.from({ length: 16 }, (_unused, index) => index);
|
|
62
|
+
/** 自动连接必须是 4×4 = 16 块;不是就明确拒绝,不猜顺序。 */
|
|
63
|
+
export const ISO_AUTOTILE_COUNT = 16;
|
|
64
|
+
export function parseIsoAnchor(value) {
|
|
65
|
+
if (value === undefined || value === null)
|
|
66
|
+
return undefined;
|
|
67
|
+
const raw = value;
|
|
68
|
+
const x = Number(raw.x);
|
|
69
|
+
const y = Number(raw.y);
|
|
70
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || x < 0 || x > 1 || y < 0 || y > 1) {
|
|
71
|
+
throw new Error(`物件锚点不合法:${JSON.stringify(value)}(x / y 应为 0~1)`);
|
|
72
|
+
}
|
|
73
|
+
return { x, y };
|
|
74
|
+
}
|
|
75
|
+
/** 通行性数组收口:长度必须等于占格数;不合法明确报错,不静默补齐。 */
|
|
76
|
+
export function parsePassCells(value, footprint) {
|
|
77
|
+
if (value === undefined || value === null)
|
|
78
|
+
return undefined;
|
|
79
|
+
if (!Array.isArray(value))
|
|
80
|
+
throw new Error("逐格通行性必须是数组");
|
|
81
|
+
const expected = footprint.cols * footprint.rows;
|
|
82
|
+
if (value.length !== expected) {
|
|
83
|
+
throw new Error(`逐格通行性应有 ${expected} 项(${footprint.cols}×${footprint.rows}),收到 ${value.length}`);
|
|
84
|
+
}
|
|
85
|
+
return value.map((entry, index) => {
|
|
86
|
+
const n = Number(entry);
|
|
87
|
+
if (n !== 0 && n !== 1 && n !== 2)
|
|
88
|
+
throw new Error(`第 ${index + 1} 格通行性只能是 0 / 1 / 2,收到 ${String(entry)}`);
|
|
89
|
+
return n;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** 默认全部「可通过·角色在上面」。 */
|
|
93
|
+
export function defaultPass(footprint) {
|
|
94
|
+
return new Array(footprint.cols * footprint.rows).fill(1);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 物件切分:一张完整图,多帧竖排。
|
|
98
|
+
*
|
|
99
|
+
* 每帧的 rect = 整张图宽 × 一帧高。帧高必须整除图片高;不整除就明确拒绝
|
|
100
|
+
* (按「大概几帧」去凑会让每一帧都错位,而且不报错)。
|
|
101
|
+
*/
|
|
102
|
+
export function buildObjectTiles(input, previous = []) {
|
|
103
|
+
const frames = Math.max(1, Math.round(input.frames));
|
|
104
|
+
if (!Number.isInteger(input.imageHeight / frames) || input.imageHeight % frames !== 0) {
|
|
105
|
+
throw new Error(`物件图高 ${input.imageHeight} 不能被帧数 ${frames} 整除`);
|
|
106
|
+
}
|
|
107
|
+
const frameHeight = input.imageHeight / frames;
|
|
108
|
+
const previousById = new Map(previous.map((tile) => [tile.id, tile]));
|
|
109
|
+
const out = [];
|
|
110
|
+
for (let frame = 0; frame < frames; frame++) {
|
|
111
|
+
const rect = { x: 0, y: frame * frameHeight, width: input.imageWidth, height: frameHeight };
|
|
112
|
+
const id = tileIdFor(rect);
|
|
113
|
+
const old = previousById.get(id);
|
|
114
|
+
const tile = old === undefined ? { id, rect, name: id } : { ...old };
|
|
115
|
+
tile.id = id;
|
|
116
|
+
tile.rect = rect;
|
|
117
|
+
if (typeof tile.name !== "string" || tile.name === "")
|
|
118
|
+
tile.name = id;
|
|
119
|
+
delete tile.shape;
|
|
120
|
+
delete tile.variant;
|
|
121
|
+
delete tile.mask;
|
|
122
|
+
delete tile.stamp;
|
|
123
|
+
tile.frame = frame;
|
|
124
|
+
out.push(tile);
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
/** 自动连接:4×4 行优先,第 i 块的 mask = i。 */
|
|
129
|
+
function assignAutotileMasks(tiles) {
|
|
130
|
+
for (let index = 0; index < tiles.length; index++) {
|
|
131
|
+
if (tiles[index] !== undefined)
|
|
132
|
+
tiles[index].mask = index;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 由几何字段重建 `tiles`(读盘自愈 / 改格后重切共用)。
|
|
137
|
+
*
|
|
138
|
+
* 与模块六 `buildTiles` 一样,按矩形 id 保留旧 tile 的人工字段;
|
|
139
|
+
* 几何派生字段(rect / frame / mask)必须覆盖,否则块号会与矩形对不上。
|
|
140
|
+
*/
|
|
141
|
+
export function rebuildIsoTiles(input, previous = []) {
|
|
142
|
+
if (input.kind === "object") {
|
|
143
|
+
return buildObjectTiles({ imageWidth: input.imageWidth, imageHeight: input.imageHeight, frames: input.frames }, previous);
|
|
144
|
+
}
|
|
145
|
+
const shape = shapeOfKind(input.kind);
|
|
146
|
+
const tiles = buildTiles({
|
|
147
|
+
shape,
|
|
148
|
+
cell: { width: input.cell.width, height: input.cell.height },
|
|
149
|
+
imageWidth: input.imageWidth,
|
|
150
|
+
imageHeight: input.imageHeight,
|
|
151
|
+
animRows: input.kind === "ground" && input.animRows === true
|
|
152
|
+
}, previous);
|
|
153
|
+
if (input.kind === "autotile")
|
|
154
|
+
assignAutotileMasks(tiles);
|
|
155
|
+
return tiles;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* 由几何字段推「调色板笔刷 / 帧数」。
|
|
159
|
+
*
|
|
160
|
+
* - 静态地面:每个格子都是独立笔刷;
|
|
161
|
+
* - 动画地面(animRows):每列一个笔刷,行 = 帧;
|
|
162
|
+
* - 自动连接:一个笔刷(满接图块);
|
|
163
|
+
* - 物件:一个笔刷(第 0 帧整图)。
|
|
164
|
+
*/
|
|
165
|
+
export function paletteOf(tileset, allTilesets = [tileset]) {
|
|
166
|
+
// ⚠️ 必须用**全项目**的展平表:只传这一张素材的话,序号会从 1 重新开始,
|
|
167
|
+
// 第二张素材的笔刷就会画成第一张的图(不报错,只是画错)。
|
|
168
|
+
const flat = flatTiles(allTilesets).filter((item) => item.tilesetId === tileset.id);
|
|
169
|
+
if (tileset.kind === "autotile") {
|
|
170
|
+
const full = tileset.tiles.find((tile) => tile.mask === 15) ?? tileset.tiles[tileset.tiles.length - 1];
|
|
171
|
+
const entry = flat.find((item) => item.tile === full);
|
|
172
|
+
return entry === undefined ? [] : [{ index: entry.index, rect: entry.tile.rect }];
|
|
173
|
+
}
|
|
174
|
+
if (tileset.kind === "object") {
|
|
175
|
+
const first = tileset.tiles.find((tile) => (tile.frame ?? 0) === 0) ?? tileset.tiles[0];
|
|
176
|
+
const entry = flat.find((item) => item.tile === first);
|
|
177
|
+
return entry === undefined ? [] : [{ index: entry.index, rect: entry.tile.rect }];
|
|
178
|
+
}
|
|
179
|
+
if (tileset.animRows === true && tileset.frames > 1) {
|
|
180
|
+
const first = flat.filter((item) => (item.tile.frame ?? 0) === 0);
|
|
181
|
+
return first.map((item) => ({ index: item.index, rect: item.tile.rect }));
|
|
182
|
+
}
|
|
183
|
+
return flat.map((item) => ({ index: item.index, rect: item.tile.rect }));
|
|
184
|
+
}
|
|
185
|
+
/** 素材说明(界面列表上的一行小字)。 */
|
|
186
|
+
export function isoReason(tileset) {
|
|
187
|
+
if (tileset.kind === "object") {
|
|
188
|
+
const fp = tileset.footprint ?? { cols: 1, rows: 1 };
|
|
189
|
+
const scale = tileset.objectScale;
|
|
190
|
+
const size = scale !== undefined && Math.abs(scale - 1) > 0.0005 ? `、大小 ${Math.round(scale * 100)}%` : "";
|
|
191
|
+
return `物件:占 ${fp.cols}×${fp.rows} 格${size}${tileset.frames > 1 ? `、${tileset.frames} 帧` : ""}`;
|
|
192
|
+
}
|
|
193
|
+
if (tileset.kind === "autotile")
|
|
194
|
+
return `自动连接:4×4 = 16 块(${tileset.cell.width}×${tileset.cell.height})`;
|
|
195
|
+
return `地面:${tileset.columns} 列${tileset.frames > 1 ? ` × ${tileset.frames} 帧` : ""}(${tileset.cell.width}×${tileset.cell.height})`;
|
|
196
|
+
}
|
|
197
|
+
export function briefOf(tileset, rev, allTilesets = [tileset]) {
|
|
198
|
+
return {
|
|
199
|
+
id: tileset.id,
|
|
200
|
+
name: tileset.name,
|
|
201
|
+
file: tileset.file,
|
|
202
|
+
imageWidth: tileset.imageWidth,
|
|
203
|
+
imageHeight: tileset.imageHeight,
|
|
204
|
+
cell: tileset.cell,
|
|
205
|
+
kind: tileset.kind,
|
|
206
|
+
columns: tileset.columns,
|
|
207
|
+
frames: tileset.frames,
|
|
208
|
+
variants: tileset.variants,
|
|
209
|
+
animRows: tileset.animRows,
|
|
210
|
+
footprint: tileset.footprint,
|
|
211
|
+
anchor: tileset.anchor,
|
|
212
|
+
objectScale: tileset.objectScale,
|
|
213
|
+
loop: tileset.loop,
|
|
214
|
+
fps: tileset.fps,
|
|
215
|
+
clarity: tileset.clarity,
|
|
216
|
+
builtin: tileset.builtin === true ? true : undefined,
|
|
217
|
+
rev,
|
|
218
|
+
tileCount: tileset.tiles.length,
|
|
219
|
+
reason: isoReason(tileset),
|
|
220
|
+
palette: paletteOf(tileset, allTilesets)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/** 读盘 / 外部输入 → 合法用法字段。不合法时明确报错。 */
|
|
224
|
+
export function normalizeAssetFrames(value, fallback = 1) {
|
|
225
|
+
const n = Math.round(Number(value));
|
|
226
|
+
if (!Number.isFinite(n) || n < 1 || n > 64)
|
|
227
|
+
throw new Error(`帧数必须是 1~64 的整数,收到 ${String(value)}`);
|
|
228
|
+
return n;
|
|
229
|
+
}
|
|
230
|
+
export function normalizeAssetClarity(value) {
|
|
231
|
+
return parseClarity(value);
|
|
232
|
+
}
|
|
233
|
+
export function normalizeAssetFps(value) {
|
|
234
|
+
return parseAssetFps(value);
|
|
235
|
+
}
|
|
236
|
+
export function normalizeAssetLoop(value) {
|
|
237
|
+
return parseAssetLoop(value);
|
|
238
|
+
}
|
|
239
|
+
/** 只用一次:导出 JSON 的图块表需要它。 */
|
|
240
|
+
export function flatOf(tilesets) {
|
|
241
|
+
return flatTiles(tilesets);
|
|
242
|
+
}
|
|
243
|
+
export { normalizeFootprint };
|
package/lib/links.js
CHANGED
|
@@ -31,26 +31,20 @@ export const OPEN_QUERY_KEY = "dsh-gmm";
|
|
|
31
31
|
/** 工作台在 `main` 槽里的 key,也是侧栏 `sidebar.panellist` 的 id。 */
|
|
32
32
|
export const PANEL_KEY = "gameStudio";
|
|
33
33
|
/** 八个模块的 key。 */
|
|
34
|
-
export const STUDIO_MODULES = ["sprite", "image", "sequence", "rig", "
|
|
34
|
+
export const STUDIO_MODULES = ["sprite", "image", "sequence", "rig", "iso", "map", "music", "sfx"];
|
|
35
35
|
/** 八方向图的四个阶段。 */
|
|
36
36
|
export const SPRITE_STAGES = ["images", "videos", "frames", "sheet"];
|
|
37
37
|
/** 音乐生成编辑(模块七)的三个阶段:生成 / 编辑 / 导出。 */
|
|
38
38
|
export const MUSIC_STAGES = ["compose", "generate", "edit", "export"];
|
|
39
39
|
/** 音效生成(模块八)的两个阶段:生成 / 导出。 */
|
|
40
40
|
export const SFX_STAGES = ["generate", "export"];
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
* ⚠️ 这里**故意不含 `template`**:模板(参考图)已经不是单独一步了,
|
|
45
|
-
* 它在「生成地块」开始时按当前占格形状自动准备(见 `tilegen.ensureTemplates`)。
|
|
46
|
-
* 老的 `stage=template` 深链接会被忽略(`TILE_STAGES.includes` 不通过)。
|
|
47
|
-
*/
|
|
48
|
-
export const TILE_STAGES = ["generate", "review", "map", "export"];
|
|
41
|
+
/** 45° 地图编辑器(模块五 · iso)的三个阶段:素材 / 地图 / 导出。 */
|
|
42
|
+
export const ISO_STAGES = ["assets", "paint", "export"];
|
|
49
43
|
/**
|
|
50
44
|
* 地图编辑器(模块六)的四个阶段。
|
|
51
45
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
46
|
+
* 这是正方格俯视编辑器;45° 编辑器是模块五(iso),两者数据与渲染完全独立。
|
|
47
|
+
* 阶段名是素材 / 自动连接 / 地图 / 导出;`rules`(自动连接)没有可配的
|
|
54
48
|
* 东西、由宿主自动完成,界面里不显示它,但 key 保留 —— 对话面的
|
|
55
49
|
* `stage=assets|rules|paint|export` 契约不能变。
|
|
56
50
|
*/
|
|
@@ -68,6 +62,11 @@ export const OPEN_STAMP_MAX = 512;
|
|
|
68
62
|
export const OPEN_DIALOGS = ["add"];
|
|
69
63
|
/** 深链接里 `shape` 允许的取值(与 `maptiles.TilesetShape` 同一套)。 */
|
|
70
64
|
export const OPEN_SHAPES = ["plain", "corner16", "a2quad", "stamp"];
|
|
65
|
+
/**
|
|
66
|
+
* 45° 编辑器的 AI 素材回链:`shape` 复用一个参数名,但取值是素材用法
|
|
67
|
+
* (`ground` / `object`)。两个模块的界面各自只接受自己那一组,不会串。
|
|
68
|
+
*/
|
|
69
|
+
export const OPEN_ISO_SHAPES = ["ground", "object"];
|
|
71
70
|
/**
|
|
72
71
|
* `asset` 必须是**项目资源目录下的相对路径**:不接受绝对路径、不接受 `..`
|
|
73
72
|
* (资源路由另有目录穿越拦截,这里先把脏值挡在意图之外,免得把坏链接带进界面)。
|
|
@@ -177,8 +176,10 @@ export function normalizeIntent(intent) {
|
|
|
177
176
|
out.asset = intent.asset.trim();
|
|
178
177
|
if (typeof intent.frames === "number" && Number.isInteger(intent.frames) && intent.frames > 0)
|
|
179
178
|
out.frames = intent.frames;
|
|
180
|
-
if (typeof intent.shape === "string" &&
|
|
179
|
+
if (typeof intent.shape === "string" &&
|
|
180
|
+
(OPEN_SHAPES.includes(intent.shape) || OPEN_ISO_SHAPES.includes(intent.shape))) {
|
|
181
181
|
out.shape = intent.shape;
|
|
182
|
+
}
|
|
182
183
|
if (typeof intent.scale === "number" && Number.isInteger(intent.scale) && intent.scale >= OPEN_SCALE_MIN && intent.scale <= OPEN_SCALE_MAX)
|
|
183
184
|
out.scale = intent.scale;
|
|
184
185
|
for (const key of ["cols", "rows"]) {
|
package/lib/mapexport.js
CHANGED
|
@@ -208,7 +208,7 @@ export async function exportMap(input) {
|
|
|
208
208
|
await write(zipName, zipEntries(entries), "archive");
|
|
209
209
|
manifest.mapZip = zipName;
|
|
210
210
|
}
|
|
211
|
-
// 清单自己也要落盘:验收包(`
|
|
211
|
+
// 清单自己也要落盘:验收包(`game_material({action:'review'})`)与「在文件夹中显示」都读它。
|
|
212
212
|
// 盘上的 files 里补一条 manifest.json(bytes 0 —— 序列化那一刻还不知道自己的大小);
|
|
213
213
|
// `write` 随后往 `files` 里 push 的是带真实字节数的那条,返回值与旧实现一致地含它。
|
|
214
214
|
await writeJson("manifest.json", { ...manifest, files: [...manifest.files, { path: "manifest.json", bytes: 0, kind: "json" }] });
|
package/lib/mapgeom.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* ## 为什么把它单独抽一层
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* 旧模块(已删除的 `tilegeom.ts` / `tilemap.ts`)的坐标口径散在三处,界面还要复刻一份,
|
|
10
10
|
* 于是「保存后整体抬高」「点到的格子不是涂到的格子」反复出现。这个模块是
|
|
11
11
|
* 新模块**唯一的坐标真源**:宿主渲染、导出、chunk 划分、命中测试全走这里;
|
|
12
12
|
* 浏览器半区**只被允许**复刻 `pointToCell` / `cellAnchor` / `cellTopLeft`
|
package/lib/maprender.js
CHANGED
package/lib/musicguide.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* ## 为什么放在宿主侧
|
|
14
14
|
*
|
|
15
|
-
* 对话里的 agent 通过 `
|
|
15
|
+
* 对话里的 agent 通过 `game_material({action:'call', method:'getMusicGuide'})` 读取它。
|
|
16
16
|
* 放在宿主侧的好处是:界面换语言不影响它、模型每次都能拿到**同一份**经过整理
|
|
17
17
|
* 的清单,而不是靠模型记性。客户端只负责把 `guide` 原样显示在「创作技巧」里。
|
|
18
18
|
*/
|