Changed Components/System/Events names to full name (with module) and fixed bug with flag
This commit is contained in:
parent
ffc19d4723
commit
ef4faf2755
1 changed files with 36 additions and 27 deletions
|
|
@ -382,6 +382,9 @@ export struct EntityManager
|
||||||
else
|
else
|
||||||
assert(pass < passes.length, "Update pass (ID " ~ pass.to!string ~ ") doesn't exist.");
|
assert(pass < passes.length, "Update pass (ID " ~ pass.to!string ~ ") doesn't exist.");
|
||||||
|
|
||||||
|
enum SystemName = fullyQualifiedName!Sys;
|
||||||
|
//enum SystemName = Sys.stringof;
|
||||||
|
|
||||||
System system;
|
System system;
|
||||||
system.m_pass = pass;
|
system.m_pass = pass;
|
||||||
|
|
||||||
|
|
@ -418,9 +421,9 @@ export struct EntityManager
|
||||||
static if (Params.length == 2 && is(Params[0] == Entity*))
|
static if (Params.length == 2 && is(Params[0] == Entity*))
|
||||||
{
|
{
|
||||||
alias EventParamType = Params[1];
|
alias EventParamType = Params[1];
|
||||||
enum EventName = Unqual!(EventParamType).stringof;
|
enum EventName = fullyQualifiedName!(Unqual!(EventParamType));//.stringof;
|
||||||
ushort evt = events_map.get(cast(char[]) EventName, ushort.max);
|
ushort evt = events_map.get(cast(char[]) EventName, ushort.max);
|
||||||
assert(evt != ushort.max, "Can't register system \"" ~ Sys.stringof
|
assert(evt != ushort.max, "Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing event \"" ~ EventName ~ "\".");
|
~ "\" due to non existing event \"" ~ EventName ~ "\".");
|
||||||
|
|
||||||
callers[i].callback = cast(void*)&callEventHandler!(EventParamType);
|
callers[i].callback = cast(void*)&callEventHandler!(EventParamType);
|
||||||
|
|
@ -479,7 +482,7 @@ export struct EntityManager
|
||||||
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
|
||||||
name = Unqual!(ForeachType!MemberType).stringof;
|
name = fullyQualifiedName!(Unqual!(ForeachType!MemberType));//.stringof;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_optional;
|
bool is_optional;
|
||||||
|
|
@ -704,7 +707,8 @@ export struct EntityManager
|
||||||
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
|
||||||
name = Unqual!(ForeachType!MemberType).stringof;
|
name = fullyQualifiedName!(Unqual!(ForeachType!MemberType));
|
||||||
|
//name = Unqual!(ForeachType!MemberType).stringof;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_optional;
|
bool is_optional;
|
||||||
|
|
@ -759,7 +763,8 @@ export struct EntityManager
|
||||||
{
|
{
|
||||||
foreach (str; Sys.ExcludedComponents)
|
foreach (str; Sys.ExcludedComponents)
|
||||||
{
|
{
|
||||||
components_info.addExcluded(CompInfo(str.stringof, str.stringof));
|
components_info.addExcluded(CompInfo(str.stringof, fullyQualifiedName!str));
|
||||||
|
// components_info.addExcluded(CompInfo(str.stringof, str.stringof));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -828,10 +833,10 @@ export struct EntityManager
|
||||||
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
||||||
version (D_BetterC)
|
version (D_BetterC)
|
||||||
assert(comp != ushort.max,
|
assert(comp != ushort.max,
|
||||||
"Can't register system \"" ~ Sys.stringof
|
"Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component.");
|
~ "\" due to non existing component.");
|
||||||
else
|
else
|
||||||
assert(comp != ushort.max, "Can't register system \"" ~ Sys.stringof
|
assert(comp != ushort.max, "Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
||||||
system.m_components[iii] = comp;
|
system.m_components[iii] = comp;
|
||||||
}
|
}
|
||||||
|
|
@ -840,10 +845,10 @@ export struct EntityManager
|
||||||
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
||||||
version (D_BetterC)
|
version (D_BetterC)
|
||||||
assert(comp != ushort.max,
|
assert(comp != ushort.max,
|
||||||
"Can't register system \"" ~ Sys.stringof
|
"Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component.");
|
~ "\" due to non existing component.");
|
||||||
else
|
else
|
||||||
assert(comp != ushort.max, "Can't register system \"" ~ Sys.stringof
|
assert(comp != ushort.max, "Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
||||||
system.m_excluded_components[iii] = comp;
|
system.m_excluded_components[iii] = comp;
|
||||||
}
|
}
|
||||||
|
|
@ -852,10 +857,10 @@ export struct EntityManager
|
||||||
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
||||||
version (D_BetterC)
|
version (D_BetterC)
|
||||||
assert(comp != ushort.max,
|
assert(comp != ushort.max,
|
||||||
"Can't register system \"" ~ Sys.stringof
|
"Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component.");
|
~ "\" due to non existing component.");
|
||||||
else
|
else
|
||||||
assert(comp != ushort.max, "Can't register system \"" ~ Sys.stringof
|
assert(comp != ushort.max, "Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
||||||
system.m_optional_components[iii] = comp;
|
system.m_optional_components[iii] = comp;
|
||||||
}
|
}
|
||||||
|
|
@ -864,10 +869,10 @@ export struct EntityManager
|
||||||
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
||||||
version (D_BetterC)
|
version (D_BetterC)
|
||||||
assert(comp != ushort.max,
|
assert(comp != ushort.max,
|
||||||
"Can't register system \"" ~ Sys.stringof
|
"Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component.");
|
~ "\" due to non existing component.");
|
||||||
else
|
else
|
||||||
assert(comp != ushort.max, "Can't register system \"" ~ Sys.stringof
|
assert(comp != ushort.max, "Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
||||||
system.m_read_only_components[iii] = comp;
|
system.m_read_only_components[iii] = comp;
|
||||||
}
|
}
|
||||||
|
|
@ -876,10 +881,10 @@ export struct EntityManager
|
||||||
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
ushort comp = components_map.get(cast(char[]) comp_info.type, ushort.max);
|
||||||
version (D_BetterC)
|
version (D_BetterC)
|
||||||
assert(comp != ushort.max,
|
assert(comp != ushort.max,
|
||||||
"Can't register system \"" ~ Sys.stringof
|
"Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component.");
|
~ "\" due to non existing component.");
|
||||||
else
|
else
|
||||||
assert(comp != ushort.max, "Can't register system \"" ~ Sys.stringof
|
assert(comp != ushort.max, "Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
~ "\" due to non existing component \"" ~ comp_info.type ~ "\".");
|
||||||
system.m_writable_components[iii] = comp;
|
system.m_writable_components[iii] = comp;
|
||||||
}
|
}
|
||||||
|
|
@ -1155,10 +1160,10 @@ export struct EntityManager
|
||||||
ushort.max);
|
ushort.max);
|
||||||
version (D_BetterC)
|
version (D_BetterC)
|
||||||
assert(comp != ushort.max,
|
assert(comp != ushort.max,
|
||||||
"Can't register system \"" ~ Sys.stringof
|
"Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing dependency.");
|
~ "\" due to non existing dependency.");
|
||||||
else
|
else
|
||||||
assert(comp != ushort.max, "Can't register system \"" ~ Sys.stringof
|
assert(comp != ushort.max, "Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing dependency \"" ~ comp_info.type ~ "\".");
|
~ "\" due to non existing dependency \"" ~ comp_info.type ~ "\".");
|
||||||
system.m_readonly_dependencies[iii] = comp;
|
system.m_readonly_dependencies[iii] = comp;
|
||||||
}
|
}
|
||||||
|
|
@ -1168,15 +1173,15 @@ export struct EntityManager
|
||||||
ushort comp = external_dependencies_map.get(cast(char[]) comp_info.type, ushort.max);
|
ushort comp = external_dependencies_map.get(cast(char[]) comp_info.type, ushort.max);
|
||||||
version (D_BetterC)
|
version (D_BetterC)
|
||||||
assert(comp != ushort.max,
|
assert(comp != ushort.max,
|
||||||
"Can't register system \"" ~ Sys.stringof
|
"Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing dependency.");
|
~ "\" due to non existing dependency.");
|
||||||
else
|
else
|
||||||
assert(comp != ushort.max, "Can't register system \"" ~ Sys.stringof
|
assert(comp != ushort.max, "Can't register system \"" ~ SystemName
|
||||||
~ "\" due to non existing dependency \"" ~ comp_info.type ~ "\".");
|
~ "\" due to non existing dependency \"" ~ comp_info.type ~ "\".");
|
||||||
system.m_writable_dependencies[iii] = comp;
|
system.m_writable_dependencies[iii] = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
ushort sys_id = systems_map.get(cast(char[]) Sys.stringof, ushort.max);
|
ushort sys_id = systems_map.get(cast(char[]) SystemName, ushort.max);
|
||||||
if (sys_id < systems.length)
|
if (sys_id < systems.length)
|
||||||
{
|
{
|
||||||
systems[sys_id].disable();
|
systems[sys_id].disable();
|
||||||
|
|
@ -1195,7 +1200,7 @@ export struct EntityManager
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
system.m_name = Mallocator.makeArray(cast(char[]) Sys.stringof);
|
system.m_name = Mallocator.makeArray(cast(char[]) SystemName);
|
||||||
|
|
||||||
systems_map.add(system.m_name, cast(ushort) systems.length);
|
systems_map.add(system.m_name, cast(ushort) systems.length);
|
||||||
|
|
||||||
|
|
@ -1254,6 +1259,9 @@ export struct EntityManager
|
||||||
{
|
{
|
||||||
ComponentInfo info;
|
ComponentInfo info;
|
||||||
|
|
||||||
|
enum ComponentName = fullyQualifiedName!Comp;
|
||||||
|
//enum ComponentName = Comp.stringof;
|
||||||
|
|
||||||
static if (!(hasMember!(Comp, "component_id")) || !is(typeof(Comp.component_id) == ushort))
|
static if (!(hasMember!(Comp, "component_id")) || !is(typeof(Comp.component_id) == ushort))
|
||||||
{
|
{
|
||||||
static assert(0, "Add \"mixin ECS.Component;\" in top of component structure;");
|
static assert(0, "Add \"mixin ECS.Component;\" in top of component structure;");
|
||||||
|
|
@ -1290,7 +1298,7 @@ export struct EntityManager
|
||||||
info.init_data = Mallocator.makeArray!ubyte(Comp.sizeof);
|
info.init_data = Mallocator.makeArray!ubyte(Comp.sizeof);
|
||||||
*cast(Comp*) info.init_data.ptr = Comp.init; // = Comp();
|
*cast(Comp*) info.init_data.ptr = Comp.init; // = Comp();
|
||||||
|
|
||||||
ushort comp_id = components_map.get(cast(char[]) Comp.stringof, ushort.max);
|
ushort comp_id = components_map.get(cast(char[]) ComponentName, ushort.max);
|
||||||
if (comp_id < components.length)
|
if (comp_id < components.length)
|
||||||
{
|
{
|
||||||
Comp.component_id = comp_id;
|
Comp.component_id = comp_id;
|
||||||
|
|
@ -1300,9 +1308,7 @@ export struct EntityManager
|
||||||
{
|
{
|
||||||
components.add(info);
|
components.add(info);
|
||||||
Comp.component_id = cast(ushort)(components.length - 1);
|
Comp.component_id = cast(ushort)(components.length - 1);
|
||||||
char[] name = Mallocator.makeArray(cast(char[]) Comp.stringof);
|
char[] name = Mallocator.makeArray(cast(char[]) ComponentName);
|
||||||
/*char[] name = Mallocator.makeArray!char(Comp.stringof.length);
|
|
||||||
name[0..$] = Comp.stringof;*/
|
|
||||||
components_map.add(name, cast(ushort)(components.length - 1));
|
components_map.add(name, cast(ushort)(components.length - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1330,7 +1336,8 @@ export struct EntityManager
|
||||||
info.size = Ev.sizeof;
|
info.size = Ev.sizeof;
|
||||||
info.alignment = Ev.alignof;
|
info.alignment = Ev.alignof;
|
||||||
|
|
||||||
ushort event_id = events_map.get(Ev.stringof, ushort.max);
|
//ushort event_id = events_map.get(Ev.stringof, ushort.max);
|
||||||
|
ushort event_id = events_map.get(fullyQualifiedName!Ev, ushort.max);
|
||||||
if (event_id < events.length)
|
if (event_id < events.length)
|
||||||
{
|
{
|
||||||
Ev.event_id = event_id;
|
Ev.event_id = event_id;
|
||||||
|
|
@ -1339,7 +1346,8 @@ export struct EntityManager
|
||||||
{
|
{
|
||||||
events.add(info);
|
events.add(info);
|
||||||
Ev.event_id = cast(ushort)(events.length - 1);
|
Ev.event_id = cast(ushort)(events.length - 1);
|
||||||
events_map.add(Ev.stringof, cast(ushort)(events.length - 1));
|
// events_map.add(Ev.stringof, cast(ushort)(events.length - 1));
|
||||||
|
events_map.add(fullyQualifiedName!Ev, cast(ushort)(events.length - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1861,6 +1869,7 @@ export struct EntityManager
|
||||||
|
|
||||||
foreach (i, id; ids)
|
foreach (i, id; ids)
|
||||||
{
|
{
|
||||||
|
if(current_delta == 0)current_delta = ushort.max;
|
||||||
alignNum(current_delta, components[id].alignment);
|
alignNum(current_delta, components[id].alignment);
|
||||||
info.deltas[id] = cast(ushort) current_delta;
|
info.deltas[id] = cast(ushort) current_delta;
|
||||||
current_delta += entites_in_block * components[id].size;
|
current_delta += entites_in_block * components[id].size;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue