-fixed optional components issue

This commit is contained in:
Mergul 2018-09-29 11:53:22 +02:00
parent c0ac19b6f9
commit 41a7f22cb3

View file

@ -150,8 +150,8 @@ class EntityManager
if (isPointer!param)
{
ret ~= "PointerTarget!(types[" ~ i.to!string
~ "])[] opt_array" ~ opt.to!string ~ ";";
ret ~= "if(info.deltas[types[" ~ i.to!string ~ "].component_id] != ushort.max)opt_array"
~ "])[] opt_array" ~ opt.to!string ~ " = null;";
ret ~= "if(info.deltas[types[" ~ i.to!string ~ "].component_id] != 0)opt_array"
~ opt.to!string ~ "
= (cast(types[" ~ i.to!string ~ "])(cast(void*)block + info.deltas[types["
~ i.to!string ~ "].component_id]))[0..block.entities_count];";
@ -266,7 +266,7 @@ class EntityManager
foreach (i, ref pointer; optional_pointers)
{
uint ind = cast(uint)(i + pointers.length);
if (data.deltas[ind] != uint.max)
if (data.deltas[ind] != 0)
pointer = data_pointer + data.deltas[ind];
else
pointer = null;