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