提交示例代码
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class ContainerConfigData : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<ContainerConfig> List { get; set; } = new List<ContainerConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, ContainerConfig> _configs = new ConcurrentDictionary<uint, ContainerConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, ContainerConfig> _configs = new Dictionary<uint, ContainerConfig>();
|
||||
#endif
|
||||
private static ContainerConfigData _instance = null;
|
||||
|
||||
public static ContainerConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<ContainerConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public ContainerConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"ContainerConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out ContainerConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class ContainerConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public string Name { get; set; } // 名字
|
||||
[ProtoMember(3)]
|
||||
public int Type { get; set; } // 容器类型
|
||||
[ProtoMember(4)]
|
||||
public int CellCountMax { get; set; } // 容器最大的格子数
|
||||
[ProtoMember(5)]
|
||||
public int CellCount { get; set; } // 初始解锁格子
|
||||
[ProtoMember(6)]
|
||||
public bool CanSort { get; set; } // 是否可以整理
|
||||
[ProtoMember(7)]
|
||||
public int SortCD { get; set; } // 是否可以整理
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class EquipAffixConfigData : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<EquipAffixConfig> List { get; set; } = new List<EquipAffixConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, EquipAffixConfig> _configs = new ConcurrentDictionary<uint, EquipAffixConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, EquipAffixConfig> _configs = new Dictionary<uint, EquipAffixConfig>();
|
||||
#endif
|
||||
private static EquipAffixConfigData _instance = null;
|
||||
|
||||
public static EquipAffixConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<EquipAffixConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public EquipAffixConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"EquipAffixConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out EquipAffixConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class EquipAffixConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public uint BuffConfigId { get; set; } // 触发的Buff
|
||||
[ProtoMember(3)]
|
||||
public string Descride { get; set; } // 介绍
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class EquipEntryConfigData : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<EquipEntryConfig> List { get; set; } = new List<EquipEntryConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, EquipEntryConfig> _configs = new ConcurrentDictionary<uint, EquipEntryConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, EquipEntryConfig> _configs = new Dictionary<uint, EquipEntryConfig>();
|
||||
#endif
|
||||
private static EquipEntryConfigData _instance = null;
|
||||
|
||||
public static EquipEntryConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<EquipEntryConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public EquipEntryConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"EquipEntryConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out EquipEntryConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class EquipEntryConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public int Min { get; set; } // 词条最小数
|
||||
[ProtoMember(3)]
|
||||
public int Max { get; set; } // 词条最大数
|
||||
[ProtoMember(4)]
|
||||
public int AffixMin { get; set; } // 词缀最小数
|
||||
[ProtoMember(5)]
|
||||
public int AffixMax { get; set; } // 词缀最大数
|
||||
[ProtoMember(6)]
|
||||
public uint[] Affix { get; set; } = Array.Empty<uint>(); // 词缀列表
|
||||
[ProtoMember(7)]
|
||||
public int[] Attrs { get; set; } = Array.Empty<int>(); // 属性数组
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class EquipValueConfigData : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<EquipValueConfig> List { get; set; } = new List<EquipValueConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, EquipValueConfig> _configs = new ConcurrentDictionary<uint, EquipValueConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, EquipValueConfig> _configs = new Dictionary<uint, EquipValueConfig>();
|
||||
#endif
|
||||
private static EquipValueConfigData _instance = null;
|
||||
|
||||
public static EquipValueConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<EquipValueConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public EquipValueConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"EquipValueConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out EquipValueConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class EquipValueConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public uint ItemConfigId { get; set; } // ItemConfigId
|
||||
[ProtoMember(3)]
|
||||
public uint EquipEntryConfigId { get; set; } // EquipEntryConfigId
|
||||
[ProtoMember(4)]
|
||||
public int Quality { get; set; } // 品质
|
||||
[ProtoMember(5)]
|
||||
public IntDictionaryConfig MainAttrs { get; set; } // 法术强度
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class ErrorCodeData : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<ErrorCode> List { get; set; } = new List<ErrorCode>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, ErrorCode> _configs = new ConcurrentDictionary<uint, ErrorCode>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, ErrorCode> _configs = new Dictionary<uint, ErrorCode>();
|
||||
#endif
|
||||
private static ErrorCodeData _instance = null;
|
||||
|
||||
public static ErrorCodeData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<ErrorCodeData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public ErrorCode Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"ErrorCode not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out ErrorCode config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class ErrorCode : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public string Name { get; set; } // 名称
|
||||
[ProtoMember(3)]
|
||||
public string Text { get; set; } // 文本内容
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class ItemConfigData : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<ItemConfig> List { get; set; } = new List<ItemConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, ItemConfig> _configs = new ConcurrentDictionary<uint, ItemConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, ItemConfig> _configs = new Dictionary<uint, ItemConfig>();
|
||||
#endif
|
||||
private static ItemConfigData _instance = null;
|
||||
|
||||
public static ItemConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<ItemConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public ItemConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"ItemConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out ItemConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class ItemConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public string Name { get; set; } // 名称
|
||||
[ProtoMember(3)]
|
||||
public string Descride { get; set; } // 描述
|
||||
[ProtoMember(4)]
|
||||
public int Weight { get; set; } // 排序权重
|
||||
[ProtoMember(5)]
|
||||
public string Model2D { get; set; } // 对应模型
|
||||
[ProtoMember(6)]
|
||||
public bool Superposed { get; set; } // 是否可以叠加
|
||||
[ProtoMember(7)]
|
||||
public uint SuperposedMax { get; set; } // 叠加
|
||||
[ProtoMember(8)]
|
||||
public uint Type { get; set; } // 类型
|
||||
[ProtoMember(9)]
|
||||
public bool IsDeal { get; set; } // 是否可以交易
|
||||
[ProtoMember(10)]
|
||||
public bool IsSell { get; set; } // 是否可以出售
|
||||
[ProtoMember(11)]
|
||||
public int[] Sell { get; set; } = Array.Empty<int>(); // 出售价格
|
||||
[ProtoMember(12)]
|
||||
public int Effect { get; set; } // 使用效果
|
||||
[ProtoMember(13)]
|
||||
public string[] Params { get; set; } = Array.Empty<string>(); // 效果参数
|
||||
[ProtoMember(14)]
|
||||
public int Durable { get; set; } // 耐久度
|
||||
[ProtoMember(15)]
|
||||
public int Quality { get; set; } // 品质
|
||||
[ProtoMember(16)]
|
||||
public int Position { get; set; } // 装备位置
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class LevelConfigData : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<LevelConfig> List { get; set; } = new List<LevelConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, LevelConfig> _configs = new ConcurrentDictionary<uint, LevelConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, LevelConfig> _configs = new Dictionary<uint, LevelConfig>();
|
||||
#endif
|
||||
private static LevelConfigData _instance = null;
|
||||
|
||||
public static LevelConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<LevelConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public LevelConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"LevelConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out LevelConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class LevelConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public string Name { get; set; } // 名称
|
||||
[ProtoMember(3)]
|
||||
public string Model { get; set; } // 数据库类型
|
||||
[ProtoMember(4)]
|
||||
public uint Group { get; set; } // 分组
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class UnitConfigData : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<UnitConfig> List { get; set; } = new List<UnitConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, UnitConfig> _configs = new ConcurrentDictionary<uint, UnitConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, UnitConfig> _configs = new Dictionary<uint, UnitConfig>();
|
||||
#endif
|
||||
private static UnitConfigData _instance = null;
|
||||
|
||||
public static UnitConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<UnitConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public UnitConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"UnitConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out UnitConfig config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class UnitConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public string Name { get; set; } // 名称
|
||||
[ProtoMember(3)]
|
||||
public string Model { get; set; } // 数据库类型
|
||||
[ProtoMember(4)]
|
||||
public uint Type { get; set; } // 类型
|
||||
[ProtoMember(5)]
|
||||
public uint MonsterPRange { get; set; } // 怪物追击范围
|
||||
[ProtoMember(6)]
|
||||
public uint TalkConfigId { get; set; } // NPC对话列表Id
|
||||
[ProtoMember(7)]
|
||||
public uint Camp { get; set; } // 玩家阵营
|
||||
[ProtoMember(8)]
|
||||
public uint[] MountContainer { get; set; } = Array.Empty<uint>(); // 挂载的容器列表
|
||||
[ProtoMember(9)]
|
||||
public uint[] Items { get; set; } = Array.Empty<uint>(); // 容器物品初始列表
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
#pragma warning disable CS8603 // Possible null reference return.
|
||||
namespace Fantasy;
|
||||
|
||||
public sealed partial class ContainerConfigData
|
||||
{
|
||||
private readonly Dictionary<int, ContainerConfig> _configsByType = new Dictionary<int, ContainerConfig>();
|
||||
|
||||
public override void EndInit()
|
||||
{
|
||||
foreach (var containerConfig in List)
|
||||
{
|
||||
_configsByType.Add(containerConfig.Type, containerConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public ContainerConfig GetConfig(ContainerType containerType)
|
||||
{
|
||||
if (!_configsByType.TryGetValue((int)containerType, out var config))
|
||||
{
|
||||
Log.Error($"containerType {containerType} not found!");
|
||||
return null;
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public bool TryGetConfig(ContainerType containerType, out ContainerConfig containerConfig)
|
||||
{
|
||||
if (!_configsByType.TryGetValue((int)containerType, out containerConfig))
|
||||
{
|
||||
Log.Error($"containerType {containerType} not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
namespace Fantasy;
|
||||
|
||||
public partial class EquipValueConfigData
|
||||
{
|
||||
private readonly Dictionary<ulong, EquipValueConfig> _equipValueDic = new Dictionary<ulong, EquipValueConfig>();
|
||||
public override void EndInit()
|
||||
{
|
||||
foreach (var equipValueConfig in List)
|
||||
{
|
||||
var equipValueKey = GetEquipValueKey(equipValueConfig.ItemConfigId, equipValueConfig.Quality);
|
||||
_equipValueDic.Add(equipValueKey, equipValueConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetValue(uint itemConfigId, int quality, out EquipValueConfig value)
|
||||
{
|
||||
var equipValueKey = GetEquipValueKey(itemConfigId, quality);
|
||||
|
||||
if (!_equipValueDic.TryGetValue(equipValueKey, out value))
|
||||
{
|
||||
Log.Error($"itemConfigId: {itemConfigId} and quality: {quality} not found in EquipValueConfig!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private ulong GetEquipValueKey(uint itemConfigId, int quality)
|
||||
{
|
||||
return ((ulong)itemConfigId << 32) | (uint)quality;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user