diff --git a/source/ecs/attributes.d b/source/ecs/attributes.d index 69667ec..4068a06 100644 --- a/source/ecs/attributes.d +++ b/source/ecs/attributes.d @@ -2,5 +2,5 @@ module ecs.attributes; ///Used to mark optional components for system. enum optional = "optional"; -///Used to mark absen components for system. Enum 'AbsenComponents' should be used instead of it. -enum absen = "absen"; \ No newline at end of file +///Used to mark absent components for system. Enum 'AbsentComponents' should be used instead of it. +enum absent = "absent"; \ No newline at end of file diff --git a/source/ecs/manager.d b/source/ecs/manager.d index c315979..95a31d6 100644 --- a/source/ecs/manager.d +++ b/source/ecs/manager.d @@ -99,11 +99,11 @@ class EntityManager static assert(0, "EntitiesData members should be arrays of elements!"); } - string ret;// = "ushort comp;uint req;uint opt;uint absen;"; + string ret;// = "ushort comp;uint req;uint opt;uint absent;"; uint req; uint opt; - uint absen; + uint absent; foreach (member; __traits(allMembers, Sys.EntitiesData)) { if (member == "length" || is(typeof(__traits(getMember, Sys.EntitiesData, @@ -126,9 +126,9 @@ class EntityManager has_att = true; break; } - else if (att == "absen") + else if (att == "absent") { - absen++; + absent++; //ret ~= "absen++;"; has_att = true; break; @@ -140,39 +140,39 @@ class EntityManager } } - static if(__traits(hasMember, Sys, "AbsenComponents")) + static if(__traits(hasMember, Sys, "AbsentComponents")) { - static if(is(Sys.AbsenComponents == enum)) + static if(is(Sys.AbsentComponents == enum)) { - absen += (Fields!(Sys.AbsenComponents)).length;//static assert(0,"Enum AbsenComponents are not implemented yet."); + absent += (Fields!(Sys.AbsentComponents)).length;//static assert(0,"Enum AbsentComponents are not implemented yet."); } - else static if(__traits(compiles,allSameType!(string,typeof(Sys.AbsenComponents))) && allSameType!(string,typeof(Sys.AbsenComponents)) && - isExpressions!(Sys.AbsenComponents)) + else static if(__traits(compiles,allSameType!(string,typeof(Sys.AbsentComponents))) && allSameType!(string,typeof(Sys.AbsentComponents)) && + isExpressions!(Sys.AbsentComponents)) { - absen += Sys.AbsenComponents.length; + absent += Sys.AbsentComponents.length; } } if(req > 0)ret ~= "system.m_components = Mallocator.instance.makeArray!ushort("~req.to!string~");"; if(opt > 0)ret ~= "system.m_optional_components = Mallocator.instance.makeArray!ushort("~opt.to!string~");"; - if(absen > 0)ret ~= "system.m_absen_components = Mallocator.instance.makeArray!ushort("~absen.to!string~");"; - ret ~= "ushort comp;";//uint opt = 0;uint req = 0;uint absen = 0;"; + if(absent > 0)ret ~= "system.m_absent_components = Mallocator.instance.makeArray!ushort("~absent.to!string~");"; + ret ~= "ushort comp;";//uint opt = 0;uint req = 0;uint absent = 0;"; opt = 0; req = 0; - absen = 0; + absent = 0; - static if(__traits(hasMember, Sys, "AbsenComponents")) + static if(__traits(hasMember, Sys, "AbsentComponents")) { - static if(is(Sys.AbsenComponents == enum)) + static if(is(Sys.AbsentComponents == enum)) { - //static assert(0,"Enum AbsenComponents are not implemented yet."); - foreach(str;Fields!(Sys.AbsenComponents))ret ~= "system.m_absen_components["~(absen++).to!string~"] = components_map.get(\""~str.stringof~"\", ushort.max);"; + //static assert(0,"Enum AbsentComponents are not implemented yet."); + foreach(str;Fields!(Sys.AbsentComponents))ret ~= "system.m_absent_components["~(absent++).to!string~"] = components_map.get(\""~str.stringof~"\", ushort.max);"; } - else static if(__traits(compiles,allSameType!(string,typeof(Sys.AbsenComponents))) && allSameType!(string,typeof(Sys.AbsenComponents)) && - isExpressions!(Sys.AbsenComponents)) + else static if(__traits(compiles,allSameType!(string,typeof(Sys.AbsentComponents))) && allSameType!(string,typeof(Sys.AbsentComponents)) && + isExpressions!(Sys.AbsentComponents)) { - foreach(str;Sys.AbsenComponents)ret ~= "system.m_absen_components["~(absen++).to!string~"] = components_map.get(\""~str~"\", ushort.max);"; + foreach(str;Sys.AbsentComponents)ret ~= "system.m_absent_components["~(absent++).to!string~"] = components_map.get(\""~str~"\", ushort.max);"; } } @@ -208,9 +208,9 @@ class EntityManager has_att = true; break; } - else if (att == "absen") + else if (att == "absent") { - ret ~= "system.m_absen_components["~(absen++).to!string~"] = comp;}"; + ret ~= "system.m_absent_components["~(absent++).to!string~"] = comp;}"; has_att = true; break; } @@ -246,7 +246,7 @@ class EntityManager ushort comp; uint req = 0; uint opt = 0; - uint absen = 0; + uint absent = 0; foreach (member; __traits(allMembers, Sys.EntitiesData)) { if (is(typeof(__traits(getMember, Sys.EntitiesData, @@ -282,9 +282,9 @@ class EntityManager has_att = true; break; } - else if (att == "absen") + else if (att == "absent") { - absen++; + absent++; has_att = true; break; } @@ -354,9 +354,9 @@ class EntityManager mixin(genCompList()); - if(system.m_components)qsort(system.m_components.ptr, system.m_components.length, ushort.sizeof, &compareUShorts); + /*if(system.m_components)qsort(system.m_components.ptr, system.m_components.length, ushort.sizeof, &compareUShorts); if(system.m_optional_components)qsort(system.m_optional_components.ptr, system.m_optional_components.length, ushort.sizeof, &compareUShorts); - if(system.m_absen_components)qsort(system.m_absen_components.ptr, system.m_absen_components.length, ushort.sizeof, &compareUShorts); + if(system.m_absent_components)qsort(system.m_absent_components.ptr, system.m_absent_components.length, ushort.sizeof, &compareUShorts);*/ ushort sys_id = systems_map.get(Sys.stringof, ushort.max); if (sys_id < systems.length) @@ -653,9 +653,9 @@ class EntityManager System* system = &systems[system_id]; CallData call_data = CallData(system_id, system, &entity); - if(system.m_absen_components) + if(system.m_absent_components) { - foreach (id; system.m_absen_components) + foreach (id; system.m_absent_components) { foreach (id2; entity.components) { diff --git a/source/ecs/system.d b/source/ecs/system.d index 421321d..b13c60a 100644 --- a/source/ecs/system.d +++ b/source/ecs/system.d @@ -58,13 +58,13 @@ package: ///required components ushort[] m_components; - ///absen components - ushort[] m_absen_components; + ///absent components + ushort[] m_absent_components; ///optional components ushort[] m_optional_components; - void function(ref EntityManager.CallData data) m_update; - //void* m_update; ///workaroud for DMD bug with upper line + //void function(ref EntityManager.CallData data) m_update; + void* m_update; ///workaroud for DMD bug with upper line void function(void* system_pointer) m_enable; void function(void* system_pointer) m_disable; @@ -75,6 +75,8 @@ package: void function(void* system_pointer) m_begin; void function(void* system_pointer) m_end; - void function(ref EntityManager.CallData data) m_initialize; - void function(ref EntityManager.CallData data) m_deinitilize; + //void function(ref EntityManager.CallData data) m_initialize; + //void function(ref EntityManager.CallData data) m_deinitilize; + void* m_initialize; + void* m_deinitilize; } diff --git a/tests/tests.d b/tests/tests.d index f2f0be0..86c48fb 100644 --- a/tests/tests.d +++ b/tests/tests.d @@ -131,7 +131,7 @@ int main() TestComp[] test; TestComp2[] test2; @optional TestComp3[] test3; - //@absen TestComp4[] test4; + //@absent TestComp4[] test4; } void update(ref Entity entity, ref TestComp test, ref TestComp2 test2)//, TestComp3* test3) //ref TestComp comp) @@ -194,22 +194,22 @@ import std.meta; { __gshared ushort system_id; - enum AbsenComponents0 + enum AbsentComponents0 { TestComp, TestComp4 } - alias AbsenComponents = AliasSeq!("TestComp", "TestComp4"); + alias AbsentComponents = AliasSeq!("TestComp", "TestComp4"); - string AbsenComponents2; + string AbsentComponents2; static struct EntitiesData { short length; Entity[] entity; TestComp3[] test; - //@absen TestComp[] testt; + //@absent TestComp[] testt; } void onEnable()