-renamed callbacks:
*onAdd -> onAddEntity *onRemove -> onRemoveEntity *update -> onUpdate
This commit is contained in:
parent
d118adc028
commit
7a33e4f94f
3 changed files with 30 additions and 30 deletions
|
|
@ -95,7 +95,7 @@ class EntityManager
|
||||||
{
|
{
|
||||||
if (system.m_update is null)
|
if (system.m_update is null)
|
||||||
{
|
{
|
||||||
if (system.m_entity_added || system.m_entity_removed)
|
if (system.m_add_entity || system.m_remove_entity)
|
||||||
{
|
{
|
||||||
foreach (info; &entities_infos.byValue)
|
foreach (info; &entities_infos.byValue)
|
||||||
{
|
{
|
||||||
|
|
@ -570,7 +570,7 @@ class EntityManager
|
||||||
string genParamsChecking()()
|
string genParamsChecking()()
|
||||||
{
|
{
|
||||||
string ret;
|
string ret;
|
||||||
foreach (func; __traits(getOverloads, Sys, "update"))
|
foreach (func; __traits(getOverloads, Sys, "onUpdate"))
|
||||||
{
|
{
|
||||||
if ((Parameters!(func)).length == 1)
|
if ((Parameters!(func)).length == 1)
|
||||||
ret ~= "\"" ~ (fullyQualifiedName!(Sys.EntitiesData)) ~ "\" == \"" ~ (
|
ret ~= "\"" ~ (fullyQualifiedName!(Sys.EntitiesData)) ~ "\" == \"" ~ (
|
||||||
|
|
@ -650,7 +650,7 @@ class EntityManager
|
||||||
mixin(genFillInputData());
|
mixin(genFillInputData());
|
||||||
}
|
}
|
||||||
|
|
||||||
static if (hasMember!(Sys, "update") && (mixin(genParamsChecking())))
|
static if (hasMember!(Sys, "onUpdate") && (mixin(genParamsChecking())))
|
||||||
{
|
{
|
||||||
static void callUpdate(ref CallData data)
|
static void callUpdate(ref CallData data)
|
||||||
{
|
{
|
||||||
|
|
@ -691,7 +691,7 @@ class EntityManager
|
||||||
fillInputData(input_data, info, block, offset, entities_count, system);
|
fillInputData(input_data, info, block, offset, entities_count, system);
|
||||||
//mixin(genFillInputData());
|
//mixin(genFillInputData());
|
||||||
|
|
||||||
s.update(input_data);
|
s.onUpdate(input_data);
|
||||||
|
|
||||||
block = block.next_block;
|
block = block.next_block;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
@ -759,8 +759,8 @@ class EntityManager
|
||||||
mixin(catchFunc!(bool)("m_begin", "onBegin"));
|
mixin(catchFunc!(bool)("m_begin", "onBegin"));
|
||||||
mixin(catchFunc("m_end", "onEnd"));
|
mixin(catchFunc("m_end", "onEnd"));
|
||||||
|
|
||||||
mixin(catchEntityFunc("m_entity_added", "onAdd"));
|
mixin(catchEntityFunc("m_add_entity", "onAddEntity"));
|
||||||
mixin(catchEntityFunc("m_entity_removed", "onRemove"));
|
mixin(catchEntityFunc("m_remove_entity", "onRemoveEntity"));
|
||||||
|
|
||||||
system.m_system_pointer = cast(void*) Mallocator.instance.make!Sys;
|
system.m_system_pointer = cast(void*) Mallocator.instance.make!Sys;
|
||||||
system.m_priority = priority;
|
system.m_priority = priority;
|
||||||
|
|
@ -1210,10 +1210,10 @@ class EntityManager
|
||||||
|
|
||||||
foreach (i, ref system; systems)
|
foreach (i, ref system; systems)
|
||||||
{
|
{
|
||||||
//if(system.m_entity_added || system.m_entity_removed)info.systems[system.id] = true;
|
//if(system.m_add_entity || system.m_remove_entity)info.systems[system.id] = true;
|
||||||
if (system.m_update is null)
|
if (system.m_update is null)
|
||||||
{
|
{
|
||||||
if (system.m_entity_added || system.m_entity_removed)
|
if (system.m_add_entity || system.m_remove_entity)
|
||||||
connectListenerToEntityInfo(*info, cast(uint) i);
|
connectListenerToEntityInfo(*info, cast(uint) i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -1253,7 +1253,7 @@ class EntityManager
|
||||||
{
|
{
|
||||||
System* system = &systems[i];
|
System* system = &systems[i];
|
||||||
//onAddEntity listener
|
//onAddEntity listener
|
||||||
if (system.m_entity_added)
|
if (system.m_add_entity)
|
||||||
{
|
{
|
||||||
//find listener position by priority
|
//find listener position by priority
|
||||||
int j;
|
int j;
|
||||||
|
|
@ -1272,7 +1272,7 @@ class EntityManager
|
||||||
tmp_add[j] = cast(ushort) i;
|
tmp_add[j] = cast(ushort) i;
|
||||||
}
|
}
|
||||||
//onRemoveEntity listener
|
//onRemoveEntity listener
|
||||||
if (system.m_entity_removed)
|
if (system.m_remove_entity)
|
||||||
{
|
{
|
||||||
//find listener position by priority
|
//find listener position by priority
|
||||||
int j;
|
int j;
|
||||||
|
|
@ -2002,7 +2002,7 @@ class EntityManager
|
||||||
data.block = block;
|
data.block = block;
|
||||||
data.begin = begin;
|
data.begin = begin;
|
||||||
data.end = end;
|
data.end = end;
|
||||||
(cast(void function(ref ListenerCallData) nothrow @nogc) system.m_entity_added)(data);
|
(cast(void function(ref ListenerCallData) nothrow @nogc) system.m_add_entity)(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callRemoveEntityListeners(EntityInfo* info, EntitiesBlock* block, int begin,
|
private void callRemoveEntityListeners(EntityInfo* info, EntitiesBlock* block, int begin,
|
||||||
|
|
@ -2023,7 +2023,7 @@ class EntityManager
|
||||||
data.block = block;
|
data.block = block;
|
||||||
data.begin = begin;
|
data.begin = begin;
|
||||||
data.end = end;
|
data.end = end;
|
||||||
(cast(void function(ref ListenerCallData) nothrow @nogc) system.m_entity_removed)(data);
|
(cast(void function(ref ListenerCallData) nothrow @nogc) system.m_remove_entity)(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBlocks()
|
private void updateBlocks()
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,15 @@ import ecs.manager;
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*System contain data required to proper glue EntityManager with Systems.
|
*System contain data required to proper glue EntityManager with Systems.
|
||||||
*System callbacks:
|
*System callbacks:
|
||||||
*<br/>-void update(EntitesData);
|
*<br/>-void onUpdate(EntitesData);
|
||||||
*<br/>-void onEnable()
|
*<br/>-void onEnable()
|
||||||
*<br/>-void onDisable();
|
*<br/>-void onDisable();
|
||||||
*<br/>-bool onBegin();
|
*<br/>-bool onBegin();
|
||||||
*<br/>-void onEnd();
|
*<br/>-void onEnd();
|
||||||
*<br/>-void onCreate()
|
*<br/>-void onCreate()
|
||||||
*<br/>-void onDestroy();
|
*<br/>-void onDestroy();
|
||||||
*<br/>-void onAdd(EntitesData);
|
*<br/>-void onAddEntity(EntitesData);
|
||||||
*<br/>-void onRemove(EntitiesData);
|
*<br/>-void onRemoveEntity(EntitiesData);
|
||||||
*/
|
*/
|
||||||
struct System
|
struct System
|
||||||
{
|
{
|
||||||
|
|
@ -135,8 +135,8 @@ package:
|
||||||
void* m_begin;
|
void* m_begin;
|
||||||
void* m_end;
|
void* m_end;
|
||||||
|
|
||||||
void* m_entity_added;
|
void* m_add_entity;
|
||||||
void* m_entity_removed;
|
void* m_remove_entity;
|
||||||
|
|
||||||
//void function(ref EntityManager.CallData data) m_initialize;
|
//void function(ref EntityManager.CallData data) m_initialize;
|
||||||
//void function(ref EntityManager.CallData data) m_deinitilize;
|
//void function(ref EntityManager.CallData data) m_deinitilize;
|
||||||
|
|
|
||||||
|
|
@ -108,13 +108,13 @@ struct ChangeTestSystem
|
||||||
writeln("On Change Test System destroy.");
|
writeln("On Change Test System destroy.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAdd(EntitiesData data)
|
void onAddEntity(EntitiesData data)
|
||||||
{
|
{
|
||||||
foreach(i;0..data.length)
|
foreach(i;0..data.length)
|
||||||
writeln("Entity added ID: ",data.entites[i].id.id);
|
writeln("Entity added ID: ",data.entites[i].id.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onRemove(EntitiesData data)
|
void onRemoveEntity(EntitiesData data)
|
||||||
{
|
{
|
||||||
writeln("Entity removed ID: ",data.entites[0].id);
|
writeln("Entity removed ID: ",data.entites[0].id);
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +142,7 @@ struct ChangeTestSystem
|
||||||
TestComp4[] test4;
|
TestComp4[] test4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(EntitiesData data)
|
void onUpdate(EntitiesData data)
|
||||||
{
|
{
|
||||||
foreach(i;0..data.length)
|
foreach(i;0..data.length)
|
||||||
{
|
{
|
||||||
|
|
@ -165,13 +165,13 @@ struct TestSystem
|
||||||
writeln("On Test System destroy.");
|
writeln("On Test System destroy.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAdd(EntitiesData data)
|
void onAddEntity(EntitiesData data)
|
||||||
{
|
{
|
||||||
//foreach(i;0..data.length)
|
//foreach(i;0..data.length)
|
||||||
//writeln("Entity added ID: ",data.entites[i].id.id);
|
//writeln("Entity added ID: ",data.entites[i].id.id);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
void onRemove(EntitiesData data)
|
void onRemoveEntity(EntitiesData data)
|
||||||
{
|
{
|
||||||
//writeln("Entity destroyed ID: ",data.entites[0].id);
|
//writeln("Entity destroyed ID: ",data.entites[0].id);
|
||||||
}*/
|
}*/
|
||||||
|
|
@ -202,7 +202,7 @@ struct TestSystem
|
||||||
//@excluded TestComp4[] test4;
|
//@excluded TestComp4[] test4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(ref Entity entity, ref TestComp test, ref TestComp2 test2)//, TestComp3* test3) //ref TestComp comp)
|
void onUpdate(ref Entity entity, ref TestComp test, ref TestComp2 test2)//, TestComp3* test3) //ref TestComp comp)
|
||||||
{
|
{
|
||||||
assert(cast(size_t)&test % TestComp.alignof == 0);
|
assert(cast(size_t)&test % TestComp.alignof == 0);
|
||||||
assert(cast(size_t)&test2 % TestComp2.alignof == 0);
|
assert(cast(size_t)&test2 % TestComp2.alignof == 0);
|
||||||
|
|
@ -214,7 +214,7 @@ struct TestSystem
|
||||||
test2.a = 8;
|
test2.a = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(EntitiesData data)
|
void onUpdate(EntitiesData data)
|
||||||
{
|
{
|
||||||
foreach(i;0..data.length)
|
foreach(i;0..data.length)
|
||||||
{
|
{
|
||||||
|
|
@ -245,7 +245,7 @@ struct TestSystemWithHighPriority
|
||||||
int o = 1;
|
int o = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(EntitiesData data)
|
void onUpdate(EntitiesData data)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +265,7 @@ struct Sys1
|
||||||
TestComp[] comp;
|
TestComp[] comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAdd(EntitiesData data)
|
void onAddEntity(EntitiesData data)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -280,7 +280,7 @@ struct Sys2
|
||||||
TestComp[] comp;
|
TestComp[] comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAdd(EntitiesData data)
|
void onAddEntity(EntitiesData data)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -295,12 +295,12 @@ struct Sys3
|
||||||
TestComp[] comp;
|
TestComp[] comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAdd(EntitiesData data)
|
void onAddEntity(EntitiesData data)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(EntitiesData data)
|
void onUpdate(EntitiesData data)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -370,7 +370,7 @@ struct TestSystem2
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(EntitiesData data)
|
void onUpdate(EntitiesData data)
|
||||||
{
|
{
|
||||||
foreach(i;0..data.test.length)
|
foreach(i;0..data.test.length)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue