表格重构

This commit is contained in:
2025-10-10 17:57:36 +08:00
parent bf2f6d2680
commit bf7b1bbbb2
133 changed files with 4481 additions and 1366 deletions

View File

@@ -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
}
}