fix: 瞬移

This commit is contained in:
unanmed 2024-08-21 22:52:04 +08:00
parent 529968a7a1
commit e5291e335a
3 changed files with 35 additions and 19 deletions

View File

@ -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 = [

View File

@ -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) {

View File

@ -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<HeroRenderer>;
@ -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 };