-fillInputData created as local function in register process
-call onAdd (WIP)
This commit is contained in:
parent
6bbc8b5152
commit
3aad89fc56
2 changed files with 79 additions and 54 deletions
|
|
@ -566,8 +566,6 @@ class EntityManager
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static if (hasMember!(Sys, "update") && (mixin(genParamsChecking())))
|
|
||||||
{
|
|
||||||
static string genFillInputData()()
|
static string genFillInputData()()
|
||||||
{
|
{
|
||||||
string ret;
|
string ret;
|
||||||
|
|
@ -598,11 +596,11 @@ class EntityManager
|
||||||
{
|
{
|
||||||
if (att == "optional")
|
if (att == "optional")
|
||||||
{
|
{
|
||||||
ret ~= "if(data.system.m_optional_components[" ~ opt.to!string
|
ret ~= "if(system.m_optional_components[" ~ opt.to!string
|
||||||
~ "] < info.deltas.length && info.deltas[ data.system.m_optional_components["
|
~ "] < info.deltas.length && info.deltas[ system.m_optional_components["
|
||||||
~ opt.to!string ~ "]] != 0)input_data." ~ member
|
~ opt.to!string ~ "]] != 0)input_data." ~ member
|
||||||
~ " = (cast(ForeachType!(typeof(Sys.EntitiesData." ~ member
|
~ " = (cast(ForeachType!(typeof(Sys.EntitiesData." ~ member
|
||||||
~ "))*)(cast(void*) block + info.deltas[ data.system.m_optional_components["
|
~ "))*)(cast(void*) block + info.deltas[ system.m_optional_components["
|
||||||
~ opt.to!string ~ "]]))[offset .. entities_count];
|
~ opt.to!string ~ "]]))[offset .. entities_count];
|
||||||
else input_data."
|
else input_data."
|
||||||
~ member ~ " = null;";
|
~ member ~ " = null;";
|
||||||
|
|
@ -620,7 +618,7 @@ class EntityManager
|
||||||
if (!has_att)
|
if (!has_att)
|
||||||
{
|
{
|
||||||
ret ~= "input_data." ~ member ~ " = (cast(ForeachType!(typeof(Sys.EntitiesData." ~ member
|
ret ~= "input_data." ~ member ~ " = (cast(ForeachType!(typeof(Sys.EntitiesData." ~ member
|
||||||
~ "))*)(cast(void*) block + info.deltas[ data.system.m_components["
|
~ "))*)(cast(void*) block + info.deltas[ system.m_components["
|
||||||
~ req.to!string ~ "]]))[offset .. entities_count];";
|
~ req.to!string ~ "]]))[offset .. entities_count];";
|
||||||
req++;
|
req++;
|
||||||
}
|
}
|
||||||
|
|
@ -632,12 +630,21 @@ class EntityManager
|
||||||
|
|
||||||
//pragma(msg,genFillInputData);
|
//pragma(msg,genFillInputData);
|
||||||
|
|
||||||
|
static void fillInputData(ref Sys.EntitiesData input_data, EntityInfo* info, EntitiesBlock* block,
|
||||||
|
uint offset, uint entities_count, System* system)
|
||||||
|
{
|
||||||
|
mixin(genFillInputData());
|
||||||
|
}
|
||||||
|
|
||||||
|
static if (hasMember!(Sys, "update") && (mixin(genParamsChecking())))
|
||||||
|
{
|
||||||
static void callUpdate(ref CallData data)
|
static void callUpdate(ref CallData data)
|
||||||
{
|
{
|
||||||
Sys* s = cast(Sys*) data.system.m_system_pointer;
|
Sys* s = cast(Sys*) data.system.m_system_pointer;
|
||||||
|
|
||||||
Sys.EntitiesData input_data;
|
Sys.EntitiesData input_data;
|
||||||
EntityInfo* info = data.info; //block.type_info;
|
EntityInfo* info = data.info; //block.type_info;
|
||||||
|
System* system = data.system;
|
||||||
|
|
||||||
EntitiesBlock* block;
|
EntitiesBlock* block;
|
||||||
if (data.first_block)
|
if (data.first_block)
|
||||||
|
|
@ -667,7 +674,8 @@ class EntityManager
|
||||||
|
|
||||||
assert(entities_count <= block.entities_count && offset <= block.entities_count);
|
assert(entities_count <= block.entities_count && offset <= block.entities_count);
|
||||||
|
|
||||||
mixin(genFillInputData());
|
fillInputData(input_data, info, block, offset, entities_count, system);
|
||||||
|
//mixin(genFillInputData());
|
||||||
|
|
||||||
s.update(input_data);
|
s.update(input_data);
|
||||||
|
|
||||||
|
|
@ -1825,12 +1833,29 @@ class EntityManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void callAddEntityListeners(EntityInfo* info, EntitiesBlock* block, int entity_index)
|
||||||
|
{
|
||||||
|
foreach(listener;info.add_listeners)
|
||||||
|
{
|
||||||
|
System* system = &systems[listener];
|
||||||
|
(cast(void function (System*)) system.m_entity_added)(system);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateBlocks()
|
private void updateBlocks()
|
||||||
{
|
{
|
||||||
foreach (ref thread; threads)
|
foreach (ref thread; threads)
|
||||||
{
|
{
|
||||||
foreach (block; thread.blocks_to_update)
|
foreach (block; thread.blocks_to_update)
|
||||||
{
|
{
|
||||||
|
EntityInfo* info = block.type_info;
|
||||||
|
if(info.add_listeners)
|
||||||
|
{
|
||||||
|
foreach(i;block.entities_count..block.entities_count+block.added_count)
|
||||||
|
{
|
||||||
|
callAddEntityListeners(info,block,i);
|
||||||
|
}
|
||||||
|
}
|
||||||
block.entities_count += block.added_count;
|
block.entities_count += block.added_count;
|
||||||
if (block.entities_count > block.type_info.max_entities)
|
if (block.entities_count > block.type_info.max_entities)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ struct TestSystem
|
||||||
|
|
||||||
void onAdd(EntitiesData data)
|
void onAdd(EntitiesData data)
|
||||||
{
|
{
|
||||||
writeln("Entity added ID: ",data.entites[0].id);
|
//writeln("Entity added ID: ");//,data.entites[0].id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void onAdd()
|
/*void onAdd()
|
||||||
|
|
@ -120,7 +120,7 @@ struct TestSystem
|
||||||
|
|
||||||
void onRemove(EntitiesData data)
|
void onRemove(EntitiesData data)
|
||||||
{
|
{
|
||||||
writeln("Entity destroyed ID: ",data.entites[0].id);
|
//writeln("Entity destroyed ID: ",data.entites[0].id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onBegin()
|
bool onBegin()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue