-added absen components list to system

-added ECS uda attributes
-added InputStruct version switch (gets update() input as structure of arrays)
-initial (WIP) EntitiesData update() input structure compile time parsing
This commit is contained in:
Mergul 2018-09-29 23:10:31 +02:00
parent 8468335b50
commit ed589bbd71
5 changed files with 238 additions and 79 deletions

View file

@ -4,6 +4,7 @@ import ecs.entity;
import ecs.events;
import ecs.manager;
import ecs.system;
import ecs.attributes;
import core.time;
import std.stdio;
@ -124,11 +125,12 @@ int main()
}
struct InputData
static struct EntitiesData
{
TestComp* test;
TestComp2* test2;
@("optional") TestComp3* test3;
@optional TestComp3* test3;
@absen TestComp4* test4;
}
void update(ref Entity entity, ref TestComp test, ref TestComp2 test2)//, TestComp3* test3) //ref TestComp comp)
@ -153,6 +155,11 @@ int main()
}
void update(ref EntitiesData data)
{
}
void handleEvent(TestEvent event, ref TestComp test, ref TestComp2 test2, TestComp3* test3)
{
@ -163,6 +170,11 @@ int main()
{
__gshared ushort system_id;
static struct EntitiesData
{
TestComp* test;
}
void initialize(ref Entity entity, ref TestComp comp)
{
@ -175,6 +187,13 @@ int main()
//writeln("High priority tekst! ");
}
void update(ref EntitiesData data) //ref TestComp comp)
{
assert(cast(size_t)&data.test % TestComp.alignof == 0);
//writeln("High priority tekst! ");
}
/*void handleEvent(Event event, ref TestComp comp)
{
@ -185,6 +204,17 @@ int main()
{
__gshared ushort system_id;
static struct EntitiesData
{
Entity* entity;
TestComp3* test;
/*void a()
{
}*/
}
void onEnable()
{
import std.stdio;
@ -211,6 +241,13 @@ int main()
gEM.sendSelfEvent!(TestEvent)(entity.id, TestEvent());
}
void update(ref EntitiesData data) //ref TestComp comp)
{
//writeln("TestSystem2 update");
data.test.gg += 14;
gEM.sendSelfEvent!(TestEvent)(data.entity.id, TestEvent());
}
/*void handleEvent(Event event, ref TestComp comp)
{