-license changed to BSD (maybe temporary) -added configurations to dub.json -initial ECS implementation (WIP): -Manager, System, Entity, Component -registering components -registering systems -calling update
58 lines
1 KiB
D
58 lines
1 KiB
D
module ecs.entity_allocator;
|
|
|
|
enum bucketSize = 4096;
|
|
enum bucketsInAllocation = 128;
|
|
|
|
struct Bucket
|
|
{
|
|
union
|
|
{
|
|
ubyte[bucketSize] memory;
|
|
Bucket* next;
|
|
}
|
|
|
|
}
|
|
|
|
struct BucketArray
|
|
{
|
|
Bucket[bucketsInAllocation] buckets;
|
|
}
|
|
|
|
struct EntityAllocator
|
|
{
|
|
BucketArray[] arrays;
|
|
Bucket* lastEmptyBucket;
|
|
|
|
Bucket* initBucketArray(ref BucketArray bArr)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
void allocateBucketArray()
|
|
{
|
|
//auto bucketArray = new BucketArray();
|
|
BucketArray bucketArray;
|
|
assert(cast(uint)bucketArray.buckets[0].memory.ptr % bucketSize == 0);
|
|
arrays ~= bucketArray;
|
|
Bucket* lasBucket = initBucketArray(bucketArray);
|
|
lastEmptyBucket = lasBucket;
|
|
}
|
|
|
|
void allocateBucket()
|
|
{
|
|
|
|
}
|
|
|
|
ubyte[] getMemory()
|
|
{
|
|
if (lastEmptyBucket is null)
|
|
{
|
|
allocateBucket();
|
|
}
|
|
auto bucketTmp = lastEmptyBucket;
|
|
lastEmptyBucket = bucketTmp.next;
|
|
|
|
return bucketTmp.memory[];
|
|
}
|
|
|
|
}
|