-getComponent functions for Template and Entity
-error information about adding system with non existing component (prints name of system and component) -fill components in template with default values
This commit is contained in:
parent
4b19907c03
commit
624c899c8c
2 changed files with 30 additions and 5 deletions
|
|
@ -16,10 +16,22 @@ struct Entity
|
|||
{
|
||||
EntityManager.instance.id_manager.update(this);
|
||||
}
|
||||
|
||||
T* getComponent(T)()
|
||||
{
|
||||
EntityManager.EntitiesBlock* block = gEM.getMetaData(&this);
|
||||
EntityManager.EntityInfo* info = block.type_data;
|
||||
return cast(T*)(cast(void*)&this + info.deltas[T.component_id]);
|
||||
}
|
||||
}
|
||||
|
||||
struct EntityTemplate
|
||||
{
|
||||
ubyte[] entity_data;
|
||||
EntityManager.EntityInfo* info;
|
||||
|
||||
T* getComponent(T)()
|
||||
{
|
||||
return cast(T*)(entity_data.ptr + info.deltas[T.component_id]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue