-update README code example (to one that compile)

-remove Entity.instance and gEM, global manager is now gEntityManager
This commit is contained in:
Mergul 2021-03-02 19:44:18 +01:00
parent d1c48e4c5f
commit 3b954b732b
11 changed files with 617 additions and 604 deletions

View file

@ -54,26 +54,26 @@ EntityTemplate* tmpl;
void beforeEveryTest()
{
gEM.initialize(0);
gEntityManager.initialize(0);
gEM.beginRegister();
gEntityManager.beginRegister();
gEM.registerComponent!CLong;
gEM.registerComponent!CInt;
gEM.registerComponent!CUInt;
gEM.registerComponent!CBig;
gEntityManager.registerComponent!CLong;
gEntityManager.registerComponent!CInt;
gEntityManager.registerComponent!CUInt;
gEntityManager.registerComponent!CBig;
gEM.endRegister();
gEntityManager.endRegister();
tmpl = gEM.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
foreach(i; 0 .. 100_000)gEM.addEntity(tmpl);
tmpl = gEntityManager.allocateTemplate([becsID!CLong, becsID!CInt, becsID!CUInt, becsID!CBig].staticArray);
foreach(i; 0 .. 100_000)gEntityManager.addEntity(tmpl);
}
void afterEveryTest()
{
if(tmpl)gEM.freeTemplate(tmpl);
if(tmpl)gEntityManager.freeTemplate(tmpl);
tmpl = null;
gEM.destroy();
gEntityManager.destroy();
}
@("DirectAccess100k1comp")
@ -81,7 +81,7 @@ unittest
{
foreach(i;0..25000)
{
Entity* entity = gEM.getEntity(EntityID(i*4+1,0));
Entity* entity = gEntityManager.getEntity(EntityID(i*4+1,0));
CUInt* comp1 = entity.getComponent!CUInt;
comp1.value = 4;
}
@ -92,7 +92,7 @@ unittest
{
foreach(i;0..25000)
{
Entity* entity = gEM.getEntity(EntityID(i*4+1,0));
Entity* entity = gEntityManager.getEntity(EntityID(i*4+1,0));
CUInt* comp1 = entity.getComponent!CUInt;
comp1.value = 4;
CInt* comp2 = entity.getComponent!CInt;
@ -109,7 +109,7 @@ unittest
{
foreach(i;0..25000)
{
Entity* entity = gEM.getEntity(EntityID(i*4+1,0));
Entity* entity = gEntityManager.getEntity(EntityID(i*4+1,0));
EntityMeta meta = entity.getMeta();
CUInt* comp1 = meta.getComponent!CUInt;
comp1.value = 4;
@ -121,7 +121,7 @@ unittest
{
foreach(i;0..25000)
{
Entity* entity = gEM.getEntity(EntityID(i*4+1,0));
Entity* entity = gEntityManager.getEntity(EntityID(i*4+1,0));
EntityMeta meta = entity.getMeta();
CUInt* comp1 = meta.getComponent!CUInt;
comp1.value = 4;