表格重构
This commit is contained in:
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class BaitConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class BaitConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<BaitConfig> List { get; set; } = new List<BaitConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, BaitConfig> _configs = new ConcurrentDictionary<uint, BaitConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, BaitConfig> _configs = new Dictionary<uint, BaitConfig>();
|
||||
#endif
|
||||
private static BaitConfigData _instance = null;
|
||||
|
||||
public static BaitConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<BaitConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public BaitConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"BaitConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out BaitConfig 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 BaitConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -106,5 +28,66 @@ namespace NBF
|
||||
public uint[] Arr { get; set; } = Array.Empty<uint>(); // 重量(克)
|
||||
[ProtoMember(7)]
|
||||
public string[] ArrStr { get; set; } = Array.Empty<string>(); // 重量(克)
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<BaitConfig> Context => ConfigTableHelper.Table<BaitConfig>();
|
||||
|
||||
public static BaitConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static BaitConfig Get(Predicate<BaitConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static BaitConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static BaitConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static BaitConfig Fist(Predicate<BaitConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static BaitConfig Last(Predicate<BaitConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<BaitConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<BaitConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<BaitConfig> GetList(Predicate<BaitConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<BaitConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
85
Assets/Scripts/Generate/Config/BasicConfig.cs
Normal file
85
Assets/Scripts/Generate/Config/BasicConfig.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class BasicConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public string Name { get; set; } // 参数名
|
||||
[ProtoMember(3)]
|
||||
public string[] Val { get; set; } = Array.Empty<string>(); // 参数值
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<BasicConfig> Context => ConfigTableHelper.Table<BasicConfig>();
|
||||
|
||||
public static BasicConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static BasicConfig Get(Predicate<BasicConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static BasicConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static BasicConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static BasicConfig Fist(Predicate<BasicConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static BasicConfig Last(Predicate<BasicConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<BasicConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<BasicConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<BasicConfig> GetList(Predicate<BasicConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<BasicConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Generate/Config/BasicConfig.cs.meta
Normal file
2
Assets/Scripts/Generate/Config/BasicConfig.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c900c2cd8da41740a01b749b9c8d844
|
||||
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class BobberConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class BobberConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<BobberConfig> List { get; set; } = new List<BobberConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, BobberConfig> _configs = new ConcurrentDictionary<uint, BobberConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, BobberConfig> _configs = new Dictionary<uint, BobberConfig>();
|
||||
#endif
|
||||
private static BobberConfigData _instance = null;
|
||||
|
||||
public static BobberConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<BobberConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public BobberConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"BobberConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out BobberConfig 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 BobberConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -104,5 +26,66 @@ namespace NBF
|
||||
public uint Displacement { get; set; } // 位移
|
||||
[ProtoMember(6)]
|
||||
public uint NightLight { get; set; } // 是否夜光
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<BobberConfig> Context => ConfigTableHelper.Table<BobberConfig>();
|
||||
|
||||
public static BobberConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static BobberConfig Get(Predicate<BobberConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static BobberConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static BobberConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static BobberConfig Fist(Predicate<BobberConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static BobberConfig Last(Predicate<BobberConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<BobberConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<BobberConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<BobberConfig> GetList(Predicate<BobberConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<BobberConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class FeederConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class FeederConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<FeederConfig> List { get; set; } = new List<FeederConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, FeederConfig> _configs = new ConcurrentDictionary<uint, FeederConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, FeederConfig> _configs = new Dictionary<uint, FeederConfig>();
|
||||
#endif
|
||||
private static FeederConfigData _instance = null;
|
||||
|
||||
public static FeederConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<FeederConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public FeederConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"FeederConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out FeederConfig 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 FeederConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -102,5 +24,66 @@ namespace NBF
|
||||
public uint Capacity { get; set; } // 能力
|
||||
[ProtoMember(5)]
|
||||
public uint Weight { get; set; } // 重量(克)
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<FeederConfig> Context => ConfigTableHelper.Table<FeederConfig>();
|
||||
|
||||
public static FeederConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static FeederConfig Get(Predicate<FeederConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static FeederConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static FeederConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static FeederConfig Fist(Predicate<FeederConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static FeederConfig Last(Predicate<FeederConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<FeederConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<FeederConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<FeederConfig> GetList(Predicate<FeederConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<FeederConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class FishConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class FishConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<FishConfig> List { get; set; } = new List<FishConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, FishConfig> _configs = new ConcurrentDictionary<uint, FishConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, FishConfig> _configs = new Dictionary<uint, FishConfig>();
|
||||
#endif
|
||||
private static FishConfigData _instance = null;
|
||||
|
||||
public static FishConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<FishConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public FishConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"FishConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out FishConfig 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 FishConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -106,5 +28,66 @@ namespace NBF
|
||||
public uint MaxWeight { get; set; } // 最大重量(克)
|
||||
[ProtoMember(7)]
|
||||
public uint Accept { get; set; } // 接受饵
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<FishConfig> Context => ConfigTableHelper.Table<FishConfig>();
|
||||
|
||||
public static FishConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static FishConfig Get(Predicate<FishConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static FishConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static FishConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static FishConfig Fist(Predicate<FishConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static FishConfig Last(Predicate<FishConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<FishConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<FishConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<FishConfig> GetList(Predicate<FishConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<FishConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class HookConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class HookConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<HookConfig> List { get; set; } = new List<HookConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, HookConfig> _configs = new ConcurrentDictionary<uint, HookConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, HookConfig> _configs = new Dictionary<uint, HookConfig>();
|
||||
#endif
|
||||
private static HookConfigData _instance = null;
|
||||
|
||||
public static HookConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<HookConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public HookConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"HookConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out HookConfig 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 HookConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -104,5 +26,66 @@ namespace NBF
|
||||
public uint Length { get; set; } // 长度(毫米)
|
||||
[ProtoMember(6)]
|
||||
public uint Weight { get; set; } // 重量(克)
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<HookConfig> Context => ConfigTableHelper.Table<HookConfig>();
|
||||
|
||||
public static HookConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static HookConfig Get(Predicate<HookConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static HookConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static HookConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static HookConfig Fist(Predicate<HookConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static HookConfig Last(Predicate<HookConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<HookConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<HookConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<HookConfig> GetList(Predicate<HookConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<HookConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
85
Assets/Scripts/Generate/Config/InitConfig.cs
Normal file
85
Assets/Scripts/Generate/Config/InitConfig.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class InitConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public uint ItemId { get; set; } // 物品Id
|
||||
[ProtoMember(3)]
|
||||
public int Amount { get; set; } // 数量
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<InitConfig> Context => ConfigTableHelper.Table<InitConfig>();
|
||||
|
||||
public static InitConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static InitConfig Get(Predicate<InitConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static InitConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static InitConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static InitConfig Fist(Predicate<InitConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static InitConfig Last(Predicate<InitConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<InitConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<InitConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<InitConfig> GetList(Predicate<InitConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<InitConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Generate/Config/InitConfig.cs.meta
Normal file
2
Assets/Scripts/Generate/Config/InitConfig.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b10beb37dfb5064593be4f13c7a4d29
|
||||
89
Assets/Scripts/Generate/Config/ItemConfig.cs
Normal file
89
Assets/Scripts/Generate/Config/ItemConfig.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class ItemConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public string Model { get; set; } // 模型
|
||||
[ProtoMember(3)]
|
||||
public uint Type { get; set; } // 类型
|
||||
[ProtoMember(4)]
|
||||
public uint Max { get; set; } // 最大堆叠数量
|
||||
[ProtoMember(5)]
|
||||
public uint AutoUse { get; set; } // 获得自动使用
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<ItemConfig> Context => ConfigTableHelper.Table<ItemConfig>();
|
||||
|
||||
public static ItemConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static ItemConfig Get(Predicate<ItemConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static ItemConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static ItemConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static ItemConfig Fist(Predicate<ItemConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static ItemConfig Last(Predicate<ItemConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<ItemConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<ItemConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<ItemConfig> GetList(Predicate<ItemConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<ItemConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Generate/Config/ItemConfig.cs.meta
Normal file
2
Assets/Scripts/Generate/Config/ItemConfig.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab3487f65cb0c3b458c2ac0a75932642
|
||||
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class LineConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class LineConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<LineConfig> List { get; set; } = new List<LineConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, LineConfig> _configs = new ConcurrentDictionary<uint, LineConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, LineConfig> _configs = new Dictionary<uint, LineConfig>();
|
||||
#endif
|
||||
private static LineConfigData _instance = null;
|
||||
|
||||
public static LineConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<LineConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public LineConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"LineConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out LineConfig 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 LineConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -104,5 +26,66 @@ namespace NBF
|
||||
public uint Strength { get; set; } // 强度
|
||||
[ProtoMember(6)]
|
||||
public uint Size { get; set; } // 尺寸
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<LineConfig> Context => ConfigTableHelper.Table<LineConfig>();
|
||||
|
||||
public static LineConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static LineConfig Get(Predicate<LineConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static LineConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static LineConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static LineConfig Fist(Predicate<LineConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static LineConfig Last(Predicate<LineConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<LineConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<LineConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<LineConfig> GetList(Predicate<LineConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<LineConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class LureConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class LureConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<LureConfig> List { get; set; } = new List<LureConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, LureConfig> _configs = new ConcurrentDictionary<uint, LureConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, LureConfig> _configs = new Dictionary<uint, LureConfig>();
|
||||
#endif
|
||||
private static LureConfigData _instance = null;
|
||||
|
||||
public static LureConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<LureConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public LureConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"LureConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out LureConfig 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 LureConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -104,5 +26,66 @@ namespace NBF
|
||||
public uint Length { get; set; } // 长度(毫米)
|
||||
[ProtoMember(6)]
|
||||
public uint Weight { get; set; } // 重量(克)
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<LureConfig> Context => ConfigTableHelper.Table<LureConfig>();
|
||||
|
||||
public static LureConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static LureConfig Get(Predicate<LureConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static LureConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static LureConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static LureConfig Fist(Predicate<LureConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static LureConfig Last(Predicate<LureConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<LureConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<LureConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<LureConfig> GetList(Predicate<LureConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<LureConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class ReelConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class ReelConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<ReelConfig> List { get; set; } = new List<ReelConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, ReelConfig> _configs = new ConcurrentDictionary<uint, ReelConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, ReelConfig> _configs = new Dictionary<uint, ReelConfig>();
|
||||
#endif
|
||||
private static ReelConfigData _instance = null;
|
||||
|
||||
public static ReelConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<ReelConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public ReelConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"ReelConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out ReelConfig 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 ReelConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -104,5 +26,66 @@ namespace NBF
|
||||
public uint Size { get; set; } // 尺寸
|
||||
[ProtoMember(6)]
|
||||
public uint Strength { get; set; } // 强度
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<ReelConfig> Context => ConfigTableHelper.Table<ReelConfig>();
|
||||
|
||||
public static ReelConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static ReelConfig Get(Predicate<ReelConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static ReelConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static ReelConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static ReelConfig Fist(Predicate<ReelConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static ReelConfig Last(Predicate<ReelConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<ReelConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<ReelConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<ReelConfig> GetList(Predicate<ReelConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<ReelConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,96 +5,79 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class RingConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class RingConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<RingConfig> List { get; set; } = new List<RingConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, RingConfig> _configs = new ConcurrentDictionary<uint, RingConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, RingConfig> _configs = new Dictionary<uint, RingConfig>();
|
||||
#endif
|
||||
private static RingConfigData _instance = null;
|
||||
|
||||
public static RingConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<RingConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public RingConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"RingConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out RingConfig 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 RingConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public string Model { get; set; } // 模型
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<RingConfig> Context => ConfigTableHelper.Table<RingConfig>();
|
||||
|
||||
public static RingConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static RingConfig Get(Predicate<RingConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static RingConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static RingConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static RingConfig Fist(Predicate<RingConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static RingConfig Last(Predicate<RingConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<RingConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<RingConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<RingConfig> GetList(Predicate<RingConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<RingConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class RodConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class RodConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<RodConfig> List { get; set; } = new List<RodConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, RodConfig> _configs = new ConcurrentDictionary<uint, RodConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, RodConfig> _configs = new Dictionary<uint, RodConfig>();
|
||||
#endif
|
||||
private static RodConfigData _instance = null;
|
||||
|
||||
public static RodConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<RodConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public RodConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"RodConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out RodConfig 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 RodConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -110,5 +32,66 @@ namespace NBF
|
||||
public uint MaxRange { get; set; } // 最大范围
|
||||
[ProtoMember(9)]
|
||||
public uint ConstructionType { get; set; } // 结构类型
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<RodConfig> Context => ConfigTableHelper.Table<RodConfig>();
|
||||
|
||||
public static RodConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static RodConfig Get(Predicate<RodConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static RodConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static RodConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static RodConfig Fist(Predicate<RodConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static RodConfig Last(Predicate<RodConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<RodConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<RodConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<RodConfig> GetList(Predicate<RodConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<RodConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,98 +5,81 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class Unit2ConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class Unit2Config : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<Unit2Config> List { get; set; } = new List<Unit2Config>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, Unit2Config> _configs = new ConcurrentDictionary<uint, Unit2Config>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, Unit2Config> _configs = new Dictionary<uint, Unit2Config>();
|
||||
#endif
|
||||
private static Unit2ConfigData _instance = null;
|
||||
|
||||
public static Unit2ConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<Unit2ConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public Unit2Config Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"Unit2Config not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out Unit2Config 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 Unit2Config : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
public string Name { get; set; } // 名称
|
||||
[ProtoMember(3)]
|
||||
public string Model { get; set; } // 数据库类型
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<Unit2Config> Context => ConfigTableHelper.Table<Unit2Config>();
|
||||
|
||||
public static Unit2Config Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static Unit2Config Get(Predicate<Unit2Config> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static Unit2Config Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static Unit2Config Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static Unit2Config Fist(Predicate<Unit2Config> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static Unit2Config Last(Predicate<Unit2Config> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<Unit2Config, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<Unit2Config> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<Unit2Config> GetList(Predicate<Unit2Config> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<Unit2Config>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,98 +5,81 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class UnitConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class UnitConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[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; } // 数据库类型
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<UnitConfig> Context => ConfigTableHelper.Table<UnitConfig>();
|
||||
|
||||
public static UnitConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static UnitConfig Get(Predicate<UnitConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static UnitConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static UnitConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static UnitConfig Fist(Predicate<UnitConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static UnitConfig Last(Predicate<UnitConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<UnitConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<UnitConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<UnitConfig> GetList(Predicate<UnitConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<UnitConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,93 +5,15 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
#if FANTASY_NET
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
#else
|
||||
using NBC;
|
||||
using NBC.Serialize;
|
||||
#endif
|
||||
// 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 NBF
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class WeightConfigData : ASerialize, IConfigTable, IProto
|
||||
public sealed partial class WeightConfig : ASerialize, IProto, IConfigTable
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<WeightConfig> List { get; set; } = new List<WeightConfig>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, WeightConfig> _configs = new ConcurrentDictionary<uint, WeightConfig>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, WeightConfig> _configs = new Dictionary<uint, WeightConfig>();
|
||||
#endif
|
||||
private static WeightConfigData _instance = null;
|
||||
|
||||
public static WeightConfigData Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<WeightConfigData>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public WeightConfig Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"WeightConfig not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out WeightConfig 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 WeightConfig : ASerialize, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public uint Id { get; set; } // Id
|
||||
[ProtoMember(2)]
|
||||
@@ -100,5 +22,66 @@ namespace NBF
|
||||
public uint Type { get; set; } // 类型
|
||||
[ProtoMember(4)]
|
||||
public uint Weight { get; set; } // 重量(克)
|
||||
}
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public uint Key => Id;
|
||||
|
||||
#region Static
|
||||
|
||||
private static ConfigContext<WeightConfig> Context => ConfigTableHelper.Table<WeightConfig>();
|
||||
|
||||
public static WeightConfig Get(uint key)
|
||||
{
|
||||
return Context.Get(key);
|
||||
}
|
||||
|
||||
public static WeightConfig Get(Predicate<WeightConfig> match)
|
||||
{
|
||||
return Context.Get(match);
|
||||
}
|
||||
|
||||
public static WeightConfig Fist()
|
||||
{
|
||||
return Context.Fist();
|
||||
}
|
||||
|
||||
public static WeightConfig Last()
|
||||
{
|
||||
return Context.Last();
|
||||
}
|
||||
|
||||
public static WeightConfig Fist(Predicate<WeightConfig> match)
|
||||
{
|
||||
return Context.Fist(match);
|
||||
}
|
||||
|
||||
public static WeightConfig Last(Predicate<WeightConfig> match)
|
||||
{
|
||||
return Context.Last(match);
|
||||
}
|
||||
|
||||
public static int Count()
|
||||
{
|
||||
return Context.Count();
|
||||
}
|
||||
|
||||
public static int Count(Func<WeightConfig, bool> predicate)
|
||||
{
|
||||
return Context.Count(predicate);
|
||||
}
|
||||
|
||||
public static List<WeightConfig> GetList()
|
||||
{
|
||||
return Context.GetList();
|
||||
}
|
||||
|
||||
public static List<WeightConfig> GetList(Predicate<WeightConfig> match)
|
||||
{
|
||||
return Context.GetList(match);
|
||||
}
|
||||
public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
|
||||
{
|
||||
ConfigTableHelper.ParseLine<WeightConfig>(arr);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user