-add systemCaller to entity only if their components matches

-System onEnable() and onDisable() callbacks
This commit is contained in:
Mergul 2018-09-12 14:28:32 +02:00
parent 22fdd2f4e4
commit ae53e13d42
4 changed files with 152 additions and 78 deletions

View file

@ -77,6 +77,18 @@ int main()
struct TestSystem2
{
void onEnable()
{
import std.stdio;
writeln("TestSystem2 enabled");
}
void onDisable()
{
import std.stdio;
writeln("TestSystem2 disabled");
}
void initialize(ref TestComp comp)
{
@ -102,15 +114,15 @@ int main()
gEM.registerComponent!TestComp;
ulong dur = (MonoTime.currTime - time).total!"usecs";
writeln("Components register time: ",dur," usecs");
writeln("Components register: ",dur," usecs");
time = MonoTime.currTime;
gEM.registerSystem!TestSystem(0);
gEM.registerSystem!TestSystem2(0);
//gEM.registerSystem!TestSystem2(0);
dur = (MonoTime.currTime - time).total!"usecs";
writeln("System register time: ",dur," usecs");
writeln("Systems register: ",dur," usecs");
time = MonoTime.currTime;
@ -119,7 +131,7 @@ int main()
*cast(EntityID*)tmpl.entity_data.ptr = EntityID(1,1);
dur = (MonoTime.currTime - time).total!"usecs";
writeln("Template allocating time: ",dur," usecs");
writeln("Template allocating: ",dur," usecs");
time = MonoTime.currTime;
@ -128,6 +140,8 @@ int main()
dur = (MonoTime.currTime - time).total!"usecs";
writeln("Entities adding: ",dur," usecs");
gEM.registerSystem!TestSystem2(0);
//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));
@ -136,10 +150,10 @@ int main()
gEM.update();
dur = (MonoTime.currTime - time).total!"usecs";
writeln("Update time: ",dur," usecs");
writeln("Update: ",dur," usecs");
import std.stdio;
writeln((cast(uint*)tmpl.info.first_block)[0..48]);
//import std.stdio;
//writeln((cast(uint*)tmpl.info.first_block)[0..48]);
gEM.freeTemplate(tmpl);
return 0;
}