fix: 录像播放

This commit is contained in:
unanmed 2024-11-20 15:58:52 +08:00
parent 7ed74c8004
commit ffc4aaa865
10 changed files with 43 additions and 33 deletions

View File

@ -46,7 +46,7 @@ main.floors.MT0=
"\r[red]注意!!!\r[]该塔新增了很多新的功能同时对样板的ui进行了大幅度的改动操作也有改变由于内容过多这里不再一一描述具体请在道具栏查看百科全书百科全书是在你面前的几个道具中的其中一个", "\r[red]注意!!!\r[]该塔新增了很多新的功能同时对样板的ui进行了大幅度的改动操作也有改变由于内容过多这里不再一一描述具体请在道具栏查看百科全书百科全书是在你面前的几个道具中的其中一个",
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.require('var', 'fixedUi').open('chapter', { chapter: '序章 起源' });\n}" "function": "function(){\nif (!core.isReplaying()) Mota.require('var', 'fixedUi').open('chapter', { chapter: '序章 起源' });\n}"
} }
], ],
"parallelDo": "", "parallelDo": "",

View File

@ -63,7 +63,7 @@ main.floors.MT6=
"\t[原始人]\b[down,hero]感觉好像可以学习一些简单的东西了。", "\t[原始人]\b[down,hero]感觉好像可以学习一些简单的东西了。",
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.require('var', 'fixedUi').open('chapter', { chapter: '第一章 勇气' });\n}" "function": "function(){\nif (!core.isReplaying()) Mota.require('var', 'fixedUi').open('chapter', { chapter: '第一章 勇气' });\n}"
}, },
{ {
"type": "setValue", "type": "setValue",

View File

@ -78,7 +78,15 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
}); });
} }
Mota.r(() => {
Mota.require('class', 'CustomToolbar').setDefaultTool(false); Mota.require('class', 'CustomToolbar').setDefaultTool(false);
});
const { NightSpecial, HeroSkill } = Mota.require(
'module',
'Mechanism'
);
NightSpecial.clearNight(core.floorIds);
HeroSkill.clearSkill();
}, },
win: function (reason, norank, noexit) { win: function (reason, norank, noexit) {
// 游戏获胜事件 // 游戏获胜事件

View File

@ -530,14 +530,6 @@ loading.once('coreInit', () => {
}); });
}); });
const { hook } = Mota.requireAll('var');
hook.on('reset', () => {
const HeroSkill = Mota.require('module', 'Mechanism').HeroSkill;
mainSetting.reset({
'action.autoSkill': HeroSkill.getAutoSkill()
});
});
interface SettingTextData { interface SettingTextData {
[x: string]: string[] | SettingTextData; [x: string]: string[] | SettingTextData;
} }

View File

@ -91,6 +91,10 @@ export namespace HeroSkill {
learned.delete(skill); learned.delete(skill);
} }
export function clearSkill() {
learned.clear();
}
export function saveSkill(): SkillSave { export function saveSkill(): SkillSave {
return { autoSkill, learned: [...learned] }; return { autoSkill, learned: [...learned] };
} }

View File

@ -204,13 +204,18 @@ export function init() {
control.prototype.waitHeroToStop = function (callback?: () => void) { control.prototype.waitHeroToStop = function (callback?: () => void) {
core.stopAutomaticRoute(); core.stopAutomaticRoute();
core.clearContinueAutomaticRoute(); core.clearContinueAutomaticRoute();
heroMover.controller?.stop();
if (heroMover.controller) { if (callback) {
heroMover.controller.stop().then(() => { core.status.replay.animate = true;
callback?.(); core.lockControl();
}); core.status.automaticRoute.moveDirectly = false;
} else { setTimeout(
callback?.(); function () {
core.status.replay.animate = false;
callback();
},
core.status.replay.speed === 24 ? 1 : 30
);
} }
}; };
@ -653,29 +658,24 @@ export function init() {
}); });
const moveAction = new Set<string>(['up', 'down', 'left', 'right']); const moveAction = new Set<string>(['up', 'down', 'left', 'right']);
let controller: IMoveController | null = null;
// 复写录像的移动 // 复写录像的移动
core.registerReplayAction('move', action => { core.registerReplayAction('move', action => {
if (moveAction.has(action)) { if (moveAction.has(action)) {
const next = core.status.replay.toReplay[1];
if (!heroMover.moving) { if (!heroMover.moving) {
controller = heroMover.startMove(); heroMover.startMove();
} }
if (!controller) { if (!heroMover.controller) {
return false; return false;
} }
controller.push({ heroMover.controller.push({
type: 'dir', type: 'dir',
value: action as Dir value: action as Dir
}); });
if (moveAction.has(next)) {
heroMover.controller.onEnd.then(() => {
core.replay(); core.replay();
} else {
controller.onEnd.then(() => {
core.replay();
controller = null;
}); });
}
return true; return true;
} else { } else {
return false; return false;

View File

@ -20,6 +20,7 @@ export function clip(...replace: string[]) {
} }
export function init() { export function init() {
const { HeroSkill } = Mota.require('module', 'Mechanism');
// 注册修改设置的录像操作 // 注册修改设置的录像操作
core.registerReplayAction('settings', name => { core.registerReplayAction('settings', name => {
if (!name.startsWith('set:')) return false; if (!name.startsWith('set:')) return false;
@ -27,7 +28,11 @@ export function init() {
const v = eval(value); const v = eval(value);
if (typeof v !== 'boolean') return false; if (typeof v !== 'boolean') return false;
if (!replayableSettings.includes(setting)) return false; if (!replayableSettings.includes(setting)) return false;
flags[setting] = v; switch (setting) {
case 'autoSkill':
HeroSkill.setAutoSkill(v);
break;
}
core.status.route.push(name); core.status.route.push(name);
core.replay(); core.replay();
return true; return true;

View File

@ -1,6 +1,7 @@
// @ts-nocheck // @ts-nocheck
export function init() { export function init() {
if (main.mode === 'editor') return;
const { mainUi, fixedUi, mainSetting } = Mota.requireAll('var'); const { mainUi, fixedUi, mainSetting } = Mota.requireAll('var');
const CustomToolbar = Mota.require('class', 'CustomToolbar'); const CustomToolbar = Mota.require('class', 'CustomToolbar');

View File

@ -348,7 +348,7 @@ interface Control {
* @example core.waitHeroToStop(core.vibrate); // 等待勇士停下然后视野左右抖动1秒 * @example core.waitHeroToStop(core.vibrate); // 等待勇士停下然后视野左右抖动1秒
* @param callback * @param callback
*/ */
waitHeroToStop(callback?: () => void): void; waitHeroToStop(callback?: () => void, waitOnly?: boolean): void;
/** /**
* @deprecated * @deprecated

View File

@ -206,7 +206,7 @@ function update() {
skillOpened.value = core.getFlag('chapter', 0) > 0; skillOpened.value = core.getFlag('chapter', 0) > 0;
jumpCnt.value = jumpCnt.value =
HeroSkill.learnedSkill(HeroSkill.Jump) && !HeroSkill.learnedSkill(HeroSkill.Jump) ||
Mota.Plugin.require('skill_g').jumpIgnoreFloor.has(core.status.floorId) Mota.Plugin.require('skill_g').jumpIgnoreFloor.has(core.status.floorId)
? -1 ? -1
: 3 - (flags[`jump_${core.status.floorId}`] ?? 0); : 3 - (flags[`jump_${core.status.floorId}`] ?? 0);