bubel-ecs/source/ecs/system.d
Mergul b3dce6560a -suport system callback: onCreate, onDestroy, onBegin, onEnd
-support for optional Components for System
-Components IDs in Systems are now stored as ushorts
2018-09-16 22:40:55 +02:00

55 lines
1.1 KiB
D

module ecs.system;
import ecs.entity;
import ecs.manager;
struct System
{
bool enabled()
{
return m_enabled;
}
void enable()
{
if (!m_enabled && m_enable)
m_enable(m_system_pointer);
m_enabled = true;
}
void disable()
{
if (m_enabled && m_disable)
m_disable(m_system_pointer);
m_enabled = false;
}
int priority()
{
return m_priority;
}
package:
///should system update and catch events?
bool m_enabled = false;
///system priority
int m_priority;
///pointer to system implementation
void* m_system_pointer;
ushort[] m_components;
ushort[] m_optional_components;
//void function(ref EntityManager.CallData data, void* entity) update;
void* m_update; ///workaroud for DMD bug with upper line
void function(void* system_pointer) m_enable;
void function(void* system_pointer) m_disable;
void function(void* system_pointer) m_create;
void function(void* system_pointer) m_destroy;
void function(void* system_pointer) m_begin;
void function(void* system_pointer) m_end;
}