2023-06-27 05:09:41 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS
|
|
|
|
|
{
|
|
|
|
|
namespace Internal
|
|
|
|
|
{
|
|
|
|
|
internal static class EcsTypeCode
|
|
|
|
|
{
|
|
|
|
|
private static readonly Dictionary<Type, int> _codes = new Dictionary<Type, int>();
|
|
|
|
|
private static int _incremetn = 1;
|
|
|
|
|
public static int GetCode(Type type)
|
|
|
|
|
{
|
|
|
|
|
if (!_codes.TryGetValue(type, out int code))
|
|
|
|
|
{
|
|
|
|
|
code = _incremetn++;
|
|
|
|
|
_codes.Add(type, code);
|
|
|
|
|
}
|
|
|
|
|
return code;
|
|
|
|
|
}
|
|
|
|
|
public static int Count => _codes.Count;
|
2023-06-29 00:56:26 +08:00
|
|
|
|
internal static class Cache<T>
|
|
|
|
|
{
|
2023-06-29 17:57:28 +08:00
|
|
|
|
public static readonly int code = GetCode(typeof(T));
|
2023-06-29 00:56:26 +08:00
|
|
|
|
}
|
2023-06-27 05:09:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|