mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-31 23:29:27 +08:00
fix: 装备录像问题 & 移动录像问题
This commit is contained in:
parent
8f894ad1e0
commit
0b0d9d2cf5
@ -1739,17 +1739,30 @@ control.prototype._replayAction_item = function (action) {
|
|||||||
|
|
||||||
control.prototype._replayAction_equip = function (action) {
|
control.prototype._replayAction_equip = function (action) {
|
||||||
if (action.indexOf('equip:') != 0) return false;
|
if (action.indexOf('equip:') != 0) return false;
|
||||||
var equipId = action.substring(6);
|
const [, type, id] = action.split(':');
|
||||||
var ownEquipment = core.getToolboxItems('equips');
|
let t = Number(type);
|
||||||
var index = ownEquipment.indexOf(equipId),
|
const hasType = !isNaN(t);
|
||||||
per = core._WIDTH_ - 1;
|
const equipId = hasType ? id : type;
|
||||||
if (index < 0) {
|
const ownEquipment = core.getToolboxItems('equips');
|
||||||
|
if (!ownEquipment.includes(equipId)) {
|
||||||
core.removeFlag('__doNotCheckAutoEvents__');
|
core.removeFlag('__doNotCheckAutoEvents__');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!hasType) {
|
||||||
|
const type = core.getEquipTypeById(equipId);
|
||||||
|
if (type >= 0) t = type;
|
||||||
|
else {
|
||||||
|
Mota.Plugin.require('render_r').tip(
|
||||||
|
'error',
|
||||||
|
'无法装备' + core.material.items[equipId]?.name
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const now = core.status.hero.equipment[t];
|
||||||
|
|
||||||
var cb = function () {
|
const cb = function () {
|
||||||
var next = core.status.replay.toReplay[0] || '';
|
const next = core.status.replay.toReplay[0] || '';
|
||||||
if (!next.startsWith('equip:') && !next.startsWith('unEquip:')) {
|
if (!next.startsWith('equip:') && !next.startsWith('unEquip:')) {
|
||||||
core.removeFlag('__doNotCheckAutoEvents__');
|
core.removeFlag('__doNotCheckAutoEvents__');
|
||||||
core.checkAutoEvents();
|
core.checkAutoEvents();
|
||||||
@ -1758,33 +1771,34 @@ control.prototype._replayAction_equip = function (action) {
|
|||||||
};
|
};
|
||||||
core.setFlag('__doNotCheckAutoEvents__', true);
|
core.setFlag('__doNotCheckAutoEvents__', true);
|
||||||
|
|
||||||
core.status.route.push(action);
|
|
||||||
if (
|
if (
|
||||||
core.material.items[equipId].hideInReplay ||
|
core.material.items[equipId].hideInReplay ||
|
||||||
core.status.replay.speed == 24
|
core.status.replay.speed == 24
|
||||||
) {
|
) {
|
||||||
core.loadEquip(equipId, cb);
|
core.items._realLoadEquip(t, equipId, now);
|
||||||
|
cb();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
core.status.event.data = {
|
|
||||||
page: Math.floor(index / per) + 1,
|
|
||||||
selectId: null
|
|
||||||
};
|
|
||||||
index = (index % per) + per;
|
|
||||||
core.ui._drawEquipbox(index);
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
core.ui.closePanel();
|
core.ui.closePanel();
|
||||||
core.loadEquip(equipId, cb);
|
core.items._realLoadEquip(t, equipId, now);
|
||||||
|
cb();
|
||||||
}, core.control.__replay_getTimeout());
|
}, core.control.__replay_getTimeout());
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
control.prototype._replayAction_unEquip = function (action) {
|
control.prototype._replayAction_unEquip = function (action) {
|
||||||
if (action.indexOf('unEquip:') != 0) return false;
|
if (action.indexOf('unequip:') != 0) return false;
|
||||||
var equipType = parseInt(action.substring(8));
|
const type = action.slice(8);
|
||||||
|
let equipType = Number(type);
|
||||||
if (!core.isset(equipType)) {
|
if (!core.isset(equipType)) {
|
||||||
|
const id = core.status.hero.equipment.indexOf(type);
|
||||||
|
if (id === -1) {
|
||||||
core.removeFlag('__doNotCheckAutoEvents__');
|
core.removeFlag('__doNotCheckAutoEvents__');
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
equipType = id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var cb = function () {
|
var cb = function () {
|
||||||
@ -1797,15 +1811,15 @@ control.prototype._replayAction_unEquip = function (action) {
|
|||||||
};
|
};
|
||||||
core.setFlag('__doNotCheckAutoEvents__', true);
|
core.setFlag('__doNotCheckAutoEvents__', true);
|
||||||
|
|
||||||
core.ui._drawEquipbox(equipType);
|
|
||||||
core.status.route.push(action);
|
|
||||||
if (core.status.replay.speed == 24) {
|
if (core.status.replay.speed == 24) {
|
||||||
core.unloadEquip(equipType, cb);
|
core.unloadEquip(equipType);
|
||||||
|
cb();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
core.ui.closePanel();
|
core.ui.closePanel();
|
||||||
core.unloadEquip(equipType, cb);
|
core.unloadEquip(equipType);
|
||||||
|
cb();
|
||||||
}, core.control.__replay_getTimeout());
|
}, core.control.__replay_getTimeout());
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -3050,6 +3064,7 @@ control.prototype.clearStatusBar = function () {
|
|||||||
////// 更新状态栏 //////
|
////// 更新状态栏 //////
|
||||||
control.prototype.updateStatusBar = function (doNotCheckAutoEvents, immediate) {
|
control.prototype.updateStatusBar = function (doNotCheckAutoEvents, immediate) {
|
||||||
if (!core.isPlaying()) return;
|
if (!core.isPlaying()) return;
|
||||||
|
core.clearRouteFolding();
|
||||||
if (immediate) {
|
if (immediate) {
|
||||||
return this.updateStatusBar_update();
|
return this.updateStatusBar_update();
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,6 @@ items.prototype.loadEquip = function (equipId, callback) {
|
|||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
core.status.route.push(`equip:${equipId}`);
|
|
||||||
|
|
||||||
this._realLoadEquip(
|
this._realLoadEquip(
|
||||||
type,
|
type,
|
||||||
@ -304,7 +303,7 @@ items.prototype.unloadEquip = function (equipType, callback) {
|
|||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
core.status.route.push(`unequip:${unloadEquipId}`);
|
core.status.route.push(`unequip:${equipType}`);
|
||||||
|
|
||||||
this._realLoadEquip(equipType, null, unloadEquipId, callback);
|
this._realLoadEquip(equipType, null, unloadEquipId, callback);
|
||||||
};
|
};
|
||||||
@ -354,6 +353,7 @@ items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) {
|
|||||||
if (loadId) core.removeItem(loadId);
|
if (loadId) core.removeItem(loadId);
|
||||||
if (unloadId) core.addItem(unloadId);
|
if (unloadId) core.addItem(unloadId);
|
||||||
core.status.hero.equipment[type] = loadId || null;
|
core.status.hero.equipment[type] = loadId || null;
|
||||||
|
if (loadId) core.status.route.push(`equip:${type}:${loadId}`);
|
||||||
|
|
||||||
// --- 提示
|
// --- 提示
|
||||||
if (loadId) core.drawTip('已装备上' + loadEquip.name, loadId);
|
if (loadId) core.drawTip('已装备上' + loadEquip.name, loadId);
|
||||||
|
@ -58,6 +58,7 @@ export class HeroKeyMover {
|
|||||||
|
|
||||||
private onPressKey = (code: KeyCode) => {
|
private onPressKey = (code: KeyCode) => {
|
||||||
if (core.isReplaying()) return;
|
if (core.isReplaying()) return;
|
||||||
|
core.waitHeroToStop();
|
||||||
if (code === this.hotkeyData.left.key) this.press('left');
|
if (code === this.hotkeyData.left.key) this.press('left');
|
||||||
else if (code === this.hotkeyData.right.key) this.press('right');
|
else if (code === this.hotkeyData.right.key) this.press('right');
|
||||||
else if (code === this.hotkeyData.up.key) this.press('up');
|
else if (code === this.hotkeyData.up.key) this.press('up');
|
||||||
|
@ -255,7 +255,9 @@ export class HeroRenderer
|
|||||||
move(dir: Dir2): Promise<void> {
|
move(dir: Dir2): Promise<void> {
|
||||||
if (!this.moving) {
|
if (!this.moving) {
|
||||||
logger.error(12);
|
logger.error(12);
|
||||||
return Promise.reject();
|
return Promise.reject(
|
||||||
|
'Cannot moving hero while hero not in moving!'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.moveDir = dir;
|
this.moveDir = dir;
|
||||||
@ -276,7 +278,7 @@ export class HeroRenderer
|
|||||||
* 结束勇士的移动过程
|
* 结束勇士的移动过程
|
||||||
*/
|
*/
|
||||||
endMove(): Promise<void> {
|
endMove(): Promise<void> {
|
||||||
if (!this.moving) return Promise.reject();
|
if (!this.moving) return Promise.resolve();
|
||||||
if (this.moveEnding) return this.moveEnding;
|
if (this.moveEnding) return this.moveEnding;
|
||||||
else {
|
else {
|
||||||
const promise = new Promise<void>(resolve => {
|
const promise = new Promise<void>(resolve => {
|
||||||
@ -347,8 +349,8 @@ export class HeroRenderer
|
|||||||
* 因为此举会导致层级的重新排序,降低渲染性能。
|
* 因为此举会导致层级的重新排序,降低渲染性能。
|
||||||
*/
|
*/
|
||||||
moveAs(x: number, y: number, time: number, fn: TimingFn<3>): Promise<void> {
|
moveAs(x: number, y: number, time: number, fn: TimingFn<3>): Promise<void> {
|
||||||
if (!this.moving) return Promise.reject();
|
if (!this.moving) return Promise.resolve();
|
||||||
if (!this.renderable) return Promise.reject();
|
if (!this.renderable) return Promise.resolve();
|
||||||
let nowZIndex = fn(0)[2];
|
let nowZIndex = fn(0)[2];
|
||||||
let startTime = Date.now();
|
let startTime = Date.now();
|
||||||
return new Promise(res => {
|
return new Promise(res => {
|
||||||
|
@ -486,12 +486,10 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
const adapter = HeroMover.adapter;
|
const adapter = HeroMover.adapter;
|
||||||
const viewport = HeroMover.viewport;
|
const viewport = HeroMover.viewport;
|
||||||
if (!adapter || !viewport) return;
|
if (!adapter || !viewport) return;
|
||||||
// if (!core.isReplaying()) {
|
|
||||||
if (!core.isReplaying() || core.status.replay.speed <= 3) {
|
if (!core.isReplaying() || core.status.replay.speed <= 3) {
|
||||||
adapter.sync('startAnimate');
|
adapter.sync('startAnimate');
|
||||||
await adapter.all('readyMove');
|
await adapter.all('readyMove');
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
// 这里要检查前面那一格能不能走,不能走则不触发平滑视角,以避免撞墙上视角卡住
|
// 这里要检查前面那一格能不能走,不能走则不触发平滑视角,以避免撞墙上视角卡住
|
||||||
if (!this.ignoreTerrain) {
|
if (!this.ignoreTerrain) {
|
||||||
const { x, y } = core.status.hero.loc;
|
const { x, y } = core.status.hero.loc;
|
||||||
@ -515,12 +513,8 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
const adapter = HeroMover.adapter;
|
const adapter = HeroMover.adapter;
|
||||||
const viewport = HeroMover.viewport;
|
const viewport = HeroMover.viewport;
|
||||||
if (!adapter || !viewport) return;
|
if (!adapter || !viewport) return;
|
||||||
// if (!core.isReplaying()) {
|
|
||||||
if (!core.isReplaying() || core.status.replay.speed <= 3) {
|
|
||||||
await adapter.all('endMove');
|
|
||||||
adapter.sync('endAnimate');
|
adapter.sync('endAnimate');
|
||||||
}
|
await adapter.all('endMove');
|
||||||
// }
|
|
||||||
viewport.sync('endMove');
|
viewport.sync('endMove');
|
||||||
core.clearContinueAutomaticRoute();
|
core.clearContinueAutomaticRoute();
|
||||||
core.stopAutomaticRoute();
|
core.stopAutomaticRoute();
|
||||||
@ -623,6 +617,7 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
if (x === 0) core.trigger(floor.width - 1, y);
|
if (x === 0) core.trigger(floor.width - 1, y);
|
||||||
else core.trigger(0, y);
|
else core.trigger(0, y);
|
||||||
}
|
}
|
||||||
|
core.checkRouteFolding();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,9 +688,13 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
viewport.all('moveTo', x, y, speed * 1.6);
|
viewport.all('moveTo', x, y, speed * 1.6);
|
||||||
adapter.sync('setAnimateDir', showDir);
|
adapter.sync('setAnimateDir', showDir);
|
||||||
if (core.isReplaying() && core.status.replay.speed > 3) {
|
if (core.isReplaying() && core.status.replay.speed > 3) {
|
||||||
|
adapter.sync('endAnimate');
|
||||||
await sleep(speed);
|
await sleep(speed);
|
||||||
await adapter.all('setHeroLoc', x, y);
|
await adapter.all('setHeroLoc', x, y);
|
||||||
} else {
|
} else {
|
||||||
|
if (core.isReplaying()) {
|
||||||
|
adapter.sync('startAnimate');
|
||||||
|
}
|
||||||
await adapter.all('move', moveDir);
|
await adapter.all('move', moveDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ export function init() {
|
|||||||
core.control.controldata.updateStatusBar();
|
core.control.controldata.updateStatusBar();
|
||||||
if (!core.control.noAutoEvents) core.checkAutoEvents();
|
if (!core.control.noAutoEvents) core.checkAutoEvents();
|
||||||
core.control._updateStatusBar_setToolboxIcon();
|
core.control._updateStatusBar_setToolboxIcon();
|
||||||
core.clearRouteFolding();
|
|
||||||
core.control.noAutoEvents = true;
|
core.control.noAutoEvents = true;
|
||||||
// 更新vue状态栏
|
// 更新vue状态栏
|
||||||
updateVueStatusBar();
|
updateVueStatusBar();
|
||||||
|
1
src/source/data.d.ts
vendored
1
src/source/data.d.ts
vendored
@ -232,6 +232,7 @@ type BgmIds =
|
|||||||
|
|
||||||
type FontIds =
|
type FontIds =
|
||||||
| 'normal'
|
| 'normal'
|
||||||
|
| 'FiraCode'
|
||||||
|
|
||||||
interface NameMap {
|
interface NameMap {
|
||||||
'确定': 'confirm.mp3';
|
'确定': 'confirm.mp3';
|
||||||
|
Loading…
Reference in New Issue
Block a user