DESKTOP-5RP3AKU\Jisol 0d600a2786 提交
2024-10-17 03:20:22 +08:00

42 lines
843 B
C#

using System;
using JNGame.Runtime.Util.Types;
namespace JNGame.Runtime.Entitas
{
public abstract class JNLookup
{
private int _index = 0;
public int Count => _index;
public int Next()
{
return _index++;
}
private readonly KeyValue<int, Type> _types = new();
public JNLookup()
{
BindIndex();
BindType(_types);
}
protected abstract void BindIndex();
protected abstract void BindType(KeyValue<int, Type> types);
//查询下标
public int GetIndex(Type type)
{
return _types.Value2Key(type);
}
//查询下标
public int GetIndex<T>()
{
return _types.Value2Key(typeof(T));
}
}
}