同步关卡属性编辑与Boss小怪置灰提示
This commit is contained in:
+5
-3
@@ -2,6 +2,7 @@
|
||||
'use strict';
|
||||
const copy = value => JSON.parse(JSON.stringify(value));
|
||||
const fields = ['width', 'height', 'characters', 'aoes'];
|
||||
const settings = typeof module !== 'undefined' && module.exports ? require('./level-settings.cjs') : root.LevelSettings;
|
||||
function importLayout(input) {
|
||||
if (!input || typeof input !== 'object' || Array.isArray(input)) throw new Error('请选择有效的单关 JSON 对象');
|
||||
if (input.formatVersion !== undefined || Array.isArray(input.levels)) throw new Error('请选择导出的单关 JSON,不是完整关卡数据包');
|
||||
@@ -43,15 +44,16 @@
|
||||
result.templates[id] = template;
|
||||
const original = base.get(template);
|
||||
if (!incoming || (active && incoming.displayLevel !== number) || fields.some(field => incoming[field] === undefined)) throw new Error('显示编号或布局字段无效:' + number);
|
||||
// 只接收布局字段;来源、难度与玩法元数据不能由数据包任意覆盖。
|
||||
return { ...copy(original), ...(base.has(id) ? {} : { sourceId: 'editor_level_' + id, sourcePath: 'editor/level_' + id + '.json', sourceUuid: 'editor_level_' + id }),
|
||||
// 布局与经过白名单校验的关卡属性可编辑,来源及特殊玩法继续继承模板。
|
||||
const levelSettings = incoming.levelSettings === undefined ? {} : { levelSettings: settings.resolve(incoming.levelSettings, data.settingsCatalog.records[template], data.settingsCatalog) };
|
||||
return { ...copy(original), ...levelSettings, ...(base.has(id) ? {} : { sourceId: 'editor_level_' + id, sourcePath: 'editor/level_' + id + '.json', sourceUuid: 'editor_level_' + id }),
|
||||
...Object.fromEntries(fields.map(field => [field, copy(incoming[field])])), displayLevel: number };
|
||||
}
|
||||
result.levels = order.map((id, index) => normalizeLevel(id, input.levels[index], index + 1, true));
|
||||
result.archivedLevels = Object.fromEntries(Object.entries(archive).map(([id, level]) => [id, normalizeLevel(Number(id), level, Number(id), false)]));
|
||||
return result;
|
||||
}
|
||||
const api = { create, normalize, sourceOrder, sourceLevel, importLayout };
|
||||
const api = { create, normalize, sourceOrder, sourceLevel, importLayout, settings };
|
||||
if (typeof module !== 'undefined' && module.exports) module.exports = api;
|
||||
else root.MainlineWorkspace = api;
|
||||
})(globalThis);
|
||||
|
||||
Reference in New Issue
Block a user