-components and infos are now stored in hash maps

-adding entities
-Template allocating and freeing
-Deltas calulating for components in EntityType
-Updating for every EntityType and System
-Generate deltas, components list, and functions callers for Systems
This commit is contained in:
Mergul 2018-09-09 23:28:18 +02:00
parent 9abc36be1c
commit a61a54b43f
5 changed files with 232 additions and 44 deletions

View file

@ -32,6 +32,23 @@ unittest
}
}
struct TestComp2
{
__gshared static int component_id;
short b;
ubyte a;
static void serializeComponent(ref TestComp comp, SerializeVector output)
{
}
static void deserializeComponent(ref TestComp comp, ubyte[] data)
{
}
}
struct TestSystem
{
@ -40,12 +57,35 @@ unittest
}
void update()//ref TestComp comp)
void update(ref TestComp test, ref TestComp2 test2)//ref TestComp comp)
{
//comp.a+=1000;
//comp.b+=2000;
import std.stdio;
writeln("Jakis tekst!");
import std.stdio;
writeln("Jakis tekst! ",test.b);
test.a+=1000;
test.b+=2000;
writeln("Jakis tekst! ",test.b);
test2.b += 2;
test2.a = 1;
writeln("Jakis tekst! ",test2.b);
}
void handleEvent(Event event, ref TestComp comp)
{
}
}
struct TestSystem2
{
void initialize(ref TestComp comp)
{
}
void update(ref TestComp2 test2)//ref TestComp comp)
{
test2.b += 1000;
}
void handleEvent(Event event, ref TestComp comp)
@ -57,13 +97,26 @@ unittest
EntityManager.initialize();
assert(gEM !is null);
gEM.registerComponent!TestComp2;
gEM.registerComponent!TestComp;
gEM.registerSystem!TestSystem(0);
gEM.registerSystem!TestSystem2(0);
uint[1] ids = [0];
ushort[2] ids = [0,1];
EntityTemplate* tmpl = gEM.allocateTemplate(ids);
*cast(EntityID*)tmpl.entity_data.ptr = EntityID(1,1);
gEM.registerSystem!TestSystem(0);
gEM.addEntity(tmpl);
gEM.addEntity(tmpl);
//assert(*(cast(EntityID*)(cast(void*)tmpl.info.first_block+24)) == EntityID(1,1));
//assert(*(cast(EntityID*)(cast(void*)tmpl.info.first_block+48)) == EntityID(1,1));
gEM.update();
gEM.update();
import std.stdio;
writeln((cast(uint*)tmpl.info.first_block)[0..48]);
gEM.freeTemplate(tmpl);
}