修改ConfigManager,定义配置数据继承体系
This commit is contained in:
@@ -46,6 +46,8 @@ export class BaseData {
|
||||
if (this._isDestroyed) return;
|
||||
this.clear();
|
||||
this._isDestroyed = true;
|
||||
this._isInitialized = null;
|
||||
this._dataId = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { VideoEmotion, purchase } from "../../schema/schema";
|
||||
import { Dialog } from "./DialogData";
|
||||
import ConfigManager from "../manager/ConfigManager";
|
||||
import { ConfigManager } from "../manager/ConfigManager";
|
||||
|
||||
/**
|
||||
* 单个角色的聊天数据结构
|
||||
|
||||
@@ -51,6 +51,13 @@ export class DataManager {
|
||||
*/
|
||||
public init(): void {
|
||||
console.log("[DataManager] 数据管理器初始化");
|
||||
this.registerAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册 数据ID → 构造器
|
||||
*/
|
||||
private registerAll(): void {
|
||||
this.register(DataId.Login, LoginData);
|
||||
this.register(DataId.Player, PlayerData);
|
||||
this.register(DataId.Account, AccountData);
|
||||
@@ -65,7 +72,7 @@ export class DataManager {
|
||||
/**
|
||||
* 注册一个数据ID及其对应的构造器
|
||||
*/
|
||||
public register<T extends BaseData>(dataId: string, ctor: DataCtor<T>): void {
|
||||
private register<T extends BaseData>(dataId: string, ctor: DataCtor<T>): void {
|
||||
if (this._config.has(dataId)) {
|
||||
console.warn(`[DataManager] 重复注册数据ID: ${dataId},将覆盖旧构造器`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user