mirror of
https://github.com/motajs/template.git
synced 2026-09-25 20:10:17 +08:00
- rename deleteBlock -> removeBlock (dynamic tiles need dynamic:true), moveHeroStep -> stepHero; touchFront steps forward and lets the mover bump - GameEventSystem.collectEvent owns point/tile source collection; moverImpl enter/leave/hit reuse it with OnEnter/OnLeave/OnTouch - IBlockEventEnv gains required system field and nullable heroFloor - MapLayer.removeBlock added and setBlock guarded by inMap; GameMap owns floorId - IObjectMover.push accepts readonly steps - update event/eventDispatch tests to the current implementation (fixtures supply system, hero location snapshots, renamed registrations) Verified: data type gate 0 in-scope; vitest 19 files / 112 tests pass; prettier and eslint clean on touched files.
31 lines
767 B
TypeScript
31 lines
767 B
TypeScript
import { IGameMap, IMapLayer } from '@user/data-base';
|
|
import { IBlockEventEnv } from '@user/data-system';
|
|
import { isNil } from 'lodash-es';
|
|
|
|
/**
|
|
* 通过环境参量获取可能的地图对象
|
|
*/
|
|
export function getPossibleMap(env: IBlockEventEnv): IGameMap | null {
|
|
if (env.map) return env.map;
|
|
if (env.layer) return env.layer.map;
|
|
|
|
if (!isNil(env.heroFloor)) {
|
|
const map = env.state.maps.getMap(env.heroFloor);
|
|
if (map) return map;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 通过环境参量获取可能的事件图层
|
|
*/
|
|
export function getPossibleLayer(env: IBlockEventEnv): IMapLayer | null {
|
|
if (env.layer) return env.layer;
|
|
|
|
const map = getPossibleMap(env);
|
|
if (map?.eventLayer) return map.eventLayer;
|
|
|
|
return null;
|
|
}
|