-added more documentation
-remove update() function from entity -currently max supported components count is 64 per type
This commit is contained in:
parent
546b73c567
commit
845f468d59
10 changed files with 199 additions and 64 deletions
|
|
@ -1,27 +1,74 @@
|
|||
/************************************************************************************************************************
|
||||
*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;
|
||||
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;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************
|
||||
*Mark structure as Event. Should be added on top of structure (before any data).
|
||||
*/
|
||||
mixin template Event()
|
||||
{
|
||||
__gshared ushort event_id;
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue