-LinearLayout implemntation:
*Entity.getComponent works *adding/removing objects work *update work
This commit is contained in:
parent
535071ebb9
commit
cb9bac5dde
5 changed files with 411 additions and 120 deletions
|
|
@ -20,9 +20,21 @@ struct Entity
|
|||
T* getComponent(T)()
|
||||
{
|
||||
EntityManager.EntitiesBlock* block = gEM.getMetaData(&this);
|
||||
EntityManager.EntityInfo* info = block.type_data;
|
||||
if(T.component_id >= info.deltas.length || info.deltas[T.component_id] == 0)return null;
|
||||
return cast(T*)(cast(void*)&this + info.deltas[T.component_id]);
|
||||
EntityManager.EntityInfo* info = block.type_info;
|
||||
if (T.component_id >= info.deltas.length || info.deltas[T.component_id] == 0)
|
||||
return null;
|
||||
version (LinearLayout)
|
||||
{
|
||||
static if (EntityID.sizeof == 8)
|
||||
uint ind = cast(uint)((cast(void*)&this - block.dataBegin()) >> 3);
|
||||
else
|
||||
uint ind = cast(uint)((cast(void*)&this - block.dataBegin()) / EntityID.sizeof());
|
||||
return cast(T*)(cast(void*)block + info.deltas[T.component_id] + ind * T.sizeof);
|
||||
}
|
||||
else
|
||||
{
|
||||
return cast(T*)(cast(void*)&this + info.deltas[T.component_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue