-sorting components ids in systems

-changed callUpdate() prototype
This commit is contained in:
Mergul 2018-10-01 22:11:27 +02:00
parent 437c672478
commit 2004909642
2 changed files with 12 additions and 5 deletions

View file

@ -302,7 +302,7 @@ class EntityManager
return ret; return ret;
} }
static void callUpdate(ref CallData data, void* entity) static void callUpdate(ref CallData data)
{ {
Sys* s = cast(Sys*) data.system.m_system_pointer; Sys* s = cast(Sys*) data.system.m_system_pointer;
@ -354,6 +354,10 @@ class EntityManager
mixin(genCompList()); mixin(genCompList());
if(system.m_components)qsort(system.m_components.ptr, system.m_components.length, ushort.sizeof, &compareUShorts);
if(system.m_optional_components)qsort(system.m_optional_components.ptr, system.m_optional_components.length, ushort.sizeof, &compareUShorts);
if(system.m_absen_components)qsort(system.m_absen_components.ptr, system.m_absen_components.length, ushort.sizeof, &compareUShorts);
ushort sys_id = systems_map.get(Sys.stringof, ushort.max); ushort sys_id = systems_map.get(Sys.stringof, ushort.max);
if (sys_id < systems.length) if (sys_id < systems.length)
{ {
@ -493,7 +497,7 @@ class EntityManager
foreach (data; info.callers) foreach (data; info.callers)
{ {
if (data.system.enabled) if (data.system.enabled)
(cast(SytemFuncType) data.system.m_update)(data, null); //caller(call_data,null); (cast(SytemFuncType) data.system.m_update)(data); //caller(call_data,null);
} }
} }
} }
@ -1331,7 +1335,7 @@ class EntityManager
EntityManager.EntityInfo* info; EntityManager.EntityInfo* info;
} }
alias SytemFuncType = void function(ref EntityManager.CallData data, void* entity); alias SytemFuncType = void function(ref EntityManager.CallData data);
//alias sendSelfEvent = instance.event_manager.sendSelfEvent; //alias sendSelfEvent = instance.event_manager.sendSelfEvent;

View file

@ -63,8 +63,8 @@ package:
///optional components ///optional components
ushort[] m_optional_components; ushort[] m_optional_components;
//void function(ref EntityManager.CallData data, void* entity) update; void function(ref EntityManager.CallData data) m_update;
void* m_update; ///workaroud for DMD bug with upper line //void* m_update; ///workaroud for DMD bug with upper line
void function(void* system_pointer) m_enable; void function(void* system_pointer) m_enable;
void function(void* system_pointer) m_disable; void function(void* system_pointer) m_disable;
@ -74,4 +74,7 @@ package:
void function(void* system_pointer) m_begin; void function(void* system_pointer) m_begin;
void function(void* system_pointer) m_end; void function(void* system_pointer) m_end;
void function(ref EntityManager.CallData data) m_initialize;
void function(ref EntityManager.CallData data) m_deinitilize;
} }