mirror of
https://github.com/motajs/template.git
synced 2026-11-04 00:04:32 +08:00
refactor(03-18): move event registration assembly out of the barrel
- Add event/registrations.ts as the sole direct-construction assembler for the eight class-based registrations in stable map/hero/control order - Reduce event/index.ts and data-state/src/index.ts to export-only barrels that re-export the four public registration creators - Point CoreState at event/registrations and record the ownership and public-export boundaries in the event contract
This commit is contained in:
1 parent
cb716f699e
commit
0dc30aace8
7 files changed
+92
-58
No files matched your search
@@ -81,7 +81,7 @@ import { ILoadProgressTotal, LoadProgressTotal } from '@motajs/loader';
|
||||
import { isNil } from 'lodash-es';
|
||||
import { DirectionMapper, IDirectionMapper, logger } from '@motajs/common';
|
||||
import { DefaultHeroMoveTopImpl } from './hero';
|
||||
import { createEventBuiltinRegistrations } from './event';
|
||||
import { createEventBuiltinRegistrations } from './event/registrations';
|
||||
import { createReplayCommandItems, registerReplayCommandItems } from './replay';
|
||||
|
||||
export class CoreState implements ICoreState {
|
||||
|
||||
@@ -111,11 +111,3 @@ export class InsertEventEventRegistration implements BuiltInFunction {
|
||||
readonly func: BuiltInFunction['func'] =
|
||||
eventInsertEvent as BuiltInFunction['func'];
|
||||
}
|
||||
|
||||
/** 创建事件控制事件的内建函数注册项 */
|
||||
export function createControlEventBuiltinRegistrations(): ReadonlyArray<BuiltInFunction> {
|
||||
return [
|
||||
new InsertEventsEventRegistration(),
|
||||
new InsertEventEventRegistration()
|
||||
];
|
||||
}
|
||||
@@ -254,12 +254,3 @@ export class TouchFrontEventRegistration implements BuiltInFunction {
|
||||
readonly func: BuiltInFunction['func'] =
|
||||
eventTouchFront as BuiltInFunction['func'];
|
||||
}
|
||||
|
||||
/** 创建勇士控制事件的内建函数注册项 */
|
||||
export function createHeroEventBuiltinRegistrations(): ReadonlyArray<BuiltInFunction> {
|
||||
return [
|
||||
new MoveHeroEventRegistration(),
|
||||
new MoveHeroStepEventRegistration(),
|
||||
new TouchFrontEventRegistration()
|
||||
];
|
||||
}
|
||||
@@ -1,18 +1,9 @@
|
||||
import { BuiltInFunction } from 'anon-tokyo';
|
||||
|
||||
import { createControlEventBuiltinRegistrations } from './event';
|
||||
import { createHeroEventBuiltinRegistrations } from './hero';
|
||||
import { createMapEventBuiltinRegistrations } from './map';
|
||||
|
||||
/** 组装八个批准事件 built-in 的稳定注册项 */
|
||||
export function createEventBuiltinRegistrations(): ReadonlyArray<BuiltInFunction> {
|
||||
return [
|
||||
...createMapEventBuiltinRegistrations(),
|
||||
...createHeroEventBuiltinRegistrations(),
|
||||
...createControlEventBuiltinRegistrations()
|
||||
];
|
||||
}
|
||||
|
||||
export {
|
||||
createControlEventBuiltinRegistrations,
|
||||
createEventBuiltinRegistrations,
|
||||
createHeroEventBuiltinRegistrations,
|
||||
createMapEventBuiltinRegistrations
|
||||
} from './registrations';
|
||||
export * from './event';
|
||||
export * from './hero';
|
||||
export * from './map';
|
||||
|
||||
@@ -85,12 +85,3 @@ export class DeleteBlockEventRegistration implements BuiltInFunction {
|
||||
readonly func: BuiltInFunction['func'] =
|
||||
eventDeleteBlock as BuiltInFunction['func'];
|
||||
}
|
||||
|
||||
/** 创建地图控制事件的内建函数注册项 */
|
||||
export function createMapEventBuiltinRegistrations(): ReadonlyArray<BuiltInFunction> {
|
||||
return [
|
||||
new SetBlockEventRegistration(),
|
||||
new MoveBlockEventRegistration(),
|
||||
new DeleteBlockEventRegistration()
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { BuiltInFunction } from 'anon-tokyo';
|
||||
import {
|
||||
DeleteBlockEventRegistration,
|
||||
MoveBlockEventRegistration,
|
||||
SetBlockEventRegistration
|
||||
} from './map';
|
||||
import {
|
||||
MoveHeroEventRegistration,
|
||||
MoveHeroStepEventRegistration,
|
||||
TouchFrontEventRegistration
|
||||
} from './hero';
|
||||
import {
|
||||
InsertEventEventRegistration,
|
||||
InsertEventsEventRegistration
|
||||
} from './event';
|
||||
|
||||
/** 创建地图控制事件的内建函数注册项 */
|
||||
export function createMapEventBuiltinRegistrations(): ReadonlyArray<BuiltInFunction> {
|
||||
return [
|
||||
new SetBlockEventRegistration(),
|
||||
new MoveBlockEventRegistration(),
|
||||
new DeleteBlockEventRegistration()
|
||||
];
|
||||
}
|
||||
|
||||
/** 创建勇士控制事件的内建函数注册项 */
|
||||
export function createHeroEventBuiltinRegistrations(): ReadonlyArray<BuiltInFunction> {
|
||||
return [
|
||||
new MoveHeroEventRegistration(),
|
||||
new MoveHeroStepEventRegistration(),
|
||||
new TouchFrontEventRegistration()
|
||||
];
|
||||
}
|
||||
|
||||
/** 创建事件控制事件的内建函数注册项 */
|
||||
export function createControlEventBuiltinRegistrations(): ReadonlyArray<BuiltInFunction> {
|
||||
return [
|
||||
new InsertEventsEventRegistration(),
|
||||
new InsertEventEventRegistration()
|
||||
];
|
||||
}
|
||||
|
||||
/** 组装八个批准事件 built-in 的稳定注册项 */
|
||||
export function createEventBuiltinRegistrations(): ReadonlyArray<BuiltInFunction> {
|
||||
return [
|
||||
...createMapEventBuiltinRegistrations(),
|
||||
...createHeroEventBuiltinRegistrations(),
|
||||
...createControlEventBuiltinRegistrations()
|
||||
];
|
||||
}
|
||||
Reference in new issue
Block a user