-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

@ -35,7 +35,7 @@ struct Entity
*/
T* getComponent(T)() const
{
/*EntityManager.EntitiesBlock* block = gEM.getMetaData(&this);
/*EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
EntityManager.EntityInfo* info = block.type_info;
if (T.component_id >= info.deltas.length || info.deltas[T.component_id] == 0)
return null;
@ -46,17 +46,17 @@ struct Entity
void* getComponent(ushort component_id) const
{
EntityManager.EntitiesBlock* block = gEM.getMetaData(&this);
EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
EntityManager.EntityInfo* info = block.type_info;
if (component_id >= info.deltas.length || info.deltas[component_id] == 0)
return null;
return (cast(void*)block + info.deltas[component_id] + block.entityIndex(&this) * gEM.components[component_id].size);
return (cast(void*)block + info.deltas[component_id] + block.entityIndex(&this) * gEntityManager.components[component_id].size);
}
bool hasComponent(ushort component_id) const
{
EntityManager.EntitiesBlock* block = gEM.getMetaData(&this);
EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
EntityManager.EntityInfo* info = block.type_info;
if (component_id >= info.deltas.length || info.deltas[component_id] == 0)return false;
return true;
@ -65,7 +65,7 @@ struct Entity
EntityMeta getMeta() const
{
EntityMeta meta;
meta.block = gEM.getMetaData(&this);
meta.block = gEntityManager.getMetaData(&this);
meta.index = meta.block.entityIndex(&this);
return meta;
}
@ -92,7 +92,7 @@ struct EntityMeta
if (component_id >= info.deltas.length || info.deltas[component_id] == 0)
return null;
return (cast(void*)block + info.deltas[component_id] + index * gEM.components[component_id].size);
return (cast(void*)block + info.deltas[component_id] + index * gEntityManager.components[component_id].size);
}
bool hasComponent(ushort component_id) const