bubel-ecs/source/ecs/core.d
Mergul 19687b9f88 -fixed critical bug with adding components
-some fixes
-minor optimization
-added debug assert test
2020-04-04 13:58:31 +02:00

76 lines
No EOL
2.3 KiB
D

/************************************************************************************************************************
*This module contain main templates for user.
*There are three structure templates (mixins) which should be added on top of structure:
* - System: make system structure
* - Component: make component structure
* - Event: make event structure
*
*ex.
*Struct System1
*{
* mixin!ECS.System;
*}
*
*Struct System2
*{
* mixin!ECS.System(16);//set number of jobs generated for system by multithreaded update
*}
*
*Struct Component1
*{
* mixin!ECS.Component;
*}
*
*Struct Event1
*{
* mixin!ECS.Event;
*}
*
*There is also template for generating list of excluded components "ExcludedComponets(T...)".
*This template takes component structure types and making list of excluded components used in "registerSystem" function.
*
*/
module ecs.core;
public import ecs.manager;
public import ecs.entity;
/************************************************************************************************************************
*Main struct used as namespace for templates.
*/
static struct ECS
{
/************************************************************************************************************************
*Mark structure as System. Should be added on top of structure (before any data).
*/
mixin template System(uint jobs_count = 32)
{
__gshared ushort system_id = ushort.max;
uint __ecs_jobs_count = jobs_count;
}
/************************************************************************************************************************
*Mark structure as Component. Should be added on top of structure (before any data).
*/
mixin template Component()
{
__gshared ushort component_id = ushort.max;
}
/************************************************************************************************************************
*Mark structure as Event. Should be added on top of structure (before any data).
*/
mixin template Event()
{
__gshared ushort event_id = ushort.max;
EntityID entity_id;
}
/************************************************************************************************************************
*Make list of excluded components. This template get structure types as argument. Should be added inside System structure.
*/
mixin template ExcludedComponents(T...)
{
alias ExcludedComponents = T;
}
}