-added filterEntity callback (used to filter EntityInfos for system, better control than simply @optional)

-removed some redundant code (two times same code)
-added some common functions
This commit is contained in:
Mergul 2021-01-03 13:05:48 +01:00
parent 13c82acad4
commit 3c1c67efd0
4 changed files with 155 additions and 25 deletions

View file

@ -128,6 +128,15 @@ export struct EntityTemplate
if(T.component_id >= info.tmpl_deltas.length || info.tmpl_deltas[T.component_id] == ushort.max)return null;
return cast(T*)(entity_data.ptr + info.tmpl_deltas[T.component_id]);
}
/************************************************************************************************************************
Get specified component. If component doesn't exist function return null. Returned pointer is valid during EntityTemplate lifetime.
*/
void* getComponent(ushort component_id) const nothrow @nogc
{
if(component_id >= info.tmpl_deltas.length || info.tmpl_deltas[component_id] == ushort.max)return null;
return cast(void*)(entity_data.ptr + info.tmpl_deltas[component_id]);
}
}
/************************************************************************************************************************