Implemented basic ECS

This commit is contained in:
Simon Lübeß
2021-04-09 19:35:24 +02:00
parent 047c09017c
commit 6376bde112
5 changed files with 478 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
using System;
namespace GlitchyEngine.World
{
public class ComponentPool
{
int _objectSize;
int _capacity;
int PoolSize => _objectSize * _capacity;
uint8* _rawData ~ delete _;
public this(int objectSize, int capacity)
{
_objectSize = objectSize;
_capacity = capacity;
_rawData = new uint8[_capacity * _objectSize]*;
}
[Inline]
public void* Get(int index)
{
Log.EngineLogger.AssertDebug(index >= 0 && index < _capacity);
return _rawData + index * _objectSize;
}
}
}