174 lines
4.4 KiB
C#
174 lines
4.4 KiB
C#
// 此文件由 ThriftIntegratedPipeline 自动生成,请勿手动修改
|
||
// 配置类: LevelData
|
||
// 数据类: LevelDataItem
|
||
|
||
using UnityEngine;
|
||
using Byway.Config;
|
||
using Byway.Thrift.Data;
|
||
using UnityGameFramework.Runtime;
|
||
|
||
namespace CrazyMaple
|
||
{
|
||
/// <summary>
|
||
/// LevelData 数据行
|
||
/// </summary>
|
||
public class DRLevelData : DataRowBase
|
||
{
|
||
private LevelDataItem _configData;
|
||
|
||
/// <summary>
|
||
/// 唯一标识
|
||
/// </summary>
|
||
public override int Id
|
||
{
|
||
get
|
||
{
|
||
return _configData?.Id ?? 0;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Lv
|
||
/// </summary>
|
||
public int Lv
|
||
{
|
||
get
|
||
{
|
||
return _configData?.Lv ?? 0;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// StoryExp
|
||
/// </summary>
|
||
public int StoryExp
|
||
{
|
||
get
|
||
{
|
||
return _configData?.StoryExp ?? 0;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// PetExp
|
||
/// </summary>
|
||
public int PetExp
|
||
{
|
||
get
|
||
{
|
||
return _configData?.PetExp ?? 0;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// StoryReward
|
||
/// </summary>
|
||
public string StoryReward
|
||
{
|
||
get
|
||
{
|
||
return _configData?.StoryReward ?? "";
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// PetReward
|
||
/// </summary>
|
||
public string PetReward
|
||
{
|
||
get
|
||
{
|
||
return _configData?.PetReward ?? "";
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// RetireEmit
|
||
/// </summary>
|
||
public string RetireEmit
|
||
{
|
||
get
|
||
{
|
||
return _configData?.RetireEmit ?? "";
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// PetShow
|
||
/// </summary>
|
||
public string PetShow
|
||
{
|
||
get
|
||
{
|
||
return _configData?.PetShow ?? "";
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 从配置加载数据(优先使用传入的配置实例)
|
||
/// </summary>
|
||
public void LoadFromConfig(int id, LevelData config = null)
|
||
{
|
||
if (config == null)
|
||
{
|
||
config = ConfigManager.Instance.GetConfig<LevelData>();
|
||
}
|
||
|
||
if (config?.Leveldatas != null)
|
||
{
|
||
config.Leveldatas.TryGetValue(id, out _configData);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 直接设置配置数据(性能优化:跳过字典查询)
|
||
/// </summary>
|
||
public void SetConfigData(LevelDataItem configData)
|
||
{
|
||
_configData = configData;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 解析数据行(优化:使用 userData 传入的配置实例,避免重复调用 GetConfig)
|
||
/// </summary>
|
||
public override bool ParseDataRow(string dataRowString, object userData)
|
||
{
|
||
int id = 0;
|
||
if (!int.TryParse(dataRowString, out id))
|
||
{
|
||
return false;
|
||
}
|
||
|
||
// 性能优化:尝试从 userData 获取配置字典,直接获取 Item
|
||
if (userData is System.Collections.Generic.Dictionary<string, object> userDataDict)
|
||
{
|
||
// 优先尝试从缓存的字典直接获取 Item(最快)
|
||
if (userDataDict.TryGetValue("ConfigDict", out object dictObj))
|
||
{
|
||
var dict = dictObj as System.Collections.Generic.Dictionary<int, LevelDataItem>;
|
||
if (dict != null && dict.TryGetValue(id, out var item))
|
||
{
|
||
_configData = item;
|
||
return true;
|
||
}
|
||
}
|
||
|
||
// 备选方案:从配置实例获取
|
||
if (userDataDict.TryGetValue("ConfigInstance", out object configObj))
|
||
{
|
||
var config = configObj as LevelData;
|
||
if (config != null)
|
||
{
|
||
LoadFromConfig(id, config);
|
||
return _configData != null;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 兜底方案:直接查询(最慢)
|
||
LoadFromConfig(id);
|
||
return _configData != null;
|
||
}
|
||
}
|
||
}
|