Files
Max-Cocos-Demo/assets/configs/generated/core/PetConfigData.ts
2025-10-28 21:55:41 +08:00

166 lines
1.9 KiB
TypeScript

import { Color } from 'cc';
import { ConfigParseUtils } from './ConfigParseUtils';
/**
* PetConfig数据结构
*/
export class PetConfigData {
private _id: number;
private _key: string;
private _bundle: string;
private _path: string;
private _name: string;
private _color: Color;
private _desc: string;
/** id */
public get id(): number {
return this._id;
}
/** key */
public get key(): string {
return this._key;
}
/** bundle */
public get bundle(): string {
return this._bundle;
}
/** 资源路径 */
public get path(): string {
return this._path;
}
/** 宠物名称 */
public get name(): string {
return this._name;
}
/** 颜色 */
public get color(): Color {
return ConfigParseUtils.createReadonlyProxy(ConfigParseUtils.deepFreeze(this._color), '颜色');
}
/** 描述 */
public get desc(): string {
return this._desc;
}
public constructor(
id: number,
key: string,
bundle: string,
path: string,
name: string,
color: Color,
desc: string
) {
this._id = id;
this._key = key;
this._bundle = bundle;
this._path = path;
this._name = name;
this._color = color;
this._desc = desc;
}
}
/**
* 解析配置数据
*/
export function parsePetConfigData(data: any): PetConfigData {
return new PetConfigData(
ConfigParseUtils.parseInt(data.id),
ConfigParseUtils.parseString(data.key),
ConfigParseUtils.parseString(data.bundle),
ConfigParseUtils.parseString(data.path),
ConfigParseUtils.parseString(data.name),
ConfigParseUtils.parseColor(data.color),
ConfigParseUtils.parseString(data.desc)
);
}