Merge branch 'master' of https://gitlab.com/Mergul/bubel-ecs.git into Demos

This commit is contained in:
Mergul 2021-02-27 17:43:05 +01:00
commit 1acd0df0ef
17 changed files with 332 additions and 293 deletions

View file

@ -65,7 +65,7 @@ void beforeEveryTest()
gEM.endRegister();
tmpl = gEM.allocateTemplate([CLong.component_id, CInt.component_id, CUInt.component_id, CBig.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
foreach(i; 0 .. 100_000)gEM.addEntity(tmpl);
}

View file

@ -115,7 +115,7 @@ struct EmptySystem
void beforeEveryTest()
{
CUnregistered.component_id = ushort.max;
becsID!CUnregistered = ushort.max;
gEM.initialize(0);
gEM.beginRegister();
@ -138,18 +138,18 @@ void afterEveryTest()
@("EntityMeta")
unittest
{
EntityTemplate* tmpl_ = gEM.allocateTemplate([CInt.component_id, CFloat.component_id, CFlag.component_id].staticArray);
EntityTemplate* tmpl_ = gEM.allocateTemplate([becsID!CInt, becsID!CFloat, becsID!CFlag].staticArray);
scope(exit)gEM.freeTemplate(tmpl_);
Entity* entity = gEM.addEntity(tmpl_);
EntityMeta meta = entity.getMeta();
assert(meta.hasComponent(CInt.component_id));
assert(meta.hasComponent(becsID!CInt));
assert(meta.getComponent!CInt);
assert(meta.hasComponent(CFloat.component_id));
assert(meta.hasComponent(becsID!CFloat));
assert(meta.getComponent!CFloat);
assert(!meta.getComponent!CLong);
assert(!meta.hasComponent(CLong.component_id));
assert(!meta.hasComponent(becsID!CLong));
assert(!meta.getComponent!CUnregistered);
assert(!meta.hasComponent(CUnregistered.component_id));
assert(!meta.hasComponent(becsID!CUnregistered));
assert(*meta.getComponent!CInt == 1);
assert(*meta.getComponent!CFloat == 2.0);
}
@ -157,7 +157,7 @@ unittest
@("AddEntity")
unittest
{
EntityTemplate* tmpl_ = gEM.allocateTemplate([CInt.component_id, CFloat.component_id, CFlag.component_id].staticArray);
EntityTemplate* tmpl_ = gEM.allocateTemplate([becsID!CInt, becsID!CFloat, becsID!CFlag].staticArray);
scope(exit)gEM.freeTemplate(tmpl_);
assert(tmpl_.info.components.length == 3);
assert(tmpl_.info.size == (CInt.sizeof + CFloat.sizeof + EntityID.sizeof));
@ -187,8 +187,8 @@ unittest
//Entity* entity3 = gEM.addEntity(tmpl_, [cint.ref_, clong.ref_].staticArray);
Entity* entity3 = gEM.addEntity(tmpl_, [CInt(10).ref_, CLong().ref_, CFlag().ref_].staticArray);
EntityID id = entity3.id;
assert(entity3.hasComponent(CInt.component_id));
assert(entity3.hasComponent(CFloat.component_id));
assert(entity3.hasComponent(becsID!CInt));
assert(entity3.hasComponent(becsID!CFloat));
assert(*entity3.getComponent!CInt == 10);
assert(*entity3.getComponent!CFloat == 2.0);
@ -203,7 +203,7 @@ unittest
assert(*entity3.getComponent!CFloat == 2.0);
assert(*entity3.getComponent!CShort == 2);
gEM.removeComponents(entity3.id, [CFlag().component_id,CShort(2).component_id].staticArray);
gEM.removeComponents(entity3.id, [becsID!CFlag,becsID!CShort].staticArray);
gEM.commit();
entity3 = gEM.getEntity(id);
assert(entity3.getComponent!CInt);
@ -214,7 +214,7 @@ unittest
assert(*entity3.getComponent!CFloat == 2.0);
gEM.addComponents(entity3.id, [CFlag().ref_,CShort(2).ref_].staticArray);
gEM.removeComponents(entity3.id, [CUnregistered.component_id].staticArray);
gEM.removeComponents(entity3.id, [becsID!CUnregistered].staticArray);
gEM.commit();
entity3 = gEM.getEntity(id);
assert(entity3.getComponent!CInt);
@ -237,7 +237,7 @@ unittest
assert(entity3.getComponent!CUnregistered);
assert(*entity3.getComponent!CUnregistered == 4);
gEM.removeComponents(entity3.id, [CUnregistered.component_id].staticArray);
gEM.removeComponents(entity3.id, [becsID!CUnregistered].staticArray);
gEM.commit();
entity3 = gEM.getEntity(id);
assert(!entity3.getComponent!CUnregistered);
@ -249,9 +249,9 @@ unittest
unittest
{
//basic template allocation
ushort[2] ids = [CInt.component_id, CFloat.component_id];
ushort[2] ids = [becsID!CInt, becsID!CFloat];
EntityTemplate* tmpl_ = gEM.allocateTemplate(ids);
EntityTemplate* tmpl_d = gEM.allocateTemplate([CFloat.component_id, CInt.component_id, CFloat.component_id].staticArray);
EntityTemplate* tmpl_d = gEM.allocateTemplate([becsID!CFloat, becsID!CInt, becsID!CFloat].staticArray);
EntityTemplate* tmpl_cp = gEM.allocateTemplate(tmpl_);
assert(tmpl_d.info == tmpl_.info);
assert(tmpl_cp.info == tmpl_cp.info);
@ -270,7 +270,7 @@ unittest
*tmpl_.getComponent!CFloat = 5.0;
//allocate template from template with additional components
ushort[2] ids2 = [CDouble.component_id,CFlag.component_id];
ushort[2] ids2 = [becsID!CDouble,becsID!CFlag];
EntityTemplate* tmpl_2 = gEM.allocateTemplate(tmpl_, ids2);
assert(tmpl_2.info.components.length == 4);
assert(tmpl_2.getComponent!CInt);
@ -315,7 +315,7 @@ unittest
assert(*tmpl_4.getComponent!CDouble == 3.0);
//allocate template from template with three additional component
ushort[3] ids3 = [CDouble.component_id, CLong.component_id, CShort.component_id];
ushort[3] ids3 = [becsID!CDouble, becsID!CLong, becsID!CShort];
EntityTemplate* tmpl_5 = gEM.allocateTemplate(tmpl_2, ids3);
assert(tmpl_5.info.components.length == 6);
assert(tmpl_5.getComponent!CInt);
@ -330,7 +330,7 @@ unittest
assert(*tmpl_5.getComponent!CShort == 12);
//allocate template from template without one component
ushort[1] rem_ids = [CFloat.component_id];
ushort[1] rem_ids = [becsID!CFloat];
EntityTemplate* tmpl_6 = gEM.allocateTemplate(tmpl_, null, rem_ids);
assert(tmpl_6.info.components.length == 1);
assert(tmpl_6.getComponent!CInt);
@ -361,8 +361,8 @@ unittest
unittest
{
//basic template allocation
ushort[2] ids = [CFloat.component_id, CInt.component_id];
ushort[2] ids2 = [CInt.component_id, CFloat.component_id];
ushort[2] ids = [becsID!CFloat, becsID!CInt];
ushort[2] ids2 = [becsID!CInt, becsID!CFloat];
EntityTemplate* tmpl_ = gEM.allocateTemplate(ids);
EntityTemplate* tmpl_2 = gEM.allocateTemplate(ids2);
assert(tmpl_.info.components.length == 2);
@ -403,9 +403,9 @@ unittest
assert(system !is null);
assert(system.count == 0);
System* ecs_system = gEM.getSystem(EmptySystem.system_id);
System* ecs_system = gEM.getSystem(becsID!EmptySystem);
assert(ecs_system !is null);
assert(ecs_system.id == EmptySystem.system_id);
assert(ecs_system.id == becsID!EmptySystem);
assert(ecs_system.name == "tests.basic.EmptySystem");
gEM.begin();
@ -507,7 +507,7 @@ unittest
//FIXME: currently destroy is only called with Manager.destory which is bug, but there is no workaround for this by now
//assert(destroy == 1);
System* ecs_system = gEM.getSystem(system.system_id);
System* ecs_system = gEM.getSystem(system.becsID);
ecs_system.enable();
assert(system.enable == 1);
@ -518,7 +518,7 @@ unittest
assert(system.disable == 1);
ushort[2] ids = [CLong.component_id,CFloat.component_id];
ushort[2] ids = [becsID!CLong,becsID!CFloat];
EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl);
gEM.addEntity(tmpl);
@ -532,7 +532,7 @@ unittest
gEM.end();
assert(system.end == 1);
ushort[2] ids2 = [CLong.component_id, CInt.component_id];
ushort[2] ids2 = [becsID!CLong, becsID!CInt];
EntityTemplate* tmpl2 = gEM.allocateTemplate(ids2);
scope (exit) gEM.freeTemplate(tmpl2);
gEM.addEntity(tmpl2);
@ -547,7 +547,7 @@ unittest
gEM.end();
assert(system.end == 2);
ushort[2] ids3 = [CLong.component_id, CShort.component_id];
ushort[2] ids3 = [becsID!CLong, becsID!CShort];
EntityTemplate* tmpl3 = gEM.allocateTemplate(ids3);
scope (exit) gEM.freeTemplate(tmpl3);
gEM.addEntity(tmpl3);
@ -606,13 +606,13 @@ unittest
assert(system !is null);
assert(system.updates_count == 0);
System* ecs_system = gEM.getSystem(LongAddSystem.system_id);
System* ecs_system = gEM.getSystem(becsID!LongAddSystem);
assert(ecs_system !is null);
assert(ecs_system.id == LongAddSystem.system_id);
assert(ecs_system.id == becsID!LongAddSystem);
assert(ecs_system.priority == -1);
assert(ecs_system.name == "tests.basic.LongAddSystem");
ushort[1] ids = [CLong.component_id];
ushort[1] ids = [becsID!CLong];
EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl);
gEM.addEntity(tmpl);
@ -762,19 +762,19 @@ unittest
assert(system.remove == 0);
assert(system.change == 0);
EntityTemplate* tmpl = gEM.allocateTemplate([CLong.component_id,CFloat.component_id].staticArray);
EntityTemplate* tmpl = gEM.allocateTemplate([becsID!CLong,becsID!CFloat].staticArray);
scope (exit) gEM.freeTemplate(tmpl);
EntityID id0 = gEM.addEntity(tmpl).id;
gEM.commit();
assert(system.add == 1);
EntityTemplate* tmpl2 = gEM.allocateTemplate([CLong.component_id, CInt.component_id].staticArray);
EntityTemplate* tmpl2 = gEM.allocateTemplate([becsID!CLong, becsID!CInt].staticArray);
scope (exit) gEM.freeTemplate(tmpl2);
EntityID id1 = gEM.addEntity(tmpl2).id;
gEM.commit();
assert(system.add == 2);
EntityTemplate* tmpl3 = gEM.allocateTemplate([CLong.component_id, CShort.component_id].staticArray);
EntityTemplate* tmpl3 = gEM.allocateTemplate([becsID!CLong, becsID!CShort].staticArray);
scope (exit) gEM.freeTemplate(tmpl3);
EntityID id2 = gEM.addEntity(tmpl3).id;
gEM.commit();
@ -783,19 +783,19 @@ unittest
gEM.beginRegister();
gEM.endRegister();
gEM.removeComponents(id0, [CFloat.component_id].staticArray);
gEM.removeComponents(id0, [becsID!CFloat].staticArray);
gEM.commit();
assert(system.add == 2);
assert(system.remove == 0);
assert(system.change == 0);
gEM.removeComponents(id1, [CInt.component_id].staticArray);
gEM.removeComponents(id1, [becsID!CInt].staticArray);
gEM.commit();
assert(system.add == 2);
assert(system.remove == 0);
assert(system.change == 1);
gEM.removeComponents(id2, [CShort.component_id].staticArray);
gEM.removeComponents(id2, [becsID!CShort].staticArray);
gEM.commit();
assert(system.add == 3);
assert(system.remove == 0);
@ -894,7 +894,7 @@ unittest
}
assert(gEM.getSystem!TestSystem is null);
assert(gEM.getSystem(TestSystem.system_id) is null);
assert(gEM.getSystem(becsID!TestSystem) is null);
}
@("MultithreadedUpdate")
@ -966,10 +966,10 @@ unittest
TestSystem* system = gEM.getSystem!TestSystem;
TestEmptySystem* empty_system = gEM.getSystem!TestEmptySystem;
ushort[2] ids = [CLong.component_id,CFloat.component_id];
ushort[2] ids = [becsID!CLong,becsID!CFloat];
EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl);
EntityTemplate* tmpl2 = gEM.allocateTemplate([CLong.component_id,CInt.component_id,CShort.component_id,CFloat.component_id].staticArray);
EntityTemplate* tmpl2 = gEM.allocateTemplate([becsID!CLong,becsID!CInt,becsID!CShort,becsID!CFloat].staticArray);
scope (exit) gEM.freeTemplate(tmpl2);
gEM.begin();
@ -1064,7 +1064,7 @@ unittest
@("AddRemoveEntities")
unittest
{
ushort[3] ids = [CLong.component_id,CFloat.component_id,CShort.component_id];
ushort[3] ids = [becsID!CLong,becsID!CFloat,becsID!CShort];
EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl);
@ -1094,7 +1094,7 @@ unittest
gEM.endRegister();
ushort[1] ids = [CLong.component_id];
ushort[1] ids = [becsID!CLong];
EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl);
@ -1123,7 +1123,7 @@ unittest
assert(*entity.getComponent!CShort == 15);
assert(*entity.getComponent!CFloat == 13);
ushort[3] ids2 = [CFloat.component_id, CLong.component_id, CUnregistered.component_id];
ushort[3] ids2 = [becsID!CFloat, becsID!CLong, becsID!CUnregistered];
gEM.removeComponents(id, ids2);
gEM.commit();
@ -1166,12 +1166,12 @@ unittest
{
struct ETest
{
mixin ECS.Event;
// mixin ECS.Event;
}
struct ETest2
{
mixin ECS.Event;
// mixin ECS.Event;
void onDestroy()
{
@ -1258,10 +1258,10 @@ unittest
gEM.endRegister();
ushort[1] ids = [CLong.component_id];
ushort[1] ids = [becsID!CLong];
EntityTemplate* tmpl = gEM.allocateTemplate(ids);
scope (exit) gEM.freeTemplate(tmpl);
ushort[1] ids2 = [CShort.component_id];
ushort[1] ids2 = [becsID!CShort];
EntityTemplate* tmpl2 = gEM.allocateTemplate(ids2);
scope (exit) gEM.freeTemplate(tmpl2);
@ -1353,11 +1353,11 @@ unittest
gEM.endRegister();
EntityTemplate* tmpl = gEM.allocateTemplate([CInt.component_id].staticArray);
EntityTemplate* tmpl = gEM.allocateTemplate([becsID!CInt].staticArray);
scope (exit) gEM.freeTemplate(tmpl);
EntityID id1 = gEM.addEntity(tmpl).id;
EntityTemplate* tmpl2 = gEM.allocateTemplate([CInt.component_id, CLong.component_id].staticArray);
EntityTemplate* tmpl2 = gEM.allocateTemplate([becsID!CInt, becsID!CLong].staticArray);
scope (exit) gEM.freeTemplate(tmpl2);
EntityID id2 = gEM.addEntity(tmpl2).id;
@ -1476,22 +1476,22 @@ unittest
const (EntityManager.UpdatePass)* pass = gEM.getPass("update");
assert(pass != null);
assert(pass.system_callers.length == 5);
assert(pass.system_callers[0].system_id == TestSystem.system_id);
assert(pass.system_callers[1].system_id == TestSystem2.system_id);
assert(pass.system_callers[2].system_id == TestSystem3.system_id);
assert(pass.system_callers[3].system_id == TestSystem4.system_id);
assert(pass.system_callers[4].system_id == TestSystem5.system_id);
assert(pass.system_callers[0].system_id == becsID!TestSystem);
assert(pass.system_callers[1].system_id == becsID!TestSystem2);
assert(pass.system_callers[2].system_id == becsID!TestSystem3);
assert(pass.system_callers[3].system_id == becsID!TestSystem4);
assert(pass.system_callers[4].system_id == becsID!TestSystem5);
assert(pass.system_callers[0].dependencies.length == 0);
assert(pass.system_callers[1].dependencies.length == 1);
assert(pass.system_callers[2].dependencies.length == 1);
assert(pass.system_callers[3].dependencies.length == 3);
assert(pass.system_callers[4].dependencies.length == 1);
assert(pass.system_callers[1].dependencies[0].system_id == TestSystem.system_id);
assert(pass.system_callers[2].dependencies[0].system_id == TestSystem2.system_id);
assert(pass.system_callers[3].dependencies[0].system_id == TestSystem.system_id);
assert(pass.system_callers[3].dependencies[1].system_id == TestSystem2.system_id);
assert(pass.system_callers[3].dependencies[2].system_id == TestSystem3.system_id);
assert(pass.system_callers[4].dependencies[0].system_id == TestSystem4.system_id);
assert(pass.system_callers[1].dependencies[0].system_id == becsID!TestSystem);
assert(pass.system_callers[2].dependencies[0].system_id == becsID!TestSystem2);
assert(pass.system_callers[3].dependencies[0].system_id == becsID!TestSystem);
assert(pass.system_callers[3].dependencies[1].system_id == becsID!TestSystem2);
assert(pass.system_callers[3].dependencies[2].system_id == becsID!TestSystem3);
assert(pass.system_callers[4].dependencies[0].system_id == becsID!TestSystem4);
}
@("ExternalSystemDependencies")
@ -1603,23 +1603,23 @@ unittest
const (EntityManager.UpdatePass)* pass = gEM.getPass("update");
assert(pass != null);
assert(pass.system_callers.length == 5);
assert(pass.system_callers[0].system_id == TestSystem.system_id);
assert(pass.system_callers[1].system_id == TestSystem2.system_id);
assert(pass.system_callers[2].system_id == TestSystem3.system_id);
assert(pass.system_callers[3].system_id == TestSystem4.system_id);
assert(pass.system_callers[4].system_id == TestSystem5.system_id);
assert(pass.system_callers[0].system_id == becsID!TestSystem);
assert(pass.system_callers[1].system_id == becsID!TestSystem2);
assert(pass.system_callers[2].system_id == becsID!TestSystem3);
assert(pass.system_callers[3].system_id == becsID!TestSystem4);
assert(pass.system_callers[4].system_id == becsID!TestSystem5);
assert(pass.system_callers[0].dependencies.length == 0);
assert(pass.system_callers[1].dependencies.length == 1);
assert(pass.system_callers[2].dependencies.length == 1);
assert(pass.system_callers[3].dependencies.length == 3);
assert(pass.system_callers[4].dependencies.length == 2);
assert(pass.system_callers[1].dependencies[0].system_id == TestSystem.system_id);
assert(pass.system_callers[2].dependencies[0].system_id == TestSystem2.system_id);
assert(pass.system_callers[3].dependencies[0].system_id == TestSystem.system_id);
assert(pass.system_callers[3].dependencies[1].system_id == TestSystem2.system_id);
assert(pass.system_callers[3].dependencies[2].system_id == TestSystem3.system_id);
assert(pass.system_callers[4].dependencies[0].system_id == TestSystem2.system_id);
assert(pass.system_callers[4].dependencies[1].system_id == TestSystem4.system_id);
assert(pass.system_callers[1].dependencies[0].system_id == becsID!TestSystem);
assert(pass.system_callers[2].dependencies[0].system_id == becsID!TestSystem2);
assert(pass.system_callers[3].dependencies[0].system_id == becsID!TestSystem);
assert(pass.system_callers[3].dependencies[1].system_id == becsID!TestSystem2);
assert(pass.system_callers[3].dependencies[2].system_id == becsID!TestSystem3);
assert(pass.system_callers[4].dependencies[0].system_id == becsID!TestSystem2);
assert(pass.system_callers[4].dependencies[1].system_id == becsID!TestSystem4);
}
@ -1641,11 +1641,11 @@ unittest
bool filterEntity(EntityManager.EntityInfo* info)
{
if(!info.hasComponent(CInt.component_id))return false;
if(!info.hasComponent(becsID!CInt))return false;
int one_from = 0;
if(info.hasComponent(CLong.component_id))one_from++;
if(info.hasComponent(CFloat.component_id))one_from++;
if(info.hasComponent(CDouble.component_id))one_from++;
if(info.hasComponent(becsID!CLong))one_from++;
if(info.hasComponent(becsID!CFloat))one_from++;
if(info.hasComponent(becsID!CDouble))one_from++;
if(one_from == 1)return true;
return false;
}
@ -1673,8 +1673,8 @@ unittest
bool filterEntity(EntityManager.EntityInfo* info)
{
if(info.hasComponent(CInt.component_id) && info.hasComponent(CFloat.component_id) && !info.hasComponent(CLong.component_id) && !info.hasComponent(CDouble.component_id))return true;
if(info.hasComponent(CLong.component_id) && info.hasComponent(CDouble.component_id) && !info.hasComponent(CInt.component_id) && !info.hasComponent(CFloat.component_id))return true;
if(info.hasComponent(becsID!CInt) && info.hasComponent(becsID!CFloat) && !info.hasComponent(becsID!CLong) && !info.hasComponent(becsID!CDouble))return true;
if(info.hasComponent(becsID!CLong) && info.hasComponent(becsID!CDouble) && !info.hasComponent(becsID!CInt) && !info.hasComponent(becsID!CFloat))return true;
return false;
}
@ -1694,17 +1694,17 @@ unittest
gEM.endRegister();
EntityTemplate* tmpl_ = gEM.allocateTemplate([CInt.component_id, CLong.component_id, CFloat.component_id, CDouble.component_id].staticArray);
EntityTemplate* tmpl_ = gEM.allocateTemplate([becsID!CInt, becsID!CLong, becsID!CFloat, becsID!CDouble].staticArray);
scope(exit)gEM.freeTemplate(tmpl_);
EntityTemplate* tmpl_2 = gEM.allocateTemplate([CInt.component_id, CFloat.component_id].staticArray);
EntityTemplate* tmpl_2 = gEM.allocateTemplate([becsID!CInt, becsID!CFloat].staticArray);
scope(exit)gEM.freeTemplate(tmpl_2);
EntityTemplate* tmpl_3 = gEM.allocateTemplate([CLong.component_id, CDouble.component_id].staticArray);
EntityTemplate* tmpl_3 = gEM.allocateTemplate([becsID!CLong, becsID!CDouble].staticArray);
scope(exit)gEM.freeTemplate(tmpl_3);
EntityTemplate* tmpl_4 = gEM.allocateTemplate([CInt.component_id, CLong.component_id, CDouble.component_id].staticArray);
EntityTemplate* tmpl_4 = gEM.allocateTemplate([becsID!CInt, becsID!CLong, becsID!CDouble].staticArray);
scope(exit)gEM.freeTemplate(tmpl_4);
EntityTemplate* tmpl_5 = gEM.allocateTemplate([CInt.component_id, CDouble.component_id].staticArray);
EntityTemplate* tmpl_5 = gEM.allocateTemplate([becsID!CInt, becsID!CDouble].staticArray);
scope(exit)gEM.freeTemplate(tmpl_5);
EntityTemplate* tmpl_6 = gEM.allocateTemplate([CDouble.component_id].staticArray);
EntityTemplate* tmpl_6 = gEM.allocateTemplate([becsID!CDouble].staticArray);
scope(exit)gEM.freeTemplate(tmpl_6);
gEM.addEntity(tmpl_);

View file

@ -21,14 +21,14 @@ unittest
{
struct Event1
{
mixin ECS.Event;
// mixin ECS.Event;
EntityID id;
}
struct Event2
{
mixin ECS.Event;
// mixin ECS.Event;
}
struct System1
@ -45,7 +45,7 @@ unittest
void onCreate()
{
tmpl = gEM.allocateTemplate([CInt.component_id, CLong.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CInt, becsID!CLong].staticArray);
}
void onDestroy()
@ -118,7 +118,7 @@ unittest
gEM.endRegister();
EntityTemplate* tmpl = gEM.allocateTemplate([CInt.component_id, CLong.component_id].staticArray);
EntityTemplate* tmpl = gEM.allocateTemplate([becsID!CInt, becsID!CLong].staticArray);
EntityID id = gEM.addEntity(tmpl,[CLong(10).ref_, CInt(6).ref_].staticArray).id;
EntityID id2 = gEM.addEntity(tmpl,[CInt(4).ref_].staticArray).id;
gEM.freeTemplate(tmpl);
@ -126,13 +126,13 @@ unittest
gEM.sendEvent(id2, Event1(id));
gEM.getSystem(System2.system_id).disable();
gEM.getSystem(becsID!System2).disable();
gEM.begin();
gEM.update();
gEM.end();
gEM.getSystem(System2.system_id).enable();
gEM.getSystem(becsID!System2).enable();
gEM.begin();
gEM.update();

View file

@ -86,22 +86,22 @@ void afterEveryTest()
void smallTmpl()
{
tmpl = gEM.allocateTemplate([CShort.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CShort].staticArray);
}
void bigTmpl()
{
tmpl = gEM.allocateTemplate([CBig.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CBig].staticArray);
}
void multiSmallTmpl()
{
tmpl = gEM.allocateTemplate([CShort.component_id, CLong.component_id, CInt.component_id, CUInt.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
}
void multiBigTmpl()
{
tmpl = gEM.allocateTemplate([CLong.component_id, CInt.component_id, CUInt.component_id, CBig.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
}
@("AddEntities100k1comp2b") @(before, &smallTmpl)
@ -138,25 +138,25 @@ void allocDealloc100k()
void smallTmplPreAlloc()
{
tmpl = gEM.allocateTemplate([CShort.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CShort].staticArray);
allocDealloc100k();
}
void bigTmplPreAlloc()
{
tmpl = gEM.allocateTemplate([CBig.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CBig].staticArray);
allocDealloc100k();
}
void multiSmallTmplPreAlloc()
{
tmpl = gEM.allocateTemplate([CShort.component_id, CLong.component_id, CInt.component_id, CUInt.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CShort, becsID!CLong, becsID!CInt, becsID!CUInt].staticArray);
allocDealloc100k();
}
void multiBigTmplPreAlloc()
{
tmpl = gEM.allocateTemplate([CLong.component_id, CInt.component_id, CUInt.component_id, CBig.component_id].staticArray);
tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
allocDealloc100k();
}