-fixed issue with ExcludedComponents as enum or alias
-removed way to add excluded component by adding attribiute @excluded (it's very stupid way)
This commit is contained in:
parent
fe158e1b60
commit
9220a28f7c
3 changed files with 23 additions and 28 deletions
|
|
@ -2,7 +2,7 @@ module ecs.attributes;
|
|||
|
||||
///Used to mark optional components for system.
|
||||
enum optional = "optional";
|
||||
///Used to mark components excluded from update for system. Enum 'ExcludedComponents' should be used instead of it.
|
||||
enum excluded = "excluded";
|
||||
//Used to mark components excluded from update for system. Enum 'ExcludedComponents' should be used instead of it.
|
||||
//enum excluded = "excluded";
|
||||
///Used to mark readonly components for system. "const" can be used insted.
|
||||
enum readonly = "readonly";
|
||||
|
|
@ -349,16 +349,16 @@ class EntityManager
|
|||
|
||||
}
|
||||
|
||||
bool checkExcludedComponentsSomething(Sys)()
|
||||
{
|
||||
return __traits(compiles, allSameType!(string, typeof(Sys.ExcludedComponents))) && allSameType!(string,
|
||||
typeof(Sys.ExcludedComponents)) && isExpressions!(Sys.ExcludedComponents);
|
||||
}
|
||||
|
||||
static ComponentsIndices getComponentsInfo()
|
||||
{
|
||||
ComponentsIndices components_info;
|
||||
|
||||
bool checkExcludedComponentsSomething(Sys)()
|
||||
{
|
||||
return __traits(compiles, allSameType!(string, typeof(Sys.ExcludedComponents))) && allSameType!(string,
|
||||
typeof(Sys.ExcludedComponents)) && isExpressions!(Sys.ExcludedComponents);
|
||||
}
|
||||
|
||||
foreach (member; __traits(allMembers, Sys.EntitiesData))
|
||||
{
|
||||
alias MemberType = typeof(__traits(getMember, Sys.EntitiesData, member));
|
||||
|
|
@ -375,7 +375,7 @@ class EntityManager
|
|||
}
|
||||
|
||||
bool is_optional;
|
||||
bool is_excluded;
|
||||
//bool is_excluded;
|
||||
bool is_read_only;
|
||||
|
||||
if (is(CopyConstness!(ForeachType!(MemberType), int) == const(int)))
|
||||
|
|
@ -389,10 +389,10 @@ class EntityManager
|
|||
{
|
||||
is_optional = true;
|
||||
}
|
||||
else if (att == "excluded")
|
||||
/*else if (att == "excluded")
|
||||
{
|
||||
is_excluded = true;
|
||||
}
|
||||
}*/
|
||||
if (att == "readonly")
|
||||
{
|
||||
is_read_only = true;
|
||||
|
|
@ -406,10 +406,10 @@ class EntityManager
|
|||
{
|
||||
components_info.mutable ~= CompInfo(member,name);
|
||||
}
|
||||
if (is_excluded)
|
||||
/*if (is_excluded)
|
||||
{
|
||||
components_info.excluded ~= CompInfo(member,name);
|
||||
}
|
||||
}*/
|
||||
if (is_optional)
|
||||
{
|
||||
components_info.optional ~= CompInfo(member,name);
|
||||
|
|
@ -418,13 +418,13 @@ class EntityManager
|
|||
{
|
||||
components_info.readonly ~= CompInfo(member,name);
|
||||
}
|
||||
if (is_excluded == false && is_optional == false)
|
||||
if (/*is_excluded == false &&*/ is_optional == false)
|
||||
{ //is Req
|
||||
components_info.req ~= CompInfo(member,name);
|
||||
}
|
||||
|
||||
assert(!(is_optional && is_excluded),
|
||||
"EntitiesData member can't have both \"@optional\" and \"@excluded\".");
|
||||
/*assert(!(is_optional && is_excluded),
|
||||
"EntitiesData member can't have both \"@optional\" and \"@excluded\".");*/
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -432,21 +432,16 @@ class EntityManager
|
|||
{
|
||||
static if (is(Sys.ExcludedComponents == enum))
|
||||
{
|
||||
foreach (str; Fields!(Sys.ExcludedComponents))
|
||||
foreach (str; __traits(allMembers, Sys.ExcludedComponents))
|
||||
{
|
||||
ComponentInfo info;
|
||||
info.is_excluded = true;
|
||||
info.name = str.stringof;
|
||||
components_info.excluded ~= CompInfo(str,str);
|
||||
}
|
||||
}
|
||||
else static if (checkExcludedComponentsSomething!Sys)
|
||||
{
|
||||
foreach (str; Sys.ExcludedComponents)
|
||||
{
|
||||
ComponentInfo info;
|
||||
info.is_excluded = true;
|
||||
info.name = str;
|
||||
|
||||
components_info.excluded ~= CompInfo(str,str);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue