mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-10-13 10:36:07 +00:00
提交Unity 联机Pro
This commit is contained in:
44
JNFrame2/Assets/JNGame/EntitasExtend/JNLookup.cs
Normal file
44
JNFrame2/Assets/JNGame/EntitasExtend/JNLookup.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Entitas;
|
||||
using JNGame.Util.Types;
|
||||
|
||||
namespace JNGame.EntitasExtend
|
||||
{
|
||||
public abstract class JNLookup
|
||||
{
|
||||
|
||||
private int _index = 0;
|
||||
|
||||
public int Count => _index + 1;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user