-add systemCaller to entity only if their components matches

-System onEnable() and onDisable() callbacks
This commit is contained in:
Mergul 2018-09-12 14:28:32 +02:00
parent 22fdd2f4e4
commit ae53e13d42
4 changed files with 152 additions and 78 deletions

View file

@ -6,7 +6,7 @@ import ecs.manager;
struct System
{
///should system update and catch events?
bool enabled = true;
bool m_enabled = false;
///system priority
int prority;
///pointer to system implementation
@ -14,5 +14,26 @@ struct System
uint[] components;
void function(ref EntityManager.CallData data, void* entity) update;
bool enabled()
{
return m_enabled;
}
void enable()
{
if(!m_enabled && m_enable)m_enable(system_pointer);
m_enabled = true;
}
void disable()
{
if(m_enabled && m_disable)m_disable(system_pointer);
m_enabled = false;
}
//void function(ref EntityManager.CallData data, void* entity) update;
void* update; ///workaroud for DMD bug with upper line
void function(void* system_pointer) m_enable;
void function(void* system_pointer) m_disable;
}