From b623e8ac98defadc4a7aa73adffa0e9773fe44bf Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sun, 13 Sep 2026 20:42:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8B=87=E5=A3=AB=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E6=97=B6=E4=B8=8D=E5=BA=94=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=BD=95=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-state/src/event/event.test.ts | 13 ++------ packages-user/data-state/src/event/hero.ts | 31 +++---------------- .../data-state/src/event/registrations.ts | 3 +- packages-user/data-state/src/event/types.ts | 3 -- 4 files changed, 9 insertions(+), 41 deletions(-) diff --git a/packages-user/data-state/src/event/event.test.ts b/packages-user/data-state/src/event/event.test.ts index 633721e..4b77d8f 100644 --- a/packages-user/data-state/src/event/event.test.ts +++ b/packages-user/data-state/src/event/event.test.ts @@ -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 仅含导出语句且既有公开事件符号仍可从根索引导入 diff --git a/packages-user/data-state/src/event/hero.ts b/packages-user/data-state/src/event/hero.ts index 40649a7..92972bb 100644 --- a/packages-user/data-state/src/event/hero.ts +++ b/packages-user/data-state/src/event/hero.ts @@ -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 }); } } diff --git a/packages-user/data-state/src/event/registrations.ts b/packages-user/data-state/src/event/registrations.ts index b2ba178..9450946 100644 --- a/packages-user/data-state/src/event/registrations.ts +++ b/packages-user/data-state/src/event/registrations.ts @@ -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(), diff --git a/packages-user/data-state/src/event/types.ts b/packages-user/data-state/src/event/types.ts index d5a8441..7d0f74f 100644 --- a/packages-user/data-state/src/event/types.ts +++ b/packages-user/data-state/src/event/types.ts @@ -50,9 +50,6 @@ export interface IMoveHeroEventParam { /** 事件:向前移动一步 */ export interface IStepHeroEventParam {} -/** 事件:勇士向前一步,前方不可通行时触发撞击 */ -export interface ITouchFrontEventParam {} - //#endregion //#region 事件控制