reafactor: 目录结构修改

This commit is contained in:
unanmed 2026-04-15 22:32:07 +08:00
parent 63e1a01fab
commit 6c1acb990e
17 changed files with 35 additions and 131 deletions

View File

@ -1,5 +1,4 @@
import { IRange, logger } from '@motajs/common';
import { ITileLocator } from '@user/types';
import { IRange, ITileLocator, logger } from '@motajs/common';
import {
IAuraConverter,
IAuraView,

View File

@ -1,5 +1,4 @@
import { logger } from '@motajs/common';
import { ITileLocator } from '@user/types';
import { logger, ITileLocator } from '@motajs/common';
import {
IEnemyContext,
IEnemyView,

View File

@ -1,5 +1,4 @@
import { IRange } from '@motajs/common';
import { ITileLocator } from '@user/types';
import { IRange, ITileLocator } from '@motajs/common';
export interface ISpecial<T = void> {
/** 特殊属性代码 */

View File

@ -1,4 +1,4 @@
import { ITileLocator } from '@user/types';
import { ITileLocator } from '@motajs/common';
import { IMapLocIndexer } from './types';
export class MapLocIndexer implements IMapLocIndexer {

View File

@ -1,12 +1,13 @@
import { ICoreState, IGameDataState, IStateSaveData } from './types';
import { ICoreState, IStateSaveData } from './types';
import { IHeroState, HeroState } from './hero';
import { ILayerState, LayerState } from './map';
import { IRoleFaceBinder, RoleFaceBinder } from './common';
import { GameDataState } from './data';
import {
DamageSystem,
EnemyContext,
EnemyManager,
IEnemyContext,
IEnemyManager,
MapDamage
} from '@user/data-base';
import { IEnemyAttributes } from './enemy/types';
@ -15,16 +16,19 @@ import {
GuardAuraConverter,
MainEnemyFinalEffect,
MainMapDamageConverter,
MainMapDamageReducer
MainMapDamageReducer,
registerSpecials
} from './enemy';
import { TILE_HEIGHT, TILE_WIDTH } from './shared';
export class CoreState implements ICoreState {
readonly layer: ILayerState;
readonly hero: IHeroState;
readonly roleFace: IRoleFaceBinder;
readonly data: IGameDataState;
readonly idNumberMap: Map<string, number>;
readonly numberIdMap: Map<number, string>;
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
readonly enemyContext: IEnemyContext<IEnemyAttributes>;
constructor() {
@ -33,8 +37,10 @@ export class CoreState implements ICoreState {
this.roleFace = new RoleFaceBinder();
this.idNumberMap = new Map();
this.numberIdMap = new Map();
this.data = new GameDataState();
// 怪物管理器初始化
this.enemyManager = new EnemyManager();
registerSpecials(this.enemyManager);
// 怪物上下文初始化
const enemyContext = new EnemyContext<IEnemyAttributes>();
const damageSystem = new DamageSystem(enemyContext);
@ -46,7 +52,7 @@ export class CoreState implements ICoreState {
enemyContext.registerAuraConverter(new CommonAuraConverter());
enemyContext.registerAuraConverter(new GuardAuraConverter());
enemyContext.registerFinalEffect(new MainEnemyFinalEffect());
enemyContext.resize(core._WIDTH_, core._HEIGHT_);
enemyContext.resize(TILE_WIDTH, TILE_HEIGHT);
this.enemyContext = enemyContext;
}

View File

@ -1,13 +0,0 @@
import { EnemyManager, IEnemyManager } from '@user/data-base';
import { IEnemyAttributes } from './enemy/types';
import { IGameDataState } from './types';
import { registerSpecials } from './enemy';
export class GameDataState implements IGameDataState {
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
constructor() {
this.enemyManager = new EnemyManager<IEnemyAttributes>();
registerSpecials(this.enemyManager);
}
}

View File

@ -3,6 +3,7 @@ import {
IManhattanRangeParam,
IRange,
IRectRangeParam,
ITileLocator,
ManhattanRange,
RectRange
} from '@motajs/common';
@ -17,7 +18,6 @@ import {
IEnemy
} from '@user/data-base';
import { IHaloValue } from './special';
import { ITileLocator } from '@user/types';
import { IEnemyAttributes } from './types';
const FULL_RANGE = new FullRange();

View File

@ -1,6 +1,6 @@
import { IEnemy, IEnemyFinalEffect } from '@user/data-base';
import { IEnemyAttributes } from './types';
import { ITileLocator } from '@user/types';
import { ITileLocator } from '@motajs/common';
const HERO_STATUS_PLACEHOLDER = {
atk: 0,

View File

@ -8,9 +8,9 @@ import {
IRectRangeParam,
ManhattanRange,
RayRange,
RectRange
RectRange,
ITileLocator
} from '@motajs/common';
import { ITileLocator } from '@user/types';
import { IReadonlyEnemy, ISpecial } from '@user/data-base';
import {
IEnemyContext,

View File

@ -1,2 +1,7 @@
/** 每个地图的默认宽度 */
export const TILE_WIDTH = 13;
/** 每个地图的默认高度 */
export const TILE_HEIGHT = 13;
/** 默认的勇士图片 */
export const DEFAULT_HERO_IMAGE: ImageIds = 'hero.png';

View File

@ -21,13 +21,13 @@ export interface ICoreState {
readonly hero: IHeroState;
/** 朝向绑定 */
readonly roleFace: IRoleFaceBinder;
/** 游戏数据状态 */
readonly data: IGameDataState;
/** id 到图块数字的映射 */
readonly idNumberMap: Map<string, number>;
/** 图块数字到 id 的映射 */
readonly numberIdMap: Map<number, string>;
/** 怪物管理器 */
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
/** 怪物上下文 */
readonly enemyContext: IEnemyContext<IEnemyAttributes>;

View File

@ -1,3 +0,0 @@
{
"name": "@user/types"
}

View File

@ -1,87 +0,0 @@
// todo: 2.C
export interface IEnemyInfo {}
export interface IDamageInfo {}
export interface IDamageEnemy {
/** 原始怪物信息 */
readonly enemy: Enemy;
/** 该怪物所属的怪物列表 */
readonly collection: IEnemyCollection | null;
/** 怪物横坐标 */
readonly x: number | undefined;
/**
*
*/
getEnemyInfo(): IEnemyInfo;
/**
*
*/
getDamageInfo(): IDamageInfo;
}
export interface IMapDamage {
/** 伤害类型 */
readonly type: string;
/** 伤害值 */
readonly damage: number;
/** 伤害优先级 */
readonly priority: number;
}
export interface IMapDamageSummary {
/** 该点的总伤害 */
readonly totalDamage: number;
/** 该点的伤害信息 */
readonly damages: IMapDamage[];
}
export interface IEnemyCollection {
/** 怪物列表,索引为 x + width * y值表示该点对应的怪物 */
readonly list: Map<number, IDamageEnemy>;
/** 楼层 id */
readonly floorId: FloorIds;
/** 楼层宽度 */
readonly width: number;
/** 楼层高度 */
readonly height: number;
/** 地图伤害 */
readonly mapDamage: Map<number, IMapDamageSummary>;
/** 用于计算本怪物列表中怪物信息的勇士属性 */
readonly hero: HeroStatus;
/**
* null
* @param x
* @param y
*/
getEnemy(x: number, y: number): IDamageEnemy | null;
/**
* null
* @param x
* @param y
*/
getMapDamage(x: number, y: number): IMapDamageSummary | null;
/**
*
*/
refresh(): void;
/**
*
* @param status
*/
with(status: HeroStatus): IEnemyCollection;
}
export interface IDamageSystem {
readonly collections: Map<FloorIds, IEnemyCollection>;
}

View File

@ -1,2 +0,0 @@
export * from './enemy';
export * from './spatial';

View File

@ -1,6 +0,0 @@
export interface ITileLocator {
/** 图块所在横坐标 */
x: number;
/** 图块所在纵坐标 */
y: number;
}

View File

@ -135,6 +135,13 @@ export interface IRayRangeParam {
//#region 实用接口
export interface ITileLocator {
/** 图块所在横坐标 */
x: number;
/** 图块所在纵坐标 */
y: number;
}
export const enum InternalDirectionGroup {
/** 上下左右四方向 */
Dir4,