图层修改

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

@@ -0,0 +1,54 @@
import { CommonDefine } from '../core/Define';
/** 地砖:仅 Baseblock / JumpBlock */
const GROUND_TILES = new Set<string>([CommonDefine.BlockBase, CommonDefine.BlockJump]);
/** 墙砖与墙饰Border 层) */
const BORDER_TILES = new Set<string>([
CommonDefine.BlockWall,
'kuai11',
'Decor23',
'素材切图-23',
'素材切图2-23',
'小游戏素材红色_03',
]);
export function isGroundTileName(tileName: string): boolean {
return GROUND_TILES.has(tileName);
}
export function isWallBlockTileName(tileName: string): boolean {
return tileName === CommonDefine.BlockWall;
}
/** Ground 层:强制地砖属性,拒绝墙砖名 */
export function normalizeGroundTile(value: unknown): string {
return value === CommonDefine.BlockJump ? CommonDefine.BlockJump : CommonDefine.BlockBase;
}
/** Border 层:强制墙砖属性,拒绝地砖名 */
export function normalizeBorderTile(value: unknown): string {
if (value === true || value == null) return CommonDefine.BlockWall;
if (typeof value !== 'string') return CommonDefine.BlockWall;
const v = value.trim();
if (!v || GROUND_TILES.has(v)) return CommonDefine.BlockWall;
if (v === CommonDefine.BlockWall || BORDER_TILES.has(v)) return v;
return v;
}
/** 按层级解析贴图 key层级优先于裸值 */
export function resolveTileNameForLayer(layer: 'ground' | 'border', value: unknown): string {
return layer === 'ground' ? normalizeGroundTile(value) : normalizeBorderTile(value);
}
export function resolveTileNameAtCell(
layer: 'ground' | 'border',
key: string,
ground?: Record<string, string>,
border?: Record<string, boolean | string>,
): string {
if (layer === 'ground') {
return normalizeGroundTile(ground?.[key]);
}
return normalizeBorderTile(border?.[key]);
}