FIxed GDC compilation (basic betterC WIP) and some improvements
-fixed issue with adding/removing entities inside events handling -fixed EntityMeta.getComponent() (added check if component_id is valid) -added function hasComponent to entity to check if component exists
This commit is contained in:
parent
f731b4cedb
commit
9589a5cb2d
11 changed files with 174 additions and 94 deletions
|
|
@ -46,6 +46,14 @@ struct Entity
|
|||
return cast(T*)(cast(void*)block + info.deltas[T.component_id] + ind * T.sizeof);
|
||||
}
|
||||
|
||||
bool hasComponent(ushort component_id)
|
||||
{
|
||||
EntityManager.EntitiesBlock* block = gEM.getMetaData(&this);
|
||||
EntityManager.EntityInfo* info = block.type_info;
|
||||
if (component_id >= info.deltas.length || info.deltas[component_id] == 0)return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityMeta getMeta()
|
||||
{
|
||||
EntityMeta meta;
|
||||
|
|
@ -65,8 +73,18 @@ struct EntityMeta
|
|||
|
||||
T* getComponent(T)() const
|
||||
{
|
||||
const (EntityManager.EntityInfo)* info = block.type_info;
|
||||
if (T.component_id >= info.deltas.length || info.deltas[T.component_id] == 0)
|
||||
return null;
|
||||
return cast(T*)(cast(void*)block + block.type_info.deltas[T.component_id] + index * T.sizeof);
|
||||
}
|
||||
|
||||
bool hasComponent(ushort component_id)
|
||||
{
|
||||
EntityManager.EntityInfo* info = block.type_info;
|
||||
if (component_id >= info.deltas.length || info.deltas[component_id] == 0)return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue