-some changes in registerSystem
This commit is contained in:
parent
a5eade669e
commit
8b24ecf7d1
1 changed files with 15 additions and 17 deletions
|
|
@ -325,6 +325,7 @@ class EntityManager
|
||||||
CompInfo[] optional;
|
CompInfo[] optional;
|
||||||
CompInfo[] mutable;
|
CompInfo[] mutable;
|
||||||
CompInfo[] req;
|
CompInfo[] req;
|
||||||
|
string entites_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void allocateSystemComponents(ComponentsIndices components_info)(ref System system)
|
static void allocateSystemComponents(ComponentsIndices components_info)(ref System system)
|
||||||
|
|
@ -363,8 +364,10 @@ class EntityManager
|
||||||
alias MemberType = typeof(__traits(getMember, Sys.EntitiesData, member));
|
alias MemberType = typeof(__traits(getMember, Sys.EntitiesData, member));
|
||||||
if (member == "length" || is(MemberType == Entity[]) || is(MemberType == const(Entity)[]))
|
if (member == "length" || is(MemberType == Entity[]) || is(MemberType == const(Entity)[]))
|
||||||
{
|
{
|
||||||
|
if(is(MemberType == Entity[]) || is(MemberType == const(Entity)[]))components_info.entites_array = member;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string name;
|
string name;
|
||||||
static if (isArray!MemberType)
|
static if (isArray!MemberType)
|
||||||
{ // Workaround. This code is never called with: not an array type, but compiler prints an error
|
{ // Workaround. This code is never called with: not an array type, but compiler prints an error
|
||||||
|
|
@ -451,6 +454,8 @@ class EntityManager
|
||||||
return components_info;
|
return components_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ComponentsIndices components_info = getComponentsInfo();
|
||||||
|
|
||||||
static void genCompList()(ref System system, ref HashMap!(const(char)[], ushort) components_map)
|
static void genCompList()(ref System system, ref HashMap!(const(char)[], ushort) components_map)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -469,7 +474,7 @@ class EntityManager
|
||||||
static assert(0, "EntitiesData members should be arrays of elements!");
|
static assert(0, "EntitiesData members should be arrays of elements!");
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ComponentsIndices components_info = getComponentsInfo();
|
//enum ComponentsIndices components_info = getComponentsInfo();
|
||||||
allocateSystemComponents!(components_info)(system);
|
allocateSystemComponents!(components_info)(system);
|
||||||
|
|
||||||
foreach (iii, comp_info; components_info.req)
|
foreach (iii, comp_info; components_info.req)
|
||||||
|
|
@ -508,23 +513,16 @@ class EntityManager
|
||||||
static void fillInputData(ref Sys.EntitiesData input_data, EntityInfo* info,
|
static void fillInputData(ref Sys.EntitiesData input_data, EntityInfo* info,
|
||||||
EntitiesBlock* block, uint offset, uint entities_count, System* system)
|
EntitiesBlock* block, uint offset, uint entities_count, System* system)
|
||||||
{
|
{
|
||||||
enum ComponentsIndices components_info = getComponentsInfo();
|
//enum ComponentsIndices components_info = getComponentsInfo();
|
||||||
static foreach (member; __traits(allMembers, Sys.EntitiesData))
|
|
||||||
{
|
|
||||||
static if (is(typeof(__traits(getMember, Sys.EntitiesData,
|
|
||||||
member)) == Entity[]) || is(typeof(__traits(getMember,
|
|
||||||
Sys.EntitiesData, member)) == const(Entity)[]))
|
|
||||||
{
|
|
||||||
__traits(getMember, input_data, member) = (cast(Entity*) block.dataBegin())[offset .. entities_count];
|
|
||||||
}
|
|
||||||
else static if (member == "length")
|
|
||||||
{
|
|
||||||
__traits(getMember, input_data, member) = cast(typeof(input_data.length))(entities_count - offset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
static if(components_info.entites_array)
|
||||||
|
{
|
||||||
|
__traits(getMember, input_data, components_info.entites_array) = (cast(Entity*) block.dataBegin())[offset .. entities_count];
|
||||||
|
}
|
||||||
|
|
||||||
|
static if(hasMember!(Sys.EntitiesData,"length"))
|
||||||
|
{
|
||||||
|
input_data.length = cast(typeof(input_data.length))(entities_count - offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static foreach (iii, comp_info; components_info.req)
|
static foreach (iii, comp_info; components_info.req)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue