This commit is contained in:
azw 2024-05-18 18:38:27 +08:00
parent 094f1d4f48
commit 2bf10f47c4
4 changed files with 81 additions and 5 deletions

View File

@ -39,15 +39,54 @@ namespace F6
} }
public class RawMetaTable<T>: IMetaTable
{
public sealed class MetaTableFieldAttribute : Attribute
{
public string fieldName;
}
public class BaseMeta
{
public Dictionary<string, int> nameIdxHash = new Dictionary<string, int>();
}
public class BaseTable
{
private BaseMeta _meta;
private BitArray _flags;
public bool HasValue(string fieldName)
{
return this.HasValue(this.GetFieldIdx(fieldName));
}
public bool HasValue(int fieldIdx)
{
return this._flags.Get(fieldIdx);
}
public int GetFieldIdx(string fieldName)
{
int idx = 0;
this._meta.nameIdxHash.TryGetValue(fieldName, out idx);
return idx;
}
}
public class RawMetaTable<T> : IMetaTable
{
protected string fileName; protected string fileName;
protected string primKey; protected string primKey;
protected bool noLoad; protected bool noLoad;
protected List<T> rawList = new List<T>(); protected List<T> rawList = new List<T>();
public RawMetaTable(string fileName, string primKey)
{
this.fileName = fileName;
this.primKey = primKey;
}
public void Traverse(TraverseCb<T> cb) public void Traverse(TraverseCb<T> cb)
{ {
foreach(var item in this.rawList) foreach(var item in this.rawList)
@ -95,6 +134,12 @@ namespace F6
{ {
base.LoadPost(); base.LoadPost();
} }
public IdMetaTable(string fileName, string primKey) :base(fileName, primKey)
{
// base(fileName, primKey);
}
} }
public class NameMetaTable<T>: RawMetaTable<T> public class NameMetaTable<T>: RawMetaTable<T>
@ -112,6 +157,12 @@ namespace F6
{ {
base.LoadPost(); base.LoadPost();
} }
public NameMetaTable(string fileName, string primKey):base(fileName, primKey)
{
}
} }
} }

View File

@ -6,7 +6,17 @@ using System.Threading.Tasks;
namespace cfclient.Mt namespace cfclient.Mt
{ {
class Equip class Equip : Mtb.Equip
{ {
} }
class EquipTable :F6.IdMetaTable<Equip>
{
public EquipTable(string fileName, string primKey):base(fileName, primKey)
{
}
}
} }

14
Mt/Table.cs Normal file
View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace cfclient.Mt
{
class Table
{
public static EquipTable Equip = new EquipTable("", "");
}
}

View File

@ -6,8 +6,9 @@ using System.Threading.Tasks;
namespace cfclient.Mtb namespace cfclient.Mtb
{ {
class Equip class Equip : F6.BaseTable
{ {
[F6.MetaTableField(fieldName ="id")]
public int id { get; } public int id { get; }
} }
} }