From e5291e335acbd024ce3941f96c3923910a1f455f Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Wed, 21 Aug 2024 22:52:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=9E=AC=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/libs/control.js | 1 + src/plugin/game/enemy/checkblock.ts | 18 --------------- src/plugin/game/fallback.ts | 35 ++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/public/libs/control.js b/public/libs/control.js index feac06f..28d6f2e 100644 --- a/public/libs/control.js +++ b/public/libs/control.js @@ -977,6 +977,7 @@ control.prototype.moveDirectly = function (destX, destY, ignoreSteps) { ////// 尝试瞬间移动 ////// control.prototype.tryMoveDirectly = function (destX, destY) { + // console.trace(); if (this.nearHero(destX, destY)) return false; var canMoveArray = core.maps.generateMovableArray(); var dirs = [ diff --git a/src/plugin/game/enemy/checkblock.ts b/src/plugin/game/enemy/checkblock.ts index 0ac2f5a..9344aea 100644 --- a/src/plugin/game/enemy/checkblock.ts +++ b/src/plugin/game/enemy/checkblock.ts @@ -87,24 +87,6 @@ export function init() { core.fillBoldText(ctx, one.text, px, py, one.color as string); }); }; - - control.prototype.moveHero = function ( - direction: Dir, - callback: () => void - ) { - // 如果正在移动,直接return - if (core.status.heroMoving != 0) return; - if (core.isset(direction)) core.setHeroLoc('direction', direction); - - const nx = core.nextX(); - const ny = core.nextY(); - if (core.status.thisMap.enemy.mapDamage[`${nx},${ny}`]?.mockery) { - core.autosave(); - } - - if (callback) return this.moveAction(callback); - this._moveHero_moving(); - }; } function checkMockery(loc: string, force: boolean = false) { diff --git a/src/plugin/game/fallback.ts b/src/plugin/game/fallback.ts index db3c9cd..eda195b 100644 --- a/src/plugin/game/fallback.ts +++ b/src/plugin/game/fallback.ts @@ -1,5 +1,6 @@ import type { RenderAdapter } from '@/core/render/adapter'; import type { HeroRenderer } from '@/core/render/preset/hero'; +import { hook } from '@/game/game'; interface Adapters { 'hero-adapter'?: RenderAdapter; @@ -77,7 +78,7 @@ export function init() { await adapter.all('readyMove'); moving = true; stopChian = false; - return startHeroMoveChain(); + startHeroMoveChain(); } } @@ -245,6 +246,38 @@ export function init() { callback?.(); }); }; + + control.prototype.moveHero = async function ( + direction: Dir, + callback: () => void + ) { + // 如果正在移动,直接return + if (core.status.heroMoving != 0) return; + if (core.isset(direction)) core.setHeroLoc('direction', direction); + + const nx = core.nextX(); + const ny = core.nextY(); + if (core.status.thisMap.enemy.mapDamage[`${nx},${ny}`]?.mockery) { + core.autosave(); + } + + console.trace(); + + moveDir = direction; + stepDir = direction; + await readyMove(); + stopChian = true; + + callback?.(); + + // if (callback) return this.moveAction(callback); + // this._moveHero_moving(); + }; + + hook.on('reset', () => { + moveDir = core.status.hero.loc.direction; + stepDir = moveDir; + }); }); return { readyMove, endMove, move };