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.
25 lines
548 B
25 lines
548 B
2 years ago
|
using System;
|
||
|
|
||
|
namespace GameCore.TinyECS
|
||
|
{
|
||
|
public struct ComponentId
|
||
|
{
|
||
|
struct Inner<T> where T : unmanaged
|
||
|
{
|
||
|
public int id;
|
||
|
private Inner(int i) => id = i;
|
||
|
public static Inner<T> Instance = default;
|
||
|
}
|
||
|
|
||
|
static int currentId;
|
||
|
|
||
|
public static int Get<T>() where T : unmanaged
|
||
|
{
|
||
|
if (Inner<T>.Instance.id == 0)
|
||
|
{
|
||
|
Inner<T>.Instance.id = ++currentId;
|
||
|
}
|
||
|
return Inner<T>.Instance.id;
|
||
|
}
|
||
|
}
|
||
|
}
|