-better compile time code generation

-support for AbsenComponents. Absen components can't exist in entity which are
	used by system. There are three possibilities to add absen component. Add
	'@absen' property to EntitiesData mebmer, create AbsenComponents enum with fields
	names corresponding to components names, or create AbsenComponents AliasSeq
	with strings expressions corresponding to components names.
This commit is contained in:
Mergul 2018-10-01 17:17:40 +02:00
parent 125c9e7d40
commit e4573f1ec7
2 changed files with 93 additions and 29 deletions

View file

@ -131,7 +131,7 @@ int main()
TestComp[] test;
TestComp2[] test2;
@optional TestComp3[] test3;
@absen TestComp4[] test4;
//@absen TestComp4[] test4;
}
void update(ref Entity entity, ref TestComp test, ref TestComp2 test2)//, TestComp3* test3) //ref TestComp comp)
@ -188,15 +188,28 @@ int main()
}*/
}
import std.meta;
struct TestSystem2
{
__gshared ushort system_id;
enum AbsenComponents0
{
TestComp,
TestComp4
}
alias AbsenComponents = AliasSeq!("TestComp", "TestComp4");
string AbsenComponents2;
static struct EntitiesData
{
short length;
Entity[] entity;
TestComp3[] test;
//@absen TestComp[] testt;
}
void onEnable()
@ -225,7 +238,15 @@ int main()
data.test[i].gg += 14;
gEM.sendSelfEvent!(TestEvent)(data.entity[i].id, TestEvent());
}
}
void lateUpdate(ref EntitiesData data)
{
foreach(i;0..data.test.length)
{
data.test[i].gg -= 1;
gEM.sendSelfEvent!(TestEvent)(data.entity[i].id, TestEvent());
}
}
/*void handleEvent(Event event, ref TestComp comp)