You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using Unity.Burst;
|
|
|
|
|
|
|
|
|
|
namespace GameCore.TinyECS
|
|
|
|
|
{
|
|
|
|
|
internal static class ComponentIdHelper
|
|
|
|
|
{
|
|
|
|
|
public static int currentId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ComponentId<T>
|
|
|
|
|
{
|
|
|
|
|
public int id;
|
|
|
|
|
public static readonly SharedStatic<ComponentId<T>> Instance = SharedStatic<ComponentId<T>>.GetOrCreate<ComponentId<T>>();
|
|
|
|
|
|
|
|
|
|
[BurstDiscard]
|
|
|
|
|
static void EnsureInitialized()
|
|
|
|
|
{
|
|
|
|
|
if (Instance.Data.id == 0)
|
|
|
|
|
{
|
|
|
|
|
Instance.Data.id = ++ComponentIdHelper.currentId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int Get()
|
|
|
|
|
{
|
|
|
|
|
EnsureInitialized();
|
|
|
|
|
return Instance.Data.id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|