-fixed small issue, now Template.getComponent should return null if component doesn't exist in template
This commit is contained in:
parent
0608fe6e89
commit
201681e4ca
2 changed files with 2 additions and 2 deletions
|
|
@ -65,7 +65,7 @@ export struct EntityTemplate
|
||||||
*/
|
*/
|
||||||
T* getComponent(T)() nothrow @nogc
|
T* getComponent(T)() nothrow @nogc
|
||||||
{
|
{
|
||||||
if(T.component_id >= info.tmpl_deltas.length)return null;
|
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]);
|
return cast(T*)(entity_data.ptr + info.tmpl_deltas[T.component_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1171,7 +1171,7 @@ class EntityManager
|
||||||
info.size = EntityID.sizeof;
|
info.size = EntityID.sizeof;
|
||||||
info.alignment = EntityID.alignof;
|
info.alignment = EntityID.alignof;
|
||||||
|
|
||||||
info.tmpl_deltas = Mallocator.instance.makeArray!ushort(ids[$ - 1] + 1);
|
info.tmpl_deltas = Mallocator.instance.makeArray!ushort(ids[$ - 1] + 1,ushort.max);
|
||||||
uint components_size = EntityID.sizeof;
|
uint components_size = EntityID.sizeof;
|
||||||
|
|
||||||
foreach (i, id; ids)
|
foreach (i, id; ids)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue