diff --git a/source/ecs/manager.d b/source/ecs/manager.d index 4cdb8e7..9b4c724 100644 --- a/source/ecs/manager.d +++ b/source/ecs/manager.d @@ -457,8 +457,7 @@ class EntityManager ushort[] deltas = (cast(ushort*) alloca(num * ushort.sizeof))[0 .. num]; uint delta_id = 0; - ushort[] cmp_array = system.m_components; - add_deltas: foreach (id; cmp_array) + foreach (id; system.m_components) { deltas[delta_id] = ushort.max; foreach (i2, id2; entity.components) @@ -478,12 +477,27 @@ class EntityManager } if (deltas is null) return; - if (cmp_array.ptr == system.m_components.ptr) + + foreach (id; system.m_optional_components) { - cmp_array = system.m_optional_components; - goto add_deltas; + deltas[delta_id] = ushort.max; + 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); uint index = 0;