mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
29 lines
450 B
Beef
29 lines
450 B
Beef
using System;
|
|
|
|
namespace GlitchyEngine.World
|
|
{
|
|
public interface IComponentPool
|
|
{
|
|
public void* Get(int index);
|
|
}
|
|
|
|
public class ComponentPool<T> : IComponentPool
|
|
{
|
|
int PoolSize => sizeof(T) * _data.Count;
|
|
T[] _data ~ delete _;
|
|
|
|
public this(int capacity)
|
|
{
|
|
_data = new T[capacity];
|
|
}
|
|
|
|
[Inline]
|
|
public void* Get(int index)
|
|
{
|
|
Log.EngineLogger.AssertDebug(index >= 0 && index < _data.Count);
|
|
|
|
return &_data[index];
|
|
}
|
|
}
|
|
}
|