30 lines
782 B
C#
30 lines
782 B
C#
using System.Collections.Generic;
|
|
|
|
namespace MoonTools.ECS
|
|
{
|
|
internal class ComponentStorageState
|
|
{
|
|
public int Count;
|
|
public Dictionary<int, int> EntityIdToStorageIndex;
|
|
public byte[] EntityIDs;
|
|
public byte[] Components;
|
|
|
|
public unsafe static ComponentStorageState Create<TComponent>(int count) where TComponent : unmanaged
|
|
{
|
|
return new ComponentStorageState(
|
|
count,
|
|
count * sizeof(int),
|
|
count * sizeof(TComponent)
|
|
);
|
|
}
|
|
|
|
private ComponentStorageState(int count, int entityIDSize, int componentSize)
|
|
{
|
|
Count = count;
|
|
EntityIdToStorageIndex = new Dictionary<int, int>(count);
|
|
EntityIDs = new byte[entityIDSize];
|
|
Components = new byte[componentSize];
|
|
}
|
|
}
|
|
}
|