-fixed bug (Events was called before onAddEntity callback)

This commit is contained in:
Mergul 2019-10-30 19:41:21 +01:00
parent d0c3926316
commit 7fa41f7671

View file

@ -2235,14 +2235,17 @@ export struct EntityManager
{
EntityID entity_id = *cast(EntityID*) event_pointer;
Entity* entity = id_manager.getEntityPointer(entity_id);
call_data.block = getMetaData(entity);
call_data.id = call_data.block.entityIndex(entity);
foreach (caller; events[i].callers)
if(entity)
{
call_data.system_pointer = caller.system.m_system_pointer;
(cast(void function(ref EventCallData) nothrow @nogc) caller
.callback)(call_data);
call_data.block = getMetaData(entity);
call_data.id = call_data.block.entityIndex(entity);
foreach (caller; events[i].callers)
{
call_data.system_pointer = caller.system.m_system_pointer;
(cast(void function(ref EventCallData) nothrow @nogc) caller
.callback)(call_data);
}
}
event_pointer += events[i].size;
}
@ -2258,11 +2261,11 @@ export struct EntityManager
export void commit()
{
updateEvents();
id_manager.optimize();
updateBlocks();
removeEntities();
changeEntities();
updateEvents();
event_manager.clearEvents();
}