-working update() with EntitiesData structure input

-added support for 'const' components input (read only, future usage)
This commit is contained in:
Mergul 2018-09-30 23:12:20 +02:00
parent ed589bbd71
commit d5780a6252
3 changed files with 167 additions and 86 deletions

View file

@ -127,10 +127,10 @@ int main()
static struct EntitiesData
{
TestComp* test;
TestComp2* test2;
@optional TestComp3* test3;
@absen TestComp4* test4;
TestComp[] test;
TestComp2[] test2;
@optional TestComp3[] test3;
@absen TestComp4[] test4;
}
void update(ref Entity entity, ref TestComp test, ref TestComp2 test2)//, TestComp3* test3) //ref TestComp comp)
@ -139,25 +139,21 @@ int main()
assert(cast(size_t)&test2 % TestComp2.alignof == 0);
import std.stdio;
//writeln("Jakis tekst! ",test.b);
test.a += 1000;
test.b += 2000;
//writeln("Jakis tekst! ",test.b);
test2.b += 2;
test2.a = 8;
//writeln("Jakis tekst! ",test2.b);
//writeln("Low priority tekst! ");
/*if (test3)
{
test3.gg = 200;
test3.bg += 1;
}*/
}
void update(ref EntitiesData data)
{
foreach(i;0..data.test.length)
{
data.test[i].a += 1000;
data.test[i].b += 2000;
data.test2[i].b += 2;
data.test2[i].a = 8;
}
}
void handleEvent(TestEvent event, ref TestComp test, ref TestComp2 test2, TestComp3* test3)
@ -172,7 +168,7 @@ int main()
static struct EntitiesData
{
TestComp* test;
TestComp[] test;
}
void initialize(ref Entity entity, ref TestComp comp)
@ -206,8 +202,8 @@ int main()
static struct EntitiesData
{
Entity* entity;
TestComp3* test;
Entity[] entity;
TestComp3[] test;
/*void a()
{
@ -244,8 +240,12 @@ int main()
void update(ref EntitiesData data) //ref TestComp comp)
{
//writeln("TestSystem2 update");
data.test.gg += 14;
gEM.sendSelfEvent!(TestEvent)(data.entity.id, TestEvent());
foreach(i;0..data.test.length)
{
data.test[i].gg += 14;
gEM.sendSelfEvent!(TestEvent)(data.entity[i].id, TestEvent());
}
}
/*void handleEvent(Event event, ref TestComp comp)