/** * 层与图的 bucket 归属。见 spec §3.3。 * bucket 决定资源落进 framework/ui/atlas-{common,login,hall,room} 哪个目录。 */ /** 登录相关:按层名点名,因其 LayerID 散落在 1..29 段内。 */ const LOGIN_LAYERS = new Set(['Logo_Layer', 'Login_Layer', 'Auth_layer', 'Bind_Layer', 'phoneInfo']); /** 命名笼统、语义不明的层:标 unassigned 交人工归位,不猜。 */ const UNASSIGNED_LAYERS = new Set([ 'Layer6', 'Layer13', 'Layer403', 'Layer411', 'Layer601', 'Layer603', 'Layer618', ]); const ROOM_ID_MIN = 50; const COMMON_ID_MIN = 600; export function layerBucket(layerId, layerName) { if (UNASSIGNED_LAYERS.has(layerName)) return 'unassigned'; if (LOGIN_LAYERS.has(layerName)) return 'login'; if (layerId >= COMMON_ID_MIN) return 'common'; if (layerId >= ROOM_ID_MIN) return 'room'; return 'hall'; } /** * 每张图按引用它的对象所在层决定 bucket。 * 跨多个 bucket → common;无对象引用 → unassigned。 */ export function imageBuckets(source) { const layerBucketById = new Map( source.layers.map((l) => [l.layerId, layerBucket(l.layerId, l.name)]), ); const bucketsPerImage = new Map(); for (const obj of source.objects.values()) { if (!obj.ImageFileID) continue; const b = layerBucketById.get(obj.BelongLayerID); if (!b) continue; if (!bucketsPerImage.has(obj.ImageFileID)) bucketsPerImage.set(obj.ImageFileID, new Set()); bucketsPerImage.get(obj.ImageFileID).add(b); } const out = new Map(); for (const id of source.images.keys()) { const set = bucketsPerImage.get(id); if (!set || set.size === 0) { out.set(id, 'unassigned'); continue; } const real = [...set].filter((b) => b !== 'unassigned'); if (real.length === 0) out.set(id, 'unassigned'); else if (real.length === 1) out.set(id, real[0]); else out.set(id, 'common'); } return out; }