refactor: CoreState 一部分类型声明挪到 data-base

This commit is contained in:
unanmed 2026-04-21 21:01:53 +08:00
parent 1a569804d8
commit ec59a44efc
15 changed files with 98 additions and 109 deletions

View File

@ -1,2 +1,3 @@
export * from './face';
export * from './types';
export * from './utils';

View File

@ -16,3 +16,39 @@ export interface IFaceData {
/** 图块朝向 */
readonly face: FaceDirection;
}
export interface IRoleFaceBinder {
/**
*
* @param identifier
* @param main
*/
malloc(identifier: number, main: FaceDirection): void;
/**
* {@link malloc}
* @param identifier
* @param main
* @param face
*/
bind(identifier: number, main: number, face: FaceDirection): void;
/**
*
* @param identifier
* @param face
*/
getFaceOf(identifier: number, face: FaceDirection): IFaceData | null;
/**
*
* @param identifier
*/
getFaceDirection(identifier: number): FaceDirection | undefined;
/**
*
* @param identifier
*/
getMainFace(identifier: number): IFaceData | null;
}

View File

@ -3,5 +3,7 @@ export * from './enemy';
export * from './flag';
export * from './hero';
export * from './load';
export * from './map';
export * from './game';
export * from './types';

View File

@ -0,0 +1,50 @@
import { IMotaDataLoader } from './load';
import { ILoadProgressTotal } from '@motajs/loader';
import { IHeroFollower, IHeroState } from './hero';
import { IEnemyContext, IEnemyManager } from './enemy';
import { IFlagSystem } from './flag';
import { IRoleFaceBinder } from './common';
import { ILayerState } from './map';
export interface IStateSaveData {
/** 跟随者列表 */
readonly followers: readonly IHeroFollower[];
}
export interface IStateBase<TEnemy, THero> {
/** 朝向绑定 */
readonly roleFace: IRoleFaceBinder;
/** id 到图块数字的映射 */
readonly idNumberMap: Map<string, number>;
/** 图块数字到 id 的映射 */
readonly numberIdMap: Map<number, string>;
/** 加载进度对象 */
readonly loadProgress: ILoadProgressTotal;
/** 数据端加载对象 */
readonly dataLoader: IMotaDataLoader;
/** 地图状态 */
readonly layer: ILayerState;
/** 勇士状态 */
readonly hero: IHeroState<THero>;
/** 怪物管理器 */
readonly enemyManager: IEnemyManager<TEnemy>;
/** 怪物上下文 */
readonly enemyContext: IEnemyContext<TEnemy, THero>;
/** Flag 系统 */
readonly flags: IFlagSystem;
/**
*
*/
saveState(): IStateSaveData;
/**
*
* @param state
*/
loadState(state: IStateSaveData): void;
}

View File

@ -1,3 +0,0 @@
export * from './face';
export * from './types';
export * from './utils';

View File

@ -1,40 +0,0 @@
import { FaceDirection, type IFaceData } from '@user/data-base';
export { FaceDirection };
export type { IFaceData } from '@user/data-base';
export interface IRoleFaceBinder {
/**
*
* @param identifier
* @param main
*/
malloc(identifier: number, main: FaceDirection): void;
/**
* {@link malloc}
* @param identifier
* @param main
* @param face
*/
bind(identifier: number, main: number, face: FaceDirection): void;
/**
*
* @param identifier
* @param face
*/
getFaceOf(identifier: number, face: FaceDirection): IFaceData | null;
/**
*
* @param identifier
*/
getFaceDirection(identifier: number): FaceDirection | undefined;
/**
*
* @param identifier
*/
getMainFace(identifier: number): IFaceData | null;
}

View File

@ -1,6 +0,0 @@
export {
degradeFace,
fromDirectionString,
getFaceMovement,
nextFaceDirection
} from '@user/data-base';

View File

@ -1,6 +1,4 @@
import { ICoreState, IStateSaveData } from './types';
import { ILayerState, LayerState } from './map';
import { FaceDirection, IRoleFaceBinder, RoleFaceBinder } from './common';
import {
DamageSystem,
EnemyContext,
@ -16,7 +14,12 @@ import {
FlagSystem,
IMotaDataLoader,
MotaDataLoader,
loading
loading,
IRoleFaceBinder,
ILayerState,
LayerState,
RoleFaceBinder,
FaceDirection
} from '@user/data-base';
import { IEnemyAttr } from './enemy/types';
import {

View File

@ -1,6 +1,5 @@
import { loading } from '@user/data-base';
import { FaceDirection, loading } from '@user/data-base';
import { isNil } from 'lodash-es';
import { FaceDirection } from './common';
import { ICoreState } from './types';
import { TILE_HEIGHT, TILE_WIDTH } from './shared';
import { state } from './ins';
@ -62,11 +61,9 @@ export function create() {
});
}
export * from './common';
export * from './enemy';
export * from './hero';
export * from './legacy';
export * from './map';
export * from './core';
export * from './ins';

View File

@ -1,61 +1,10 @@
import { ILayerState } from './map';
import { IRoleFaceBinder } from './common';
import {
IEnemyContext,
IEnemyManager,
IHeroFollower,
IHeroState,
IMotaDataLoader
} from '@user/data-base';
import { IHeroFollower, IStateBase } from '@user/data-base';
import { IEnemyAttr } from './enemy/types';
import { IHeroAttr } from './hero';
import { IFlagSystem } from '../../data-base/src/flag/types';
import { ILoadProgressTotal } from '@motajs/loader';
export interface IGameDataState {
/** 怪物管理器 */
readonly enemyManager: IEnemyManager<IEnemyAttr>;
}
export interface IStateSaveData {
/** 跟随者列表 */
readonly followers: readonly IHeroFollower[];
}
export interface ICoreState {
/** 朝向绑定 */
readonly roleFace: IRoleFaceBinder;
/** id 到图块数字的映射 */
readonly idNumberMap: Map<string, number>;
/** 图块数字到 id 的映射 */
readonly numberIdMap: Map<number, string>;
/** 加载进度对象 */
readonly loadProgress: ILoadProgressTotal;
/** 数据端加载对象 */
readonly dataLoader: IMotaDataLoader;
/** 地图状态 */
readonly layer: ILayerState;
/** 勇士状态 */
readonly hero: IHeroState<IHeroAttr>;
/** 怪物管理器 */
readonly enemyManager: IEnemyManager<IEnemyAttr>;
/** 怪物上下文 */
readonly enemyContext: IEnemyContext<IEnemyAttr, IHeroAttr>;
/** Flag 系统 */
readonly flags: IFlagSystem;
/**
*
*/
saveState(): IStateSaveData;
/**
*
* @param data
*/
loadState(data: IStateSaveData): void;
}
export interface ICoreState extends IStateBase<IEnemyAttr, IHeroAttr> {}