mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-31 23:29:27 +08:00
fix: 自动存档 & 事件触发
This commit is contained in:
parent
c7f7cf280b
commit
b881cc1d2e
@ -111,7 +111,7 @@ export class HeroKeyMover {
|
|||||||
if (this.moving || core.status.lockControl) return false;
|
if (this.moving || core.status.lockControl) return false;
|
||||||
|
|
||||||
this.mover.oneStep(this.moveDir);
|
this.mover.oneStep(this.moveDir);
|
||||||
const controller = this.mover.startMove();
|
const controller = this.mover.startMove(false, false, false, true);
|
||||||
if (!controller) return;
|
if (!controller) return;
|
||||||
|
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
|
@ -400,6 +400,8 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
private noRoute: boolean = false;
|
private noRoute: boolean = false;
|
||||||
/** 当前移动是否是在lockControl条件下开始的 */
|
/** 当前移动是否是在lockControl条件下开始的 */
|
||||||
private inLockControl: boolean = false;
|
private inLockControl: boolean = false;
|
||||||
|
/** 是否会在特殊时刻进行自动存档 */
|
||||||
|
private autoSave: boolean = false;
|
||||||
|
|
||||||
/** 这一步的传送门信息 */
|
/** 这一步的传送门信息 */
|
||||||
private portalData?: BluePalace.PortalTo;
|
private portalData?: BluePalace.PortalTo;
|
||||||
@ -407,14 +409,27 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
override startMove(
|
override startMove(
|
||||||
ignoreTerrain: boolean = false,
|
ignoreTerrain: boolean = false,
|
||||||
noRoute: boolean = false,
|
noRoute: boolean = false,
|
||||||
inLockControl: boolean = false
|
inLockControl: boolean = false,
|
||||||
|
autoSave: boolean = false
|
||||||
): IMoveController | null {
|
): IMoveController | null {
|
||||||
this.ignoreTerrain = ignoreTerrain;
|
this.ignoreTerrain = ignoreTerrain;
|
||||||
this.noRoute = noRoute;
|
this.noRoute = noRoute;
|
||||||
this.inLockControl = inLockControl;
|
this.inLockControl = inLockControl;
|
||||||
|
this.autoSave = autoSave;
|
||||||
return super.startMove();
|
return super.startMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private checkAutoSave(x: number, y: number) {
|
||||||
|
const index = `${x},${y}`;
|
||||||
|
const map = core.status.thisMap.enemy.mapDamage;
|
||||||
|
const dam = map[index];
|
||||||
|
if (!dam) return false;
|
||||||
|
if (dam.mockery || dam.hunt) {
|
||||||
|
core.autosave();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected async onMoveStart(controller: IMoveController): Promise<void> {
|
protected async onMoveStart(controller: IMoveController): Promise<void> {
|
||||||
const adapter = HeroMover.adapter;
|
const adapter = HeroMover.adapter;
|
||||||
if (!adapter) return;
|
if (!adapter) return;
|
||||||
@ -441,6 +456,8 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
const { x, y } = core.status.hero.loc;
|
const { x, y } = core.status.hero.loc;
|
||||||
const { x: nx, y: ny } = this.nextLoc(x, y, this.moveDir);
|
const { x: nx, y: ny } = this.nextLoc(x, y, this.moveDir);
|
||||||
|
|
||||||
|
this.checkAutoSave(nx, ny);
|
||||||
|
|
||||||
if (!this.inLockControl && core.status.lockControl) {
|
if (!this.inLockControl && core.status.lockControl) {
|
||||||
controller.stop();
|
controller.stop();
|
||||||
return HeroMoveCode.Stop;
|
return HeroMoveCode.Stop;
|
||||||
|
@ -168,6 +168,7 @@ export function init() {
|
|||||||
}
|
}
|
||||||
if (name === 'direction') {
|
if (name === 'direction') {
|
||||||
adapters['hero-adapter']?.sync('turn', value);
|
adapters['hero-adapter']?.sync('turn', value);
|
||||||
|
adapters['hero-adapter']?.sync('setAnimateDir', value);
|
||||||
setHeroDirection(value as Dir);
|
setHeroDirection(value as Dir);
|
||||||
} else if (name === 'x') {
|
} else if (name === 'x') {
|
||||||
adapters['hero-adapter']?.sync('setHeroLoc', value);
|
adapters['hero-adapter']?.sync('setHeroLoc', value);
|
||||||
@ -181,9 +182,13 @@ export function init() {
|
|||||||
core.stopAutomaticRoute();
|
core.stopAutomaticRoute();
|
||||||
core.clearContinueAutomaticRoute();
|
core.clearContinueAutomaticRoute();
|
||||||
|
|
||||||
heroMover.controller?.stop().then(() => {
|
if (heroMover.controller) {
|
||||||
|
heroMover.controller.stop().then(() => {
|
||||||
|
callback?.();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
callback?.();
|
callback?.();
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
control.prototype.moveHero = async function (
|
control.prototype.moveHero = async function (
|
||||||
@ -191,11 +196,6 @@ export function init() {
|
|||||||
callback?: () => void
|
callback?: () => void
|
||||||
) {
|
) {
|
||||||
if (heroMover.moving) return;
|
if (heroMover.moving) return;
|
||||||
// const nx = core.nextX();
|
|
||||||
// const ny = core.nextY();
|
|
||||||
// if (core.status.thisMap.enemy.mapDamage[`${nx},${ny}`]?.mockery) {
|
|
||||||
// core.autosave();
|
|
||||||
// }
|
|
||||||
heroMover.clearMoveQueue();
|
heroMover.clearMoveQueue();
|
||||||
heroMover.oneStep(direction ?? 'forward');
|
heroMover.oneStep(direction ?? 'forward');
|
||||||
const lock = core.status.lockControl;
|
const lock = core.status.lockControl;
|
||||||
|
7
src/types/control.d.ts
vendored
7
src/types/control.d.ts
vendored
@ -772,6 +772,9 @@ interface Control {
|
|||||||
* @param noGather 是否聚集跟随者
|
* @param noGather 是否聚集跟随者
|
||||||
*/
|
*/
|
||||||
setHeroLoc(name: 'x' | 'y', value: number, noGather?: boolean): void;
|
setHeroLoc(name: 'x' | 'y', value: number, noGather?: boolean): void;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
setHeroLoc(name: 'direction', value: Dir, noGather?: boolean): void;
|
setHeroLoc(name: 'direction', value: Dir, noGather?: boolean): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -781,6 +784,10 @@ interface Control {
|
|||||||
* @param name 要读取横坐标还是纵坐标还是朝向还是都读取
|
* @param name 要读取横坐标还是纵坐标还是朝向还是都读取
|
||||||
*/
|
*/
|
||||||
getHeroLoc(): DiredLoc;
|
getHeroLoc(): DiredLoc;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param name 要读取横坐标还是纵坐标还是朝向还是都读取
|
||||||
|
*/
|
||||||
getHeroLoc<K extends keyof DiredLoc>(name: K): DiredLoc[K];
|
getHeroLoc<K extends keyof DiredLoc>(name: K): DiredLoc[K];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user