-fixed issue with optional components in systems
This commit is contained in:
parent
8cb5d6ce62
commit
9511e1936e
1 changed files with 19 additions and 5 deletions
|
|
@ -457,8 +457,7 @@ class EntityManager
|
||||||
ushort[] deltas = (cast(ushort*) alloca(num * ushort.sizeof))[0 .. num];
|
ushort[] deltas = (cast(ushort*) alloca(num * ushort.sizeof))[0 .. num];
|
||||||
uint delta_id = 0;
|
uint delta_id = 0;
|
||||||
|
|
||||||
ushort[] cmp_array = system.m_components;
|
foreach (id; system.m_components)
|
||||||
add_deltas: foreach (id; cmp_array)
|
|
||||||
{
|
{
|
||||||
deltas[delta_id] = ushort.max;
|
deltas[delta_id] = ushort.max;
|
||||||
foreach (i2, id2; entity.components)
|
foreach (i2, id2; entity.components)
|
||||||
|
|
@ -478,12 +477,27 @@ class EntityManager
|
||||||
}
|
}
|
||||||
if (deltas is null)
|
if (deltas is null)
|
||||||
return;
|
return;
|
||||||
if (cmp_array.ptr == system.m_components.ptr)
|
|
||||||
|
foreach (id; system.m_optional_components)
|
||||||
{
|
{
|
||||||
cmp_array = system.m_optional_components;
|
deltas[delta_id] = ushort.max;
|
||||||
goto add_deltas;
|
foreach (i2, id2; entity.components)
|
||||||
|
{
|
||||||
|
if (id2 == id)
|
||||||
|
{
|
||||||
|
deltas[delta_id] = entity.deltas[id2];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*if (deltas[delta_id] == ushort.max)
|
||||||
|
{
|
||||||
|
deltas = null;
|
||||||
|
break;
|
||||||
|
}*/
|
||||||
|
delta_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
call_data.deltas = Mallocator.instance.makeArray(deltas); //Mallocator.instance.makeArray!ushort(system.m_components.length);
|
call_data.deltas = Mallocator.instance.makeArray(deltas); //Mallocator.instance.makeArray!ushort(system.m_components.length);
|
||||||
|
|
||||||
uint index = 0;
|
uint index = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue