fix: 勇士事件移动时不应记录录像

This commit is contained in:
unanmed 2026-09-13 20:42:48 +08:00
parent 0ba70e1a63
commit b623e8ac98
4 changed files with 9 additions and 41 deletions

View File

@ -18,11 +18,9 @@ import {
EventMoveBlock,
EventMoveHero,
EventStepHero,
EventSetBlock,
EventTouchFront
EventSetBlock
} from './index';
import { EventSetBlock as MapEventSetBlock } from './map';
import { EventTouchFront as HeroEventTouchFront } from './hero';
import { EventInsertEvent as ControlEventInsertEvent } from './event';
import * as dataStateRoot from '../index';
@ -307,9 +305,8 @@ describe('event registration ownership', () => {
expect(registrations[2]).toBeInstanceOf(EventRemoveBlock);
expect(registrations[3]).toBeInstanceOf(EventMoveHero);
expect(registrations[4]).toBeInstanceOf(EventStepHero);
expect(registrations[5]).toBeInstanceOf(EventTouchFront);
expect(registrations[6]).toBeInstanceOf(EventInsertEvents);
expect(registrations[7]).toBeInstanceOf(EventInsertEvent);
expect(registrations[5]).toBeInstanceOf(EventInsertEvents);
expect(registrations[6]).toBeInstanceOf(EventInsertEvent);
expect(createEventRegistrations()).not.toBe(registrations);
expect(createEventRegistrations()[0]).not.toBe(registrations[0]);
});
@ -326,11 +323,7 @@ describe('event registration ownership', () => {
// 验证注册类分别来自地图勇士事件模块且勇士面前注册类归 hero 所有
it('originates registration classes from their owning event modules', () => {
expect(EventSetBlock).toBe(MapEventSetBlock);
expect(EventTouchFront).toBe(HeroEventTouchFront);
expect(EventInsertEvent).toBe(ControlEventInsertEvent);
expect(getRegistration('touchFront')).toBeInstanceOf(
HeroEventTouchFront
);
});
// 验证事件 barrel 仅含导出语句且既有公开事件符号仍可从根索引导入

View File

@ -1,11 +1,6 @@
import { BuiltInFunction } from '@motajs/anon-tokyo';
import { IBlockEventEnv } from '@user/data-system';
import {
IMoveHeroEventParam,
IStepHeroEventParam,
ITouchFrontEventParam
} from './types';
import { getPossibleLayer } from './utils';
import { IMoveHeroEventParam, IStepHeroEventParam } from './types';
export class EventMoveHero implements BuiltInFunction<
IMoveHeroEventParam,
@ -17,10 +12,12 @@ export class EventMoveHero implements BuiltInFunction<
const mover = env.state.hero.location.mover;
if (mover.moving) return;
mover.config({ noRoute: true });
mover.push([...param.steps]);
const controller = mover.start();
if (!controller) return;
await controller.onEnd;
mover.config({ noRoute: false });
}
}
@ -34,29 +31,11 @@ export class EventStepHero implements BuiltInFunction<
const mover = env.state.hero.location.mover;
if (mover.moving) return;
mover.config({ noRoute: true });
mover.forward(1);
const controller = mover.start();
if (!controller) return;
await controller.onEnd;
}
}
export class EventTouchFront implements BuiltInFunction<
ITouchFrontEventParam,
IBlockEventEnv
> {
name: string = 'touchFront';
async func(_param: ITouchFrontEventParam, env: IBlockEventEnv) {
const layer = getPossibleLayer(env);
if (!layer) return;
const mover = env.state.hero.location.mover;
if (mover.moving) return;
mover.forward();
const controller = mover.start();
if (!controller) return;
await controller.onEnd;
mover.config({ noRoute: false });
}
}

View File

@ -1,6 +1,6 @@
import { BuiltInFunction } from '@motajs/anon-tokyo';
import { EventRemoveBlock, EventMoveBlock, EventSetBlock } from './map';
import { EventMoveHero, EventStepHero, EventTouchFront } from './hero';
import { EventMoveHero, EventStepHero } from './hero';
import { EventInsertEvent, EventInsertEvents } from './event';
/**
@ -16,7 +16,6 @@ export function createEventRegistrations(): BuiltInFunction[] {
// 玩家控制
new EventMoveHero(),
new EventStepHero(),
new EventTouchFront(),
// 事件控制
new EventInsertEvents(),

View File

@ -50,9 +50,6 @@ export interface IMoveHeroEventParam {
/** 事件:向前移动一步 */
export interface IStepHeroEventParam {}
/** 事件:勇士向前一步,前方不可通行时触发撞击 */
export interface ITouchFrontEventParam {}
//#endregion
//#region 事件控制