图层修改

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-14 16:02:20 +08:00
parent ff1542c24f
commit ae75fce80b
5121 changed files with 17930 additions and 16467861 deletions

View File

@@ -37,8 +37,12 @@ function removeCell(state, key) {
}
function setCell(state, key, tileKey) {
if (state.editLayer === 'ground') state.config.ground[key] = tileKey;
else state.config.border[key] = tileKey;
if (state.editLayer === 'ground') {
state.config.ground[key] = tileKey === 'JumpBlock' ? 'JumpBlock' : 'Baseblock';
} else {
const s = typeof tileKey === 'string' ? tileKey.trim() : '';
state.config.border[key] = (!s || s === 'Baseblock' || s === 'JumpBlock') ? 'WallBlock' : s;
}
}
function canPaintBrush(state) {
@@ -135,6 +139,45 @@ function findPaletteTile(state, tileKey, layer) {
return state.tiles.find((t) => t.tileKey === tileKey && t.layer === layer) || null;
}
/** Ground 瓦片中文名 */
function groundTileLabel(tileKey) {
if (tileKey === 'JumpBlock') return '跳跃砖(JumpBlock)';
return '可移动砖块(Baseblock)';
}
/** Border 瓦片中文名 */
function borderTileLabel(tileKey) {
const s = tileKey === true || tileKey === 1 ? 'WallBlock' : String(tileKey || 'WallBlock').trim();
if (!s || s === 'WallBlock') return '墙砖(WallBlock)';
return `墙饰(${s})`;
}
/**
* 汇总格子上全部内容(两层瓦片 + 实体),用于状态栏悬停提示。
* @param {object} state
* @param {number} x
* @param {number} y
* @param {{ kind: string, propPlacement?: string }[]} [spawnHits]
* @param {Record<string, string>} [spawnKindLabels]
*/
function describeCellContents(state, x, y, spawnHits, spawnKindLabels) {
const key = `${x},${y}`;
const parts = [];
const ground = state.config?.ground?.[key];
if (ground !== undefined) parts.push(groundTileLabel(ground));
const border = state.config?.border?.[key];
if (border !== undefined) parts.push(borderTileLabel(border));
if (Array.isArray(spawnHits)) {
for (const h of spawnHits) {
let label = (spawnKindLabels && spawnKindLabels[h.kind]) || h.kind;
if (h.kind === 'player') label = '人物';
if (h.kind === 'prop' && h.propPlacement === 'ground') label = `${label}(空地)`;
parts.push(label);
}
}
return parts.length ? parts.join(' + ') : '空';
}
module.exports = {
TOOLS,
TOOL_LABELS,
@@ -150,4 +193,7 @@ module.exports = {
floodFill,
floodErase,
findPaletteTile,
groundTileLabel,
borderTileLabel,
describeCellContents,
};