refactor: 存档系统迁移至 L0

This commit is contained in:
unanmed 2026-07-01 20:53:29 +08:00
parent 94a16b31ba
commit e72ad36e8d
8 changed files with 35 additions and 37 deletions

View File

@ -52,31 +52,3 @@ export interface IRoleFaceBinder {
*/
getMainFace(identifier: number): IFaceData | null;
}
//#region 功能接口
export const enum SaveCompression {
/** 不进行压缩,仅提取必要数据 */
NoCompression,
/** 进行小幅度压缩,以性能为主要考虑目标 */
LowCompression,
/** 进行大幅度压缩,以体积为主要考虑目标 */
HighCompression
}
export interface ISaveableContent<T> {
/**
* `structuedClone`
* @param compression
*/
saveState(compression: SaveCompression): T;
/**
*
* @param state
* @param compression
*/
loadState(state: T, compression: SaveCompression): void;
}
//#endregion

View File

@ -1,4 +1,5 @@
export * from './common';
export * from './save';
export * from './store';
export * from './types';

View File

@ -4,9 +4,10 @@ import {
IGlobalTrasaction,
ISaveRead,
ISaveSystem,
ISaveSystemConfig
ISaveSystemConfig,
ISaveableContent,
SaveCompression
} from './types';
import { ISaveableContent, SaveCompression } from '@user/data-common';
import { isNil } from 'lodash-es';
interface ISaveRecord {

View File

@ -1,6 +1,29 @@
import { ISaveableContent, SaveCompression } from '@user/data-common';
import { Dexie, Table } from 'dexie';
export const enum SaveCompression {
/** 不进行压缩,仅提取必要数据 */
NoCompression,
/** 进行小幅度压缩,以性能为主要考虑目标 */
LowCompression,
/** 进行大幅度压缩,以体积为主要考虑目标 */
HighCompression
}
export interface ISaveableContent<T> {
/**
* `structuedClone`
* @param compression
*/
saveState(compression: SaveCompression): T;
/**
*
* @param state
* @param compression
*/
loadState(state: T, compression: SaveCompression): void;
}
export interface IGlobalTrasaction {
/** 全局存储对应的表 */
readonly table: Table<unknown, string>;

View File

@ -1,6 +1,7 @@
import { ITileLocator } from '@motajs/common';
import { IFaceManager, IRoleFaceBinder } from './common';
import { ITileStore } from './store';
import { ISaveSystem } from './save';
export interface IEnemyAttr {
/** 怪物生命值 */
@ -49,6 +50,8 @@ export interface IDataCommon {
readonly roleFace: IRoleFaceBinder;
/** 朝向管理 */
readonly faceManager: IFaceManager;
/** 存档系统 */
readonly saveSystem: ISaveSystem;
}
export interface IDataCommonExtended {

View File

@ -13,7 +13,9 @@ import {
FaceGroup,
FaceDirection,
IHeroAttr,
IEnemyAttr
IEnemyAttr,
ISaveSystem,
SaveSystem
} from '@user/data-common';
import {
EnemyManager,
@ -65,7 +67,6 @@ import { LegacyTileData, TileLegacyBridge } from './legacy';
import { ILoadProgressTotal, LoadProgressTotal } from '@motajs/loader';
import { isNil } from 'lodash-es';
import { logger } from '@motajs/common';
import { ISaveSystem, SaveSystem } from './save';
import { DefaultHeroMoveTopImpl } from './hero';
export class CoreState implements ICoreState {
@ -73,6 +74,7 @@ export class CoreState implements ICoreState {
readonly roleFace: IRoleFaceBinder;
readonly faceManager: IFaceManager;
readonly tileStore: ITileStore<LegacyTileData>;
readonly saveSystem: ISaveSystem;
// Layer 1 数据层,所有可存档内容都在这,一般用于数据存储
readonly maps: IMapStore;
@ -88,7 +90,6 @@ export class CoreState implements ICoreState {
// Layer 3 用户层,也就是最顶层的内容,一般仅用于初始化以及仅供渲染端调用的顶层模块
readonly loadProgress: ILoadProgressTotal;
readonly dataLoader: IMotaDataLoader;
readonly saveSystem: ISaveSystem;
/** 可存档对象映射 */
private readonly saveables: Map<string, ISaveableContent<any>> = new Map();

View File

@ -1,6 +1,5 @@
import { IMotaDataLoader, IStateBase } from '@user/data-base';
import { ILoadProgressTotal } from '@motajs/loader';
import { ISaveSystem } from './save';
import { IStateSystem } from '@user/data-system';
import { ISaveableContent } from '@user/data-common';
@ -18,8 +17,6 @@ export interface ICoreState extends IStateSystem {
readonly loadProgress: ILoadProgressTotal;
/** 数据端加载对象 */
readonly dataLoader: IMotaDataLoader;
/** 存档系统 */
readonly saveSystem: ISaveSystem;
/**
*