mirror of
https://github.com/motajs/template.git
synced 2026-08-14 20:52:29 +08:00
Compare commits
1 Commits
c1b721774e
...
5e611d3a00
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e611d3a00 |
@ -6,14 +6,14 @@ import {
|
|||||||
ILayerStateSave,
|
ILayerStateSave,
|
||||||
IMapLayer,
|
IMapLayer,
|
||||||
IMapLayerSave,
|
IMapLayerSave,
|
||||||
IMapState,
|
IMapStore,
|
||||||
IMapStoreSave,
|
IMapStoreSave,
|
||||||
MapArea
|
MapArea
|
||||||
} from './types';
|
} from './types';
|
||||||
import { LayerState } from './layerState';
|
import { LayerState } from './layerState';
|
||||||
import { uniq } from 'lodash-es';
|
import { uniq } from 'lodash-es';
|
||||||
|
|
||||||
export class MapState implements IMapState {
|
export class MapStore implements IMapStore {
|
||||||
/** 楼层 id 到状态对象的映射 */
|
/** 楼层 id 到状态对象的映射 */
|
||||||
private readonly mapData: Map<string, LayerState> = new Map();
|
private readonly mapData: Map<string, LayerState> = new Map();
|
||||||
|
|
||||||
|
|||||||
@ -425,7 +425,7 @@ export interface IMapAreaInterval {
|
|||||||
|
|
||||||
export type MapArea = IMapAreaInterval[];
|
export type MapArea = IMapAreaInterval[];
|
||||||
|
|
||||||
export interface IMapState
|
export interface IMapStore
|
||||||
extends ISaveableContent<IMapStoreSave>, IDataCommonExtended {
|
extends ISaveableContent<IMapStoreSave>, IDataCommonExtended {
|
||||||
/** 所有楼层的 id 有序数组 */
|
/** 所有楼层的 id 有序数组 */
|
||||||
readonly maps: ReadonlyArray<string>;
|
readonly maps: ReadonlyArray<string>;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { IHeroFollower, IHeroState } from './hero';
|
import { IHeroFollower, IHeroState } from './hero';
|
||||||
import { IEnemyManager } from './enemy';
|
import { IEnemyManager } from './enemy';
|
||||||
import { IFlagSystem } from './flag';
|
import { IFlagSystem } from './flag';
|
||||||
import { IMapState } from './map';
|
import { IMapStore } from './map';
|
||||||
import {
|
import {
|
||||||
IDataCommon,
|
IDataCommon,
|
||||||
IEnemyAttr,
|
IEnemyAttr,
|
||||||
@ -16,7 +16,7 @@ export interface IStateSaveData {
|
|||||||
|
|
||||||
export interface IStateBase extends IDataCommon {
|
export interface IStateBase extends IDataCommon {
|
||||||
/** 地图状态 */
|
/** 地图状态 */
|
||||||
readonly maps: IMapState;
|
readonly maps: IMapStore;
|
||||||
/** 勇士状态 */
|
/** 勇士状态 */
|
||||||
readonly hero: IHeroState<IHeroAttr>;
|
readonly hero: IHeroState<IHeroAttr>;
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
import { IMapRawData, IMapStore } from './types';
|
|
||||||
|
|
||||||
export class MapStore implements IMapStore {
|
|
||||||
/** 地图存储映射 */
|
|
||||||
private readonly maps: Map<string, IMapRawData> = new Map();
|
|
||||||
|
|
||||||
getMap(floorId: string): IMapRawData | null {
|
|
||||||
return this.maps.get(floorId) ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
addMap(map: IMapRawData): void {
|
|
||||||
this.maps.set(map.floorId, map);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -68,7 +68,7 @@ export interface ITileLegacyConverter<TLegacy> {
|
|||||||
fromLegacy(num: number, legacy: TLegacy): ITileRawData;
|
fromLegacy(num: number, legacy: TLegacy): ITileRawData;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITileStore<TLegacy = unknown> {
|
export interface ITileStore<TLegacy> {
|
||||||
/**
|
/**
|
||||||
* 获取指定图块数字对应的完整原始定义
|
* 获取指定图块数字对应的完整原始定义
|
||||||
* @param num 图块数字
|
* @param num 图块数字
|
||||||
@ -250,32 +250,3 @@ export interface IItemStore<THero, TLegacy> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region map
|
|
||||||
|
|
||||||
export interface IMapRawData {
|
|
||||||
/** 楼层 id */
|
|
||||||
readonly floorId: string;
|
|
||||||
/** 地图宽度 */
|
|
||||||
readonly width: number;
|
|
||||||
/** 地图数组 */
|
|
||||||
readonly map: Record<number, number[]>;
|
|
||||||
/** 每个地图图层的字符串别名 */
|
|
||||||
readonly layerAlias: Record<number, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IMapStore {
|
|
||||||
/**
|
|
||||||
* 根据地图 id 获取指定地图的原始数据
|
|
||||||
* @param floorId 楼层 id
|
|
||||||
*/
|
|
||||||
getMap(floorId: string): IMapRawData | null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加地图的原始数据定义
|
|
||||||
* @param map 地图原始数据
|
|
||||||
*/
|
|
||||||
addMap(map: IMapRawData): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { ITileLocator } from '@motajs/common';
|
import { ITileLocator } from '@motajs/common';
|
||||||
import { IFaceManager, IRoleFaceBinder } from './common';
|
import { IFaceManager, IRoleFaceBinder } from './common';
|
||||||
import { IItemStore, IMapStore, ITileStore } from './store';
|
import { IItemStore, ITileStore } from './store';
|
||||||
import { ISaveSystem } from './save';
|
import { ISaveSystem } from './save';
|
||||||
|
|
||||||
export interface IEnemyAttr {
|
export interface IEnemyAttr {
|
||||||
@ -48,8 +48,6 @@ export interface IDataCommon {
|
|||||||
readonly tileStore: ITileStore<MapDataOf<keyof NumberToId>>;
|
readonly tileStore: ITileStore<MapDataOf<keyof NumberToId>>;
|
||||||
/** 道具定义存储 */
|
/** 道具定义存储 */
|
||||||
readonly itemStore: IItemStore<IHeroAttr, Item<AllIdsOf<'items'>>>;
|
readonly itemStore: IItemStore<IHeroAttr, Item<AllIdsOf<'items'>>>;
|
||||||
/** 地图定义存储 */
|
|
||||||
readonly mapStore: IMapStore;
|
|
||||||
/** 朝向绑定 */
|
/** 朝向绑定 */
|
||||||
readonly roleFace: IRoleFaceBinder;
|
readonly roleFace: IRoleFaceBinder;
|
||||||
/** 朝向管理 */
|
/** 朝向管理 */
|
||||||
|
|||||||
@ -17,8 +17,7 @@ import {
|
|||||||
ISaveSystem,
|
ISaveSystem,
|
||||||
SaveSystem,
|
SaveSystem,
|
||||||
IItemStore,
|
IItemStore,
|
||||||
ItemStore,
|
ItemStore
|
||||||
IMapStore
|
|
||||||
} from '@user/data-common';
|
} from '@user/data-common';
|
||||||
import {
|
import {
|
||||||
EnemyManager,
|
EnemyManager,
|
||||||
@ -32,8 +31,8 @@ import {
|
|||||||
MotaDataLoader,
|
MotaDataLoader,
|
||||||
loading,
|
loading,
|
||||||
IReadonlyEnemy,
|
IReadonlyEnemy,
|
||||||
IMapState,
|
IMapStore,
|
||||||
MapState
|
MapStore
|
||||||
} from '@user/data-base';
|
} from '@user/data-base';
|
||||||
import {
|
import {
|
||||||
DamageSystem,
|
DamageSystem,
|
||||||
@ -76,7 +75,6 @@ import { ILoadProgressTotal, LoadProgressTotal } from '@motajs/loader';
|
|||||||
import { isNil } from 'lodash-es';
|
import { isNil } from 'lodash-es';
|
||||||
import { logger } from '@motajs/common';
|
import { logger } from '@motajs/common';
|
||||||
import { DefaultHeroMoveTopImpl } from './hero';
|
import { DefaultHeroMoveTopImpl } from './hero';
|
||||||
import { MapStore } from '../../data-common/src/store/mapStore';
|
|
||||||
|
|
||||||
export class CoreState implements ICoreState {
|
export class CoreState implements ICoreState {
|
||||||
// Layer 0 公共层,最底层的接口,不会依赖任何其他内容,一般是工具性接口及不需要存档的数据
|
// Layer 0 公共层,最底层的接口,不会依赖任何其他内容,一般是工具性接口及不需要存档的数据
|
||||||
@ -85,10 +83,9 @@ export class CoreState implements ICoreState {
|
|||||||
readonly faceManager: IFaceManager;
|
readonly faceManager: IFaceManager;
|
||||||
readonly tileStore: ITileStore<LegacyTileData>;
|
readonly tileStore: ITileStore<LegacyTileData>;
|
||||||
readonly itemStore: IItemStore<IHeroAttr, LegacyItemData>;
|
readonly itemStore: IItemStore<IHeroAttr, LegacyItemData>;
|
||||||
readonly mapStore: IMapStore;
|
|
||||||
|
|
||||||
// Layer 1 数据层,所有可存档内容都在这,一般用于数据存储
|
// Layer 1 数据层,所有可存档内容都在这,一般用于数据存储
|
||||||
readonly maps: IMapState;
|
readonly maps: IMapStore;
|
||||||
readonly hero: IHeroState<IHeroAttr>;
|
readonly hero: IHeroState<IHeroAttr>;
|
||||||
readonly enemyManager: IEnemyManager<IEnemyAttr>;
|
readonly enemyManager: IEnemyManager<IEnemyAttr>;
|
||||||
readonly flags: IFlagSystem;
|
readonly flags: IFlagSystem;
|
||||||
@ -141,12 +138,9 @@ export class CoreState implements ICoreState {
|
|||||||
tileStore.attachLegacyConverter(new TileLegacyBridge());
|
tileStore.attachLegacyConverter(new TileLegacyBridge());
|
||||||
this.tileStore = tileStore;
|
this.tileStore = tileStore;
|
||||||
// 道具
|
// 道具
|
||||||
const itemStore = new ItemStore<IHeroAttr, LegacyItemData>();
|
const itemStore = new ItemStore<LegacyItemData>();
|
||||||
itemStore.attachLegacyConverter(new ItemLegacyBridge(this));
|
itemStore.attachLegacyConverter(new ItemLegacyBridge(this));
|
||||||
this.itemStore = itemStore;
|
this.itemStore = itemStore;
|
||||||
// 地图
|
|
||||||
const mapStore = new MapStore();
|
|
||||||
this.mapStore = mapStore;
|
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -156,7 +150,7 @@ export class CoreState implements ICoreState {
|
|||||||
this.flags = new FlagSystem();
|
this.flags = new FlagSystem();
|
||||||
|
|
||||||
// 地图
|
// 地图
|
||||||
this.maps = new MapState(tileStore, this);
|
this.maps = new MapStore(tileStore, this);
|
||||||
|
|
||||||
// 勇士
|
// 勇士
|
||||||
const heroAttribute = new HeroAttribute(HERO_DEFAULT_ATTRIBUTE);
|
const heroAttribute = new HeroAttribute(HERO_DEFAULT_ATTRIBUTE);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
IHeroMoveTopHandler,
|
IHeroMoveTopHandler,
|
||||||
IHeroMoveTopImpl,
|
IHeroMoveTopImpl,
|
||||||
IMapState
|
IMapStore
|
||||||
} from '@user/data-base';
|
} from '@user/data-base';
|
||||||
import { FaceDirection, PassBit } from '@user/data-common';
|
import { FaceDirection, PassBit } from '@user/data-common';
|
||||||
import {
|
import {
|
||||||
@ -13,7 +13,7 @@ import { isNil } from 'lodash-es';
|
|||||||
|
|
||||||
export class DefaultHeroMoveTopImpl implements IHeroMoveTopImpl {
|
export class DefaultHeroMoveTopImpl implements IHeroMoveTopImpl {
|
||||||
/** 地图存储对象 */
|
/** 地图存储对象 */
|
||||||
private readonly maps: IMapState;
|
private readonly maps: IMapStore;
|
||||||
/** 触发器收集器对象 */
|
/** 触发器收集器对象 */
|
||||||
private readonly collector: ITriggerCollector;
|
private readonly collector: ITriggerCollector;
|
||||||
|
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
// Type: packages-user/data-common/src/store/types IItemRawData
|
|
||||||
// ItemEffect: ./item.ts
|
|
||||||
{}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
// Type: packages-user/data-base/src/map/types.ts
|
|
||||||
{}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
// Type: packages-user/data-common/src/store/types ITileRawData
|
|
||||||
{}
|
|
||||||
Loading…
Reference in New Issue
Block a user