More test and fixes:
-added test for addEntityCopy -test order of onAddEntity, onRemoveEntity, onChangeEntity callbacks calls -testing onAddEntity, onRemoveEntity, onChangeEntity callback -test callEntityFunction call -fixed bug with crashing ECS (setting callers for entity change callbacks) -commented debug asserts conering duplicated components ids (to further consideration)
This commit is contained in:
parent
cb9eaad123
commit
f7a1e9bd05
2 changed files with 250 additions and 22 deletions
|
|
@ -1187,7 +1187,7 @@ export struct EntityManager
|
|||
(cast(Ev*) pointer).onDestroy();
|
||||
}
|
||||
|
||||
info.destroy_callback = &callDestroy;
|
||||
info.destroy_callback = cast(void function(void*) nothrow @nogc)&callDestroy;
|
||||
}
|
||||
|
||||
info.size = Ev.sizeof;
|
||||
|
|
@ -1214,7 +1214,7 @@ export struct EntityManager
|
|||
"Can't call function with system which hasn't EntitesData structure.");
|
||||
static assert(__traits(hasMember, Sys, "onUpdate"),
|
||||
"Can't call function with system which hasn't onUpdate function callback.");
|
||||
static assert(is(T == typeof(&s.onUpdate)), "Function must match system update function.");
|
||||
static assert(is(SetFunctionAttributes!(T,functionLinkage!(s.onUpdate), functionAttributes!(s.onUpdate)) == typeof(&s.onUpdate)), "Function must match system update function.");
|
||||
static assert(__traits(hasMember, Sys, "system_id"), "Sys must be system type.");
|
||||
|
||||
System* system = getSystem(Sys.system_id);
|
||||
|
|
@ -1527,8 +1527,8 @@ export struct EntityManager
|
|||
ids[j] = ids[i];
|
||||
j++;
|
||||
}
|
||||
else
|
||||
debug assert(0, "Duplicated components in template!!!");
|
||||
//else
|
||||
// debug assert(0, "Duplicated components in template!!!");
|
||||
}
|
||||
ids = ids[0 .. j];
|
||||
}
|
||||
|
|
@ -1544,8 +1544,6 @@ export struct EntityManager
|
|||
{
|
||||
memcpy(temp.entity_data.ptr + info.tmpl_deltas[comp],
|
||||
components[comp].init_data.ptr, components[comp].size);
|
||||
/*temp.entity_data[info.tmpl_deltas[comp] .. info.tmpl_deltas[comp] + components[comp].size]
|
||||
= components[comp].init_data;*/
|
||||
}
|
||||
|
||||
return temp;
|
||||
|
|
@ -1593,8 +1591,8 @@ export struct EntityManager
|
|||
ids[j] = ids[i];
|
||||
j++;
|
||||
}
|
||||
else
|
||||
debug assert(0, "Duplicated components in template!!!");
|
||||
//else
|
||||
// debug assert(0, "Duplicated components in template!!!");
|
||||
}
|
||||
ids = ids[0 .. j];
|
||||
}
|
||||
|
|
@ -1747,7 +1745,7 @@ export struct EntityManager
|
|||
int j;
|
||||
for (j = 0; j < add_len; j++)
|
||||
{
|
||||
if (systems[i].priority > systems[tmp_add[j]].priority)
|
||||
if (systems[i].priority < systems[tmp_add[j]].priority)
|
||||
break;
|
||||
}
|
||||
add_len++;
|
||||
|
|
@ -1767,7 +1765,7 @@ export struct EntityManager
|
|||
int j;
|
||||
for (j = 0; j < rem_len; j++)
|
||||
{
|
||||
if (systems[i].priority > systems[tmp_rem[j]].priority)
|
||||
if (systems[i].priority < systems[tmp_rem[j]].priority)
|
||||
break;
|
||||
}
|
||||
rem_len++;
|
||||
|
|
@ -1787,7 +1785,7 @@ export struct EntityManager
|
|||
int j;
|
||||
for (j = 0; j < ch_len; j++)
|
||||
{
|
||||
if (systems[i].priority > systems[tmp_ch[j]].priority)
|
||||
if (systems[i].priority < systems[tmp_ch[j]].priority)
|
||||
break;
|
||||
}
|
||||
ch_len++;
|
||||
|
|
@ -2727,6 +2725,7 @@ export struct EntityManager
|
|||
call_data);
|
||||
}
|
||||
}
|
||||
if(events[i].destroy_callback)events[i].destroy_callback(event_pointer);
|
||||
event_pointer += events[i].size;
|
||||
}
|
||||
block = block.next;
|
||||
|
|
@ -2957,7 +2956,7 @@ export struct EntityManager
|
|||
ushort size;
|
||||
ushort alignment;
|
||||
EventCaller[] callers;
|
||||
void function(void* pointer) destroy_callback;
|
||||
void function(void* pointer) nothrow @nogc destroy_callback;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue