-support for system priority
-fixed callers system pointer update -fixed HashMap issue
This commit is contained in:
parent
0eaff0adad
commit
1aa1fbf36b
3 changed files with 35 additions and 3 deletions
|
|
@ -115,6 +115,7 @@ class EntityManager
|
||||||
}
|
}
|
||||||
|
|
||||||
system.m_system_pointer = cast(void*) Mallocator.instance.make!Sys;
|
system.m_system_pointer = cast(void*) Mallocator.instance.make!Sys;
|
||||||
|
system.m_priority = priority;
|
||||||
|
|
||||||
system.m_components = Mallocator.instance.makeArray!uint(types.length - 1);
|
system.m_components = Mallocator.instance.makeArray!uint(types.length - 1);
|
||||||
mixin(genCompList());
|
mixin(genCompList());
|
||||||
|
|
@ -268,7 +269,7 @@ class EntityManager
|
||||||
{
|
{
|
||||||
foreach(entity;&entities_infos.byValue)
|
foreach(entity;&entities_infos.byValue)
|
||||||
{
|
{
|
||||||
foreach(caller;entity.callers)
|
foreach(ref caller;entity.callers)
|
||||||
{
|
{
|
||||||
caller.system = &systems[caller.system_id];
|
caller.system = &systems[caller.system_id];
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +303,13 @@ class EntityManager
|
||||||
{
|
{
|
||||||
call_data.deltas = Mallocator.instance.makeArray(deltas); //Mallocator.instance.makeArray!ushort(system.m_components.length);
|
call_data.deltas = Mallocator.instance.makeArray(deltas); //Mallocator.instance.makeArray!ushort(system.m_components.length);
|
||||||
|
|
||||||
entity.callers.add(call_data);
|
uint index = 0;
|
||||||
|
for(;index<entity.callers.length;index++)
|
||||||
|
{
|
||||||
|
CallData* caller = &entity.callers[index];
|
||||||
|
if(caller.system.priority >= call_data.system.priority)break;
|
||||||
|
}
|
||||||
|
entity.callers.add(call_data,index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,8 @@ public:
|
||||||
extend(array.length * 2);
|
extend(array.length * 2);
|
||||||
}
|
}
|
||||||
foreach_reverse (size_t i; pos .. used) {
|
foreach_reverse (size_t i; pos .. used) {
|
||||||
swap(array[i + 1], array[i]);
|
//swap(array[i + 1], array[i]);
|
||||||
|
array[i+1] = array[i];
|
||||||
}
|
}
|
||||||
emplace(&array[pos], t);
|
emplace(&array[pos], t);
|
||||||
used++;
|
used++;
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,28 @@ int main()
|
||||||
test2.b += 2;
|
test2.b += 2;
|
||||||
test2.a = 8;
|
test2.a = 8;
|
||||||
//writeln("Jakis tekst! ",test2.b);
|
//writeln("Jakis tekst! ",test2.b);
|
||||||
|
writeln("Low priority tekst! ");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleEvent(Event event, ref TestComp comp)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestSystemWithHighPriority
|
||||||
|
{
|
||||||
|
|
||||||
|
void initialize(ref Entity entity, ref TestComp comp)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(ref Entity entity, ref TestComp test) //ref TestComp comp)
|
||||||
|
{
|
||||||
|
assert(cast(size_t)&test % TestComp.alignof == 0);
|
||||||
|
|
||||||
|
writeln("High priority tekst! ");
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleEvent(Event event, ref TestComp comp)
|
void handleEvent(Event event, ref TestComp comp)
|
||||||
|
|
@ -158,7 +180,9 @@ int main()
|
||||||
|
|
||||||
time = MonoTime.currTime;
|
time = MonoTime.currTime;
|
||||||
|
|
||||||
|
gEM.registerSystem!TestSystemWithHighPriority(100);
|
||||||
gEM.registerSystem!TestSystem(0);
|
gEM.registerSystem!TestSystem(0);
|
||||||
|
//gEM.registerSystem!TestSystemWithHighPriority(100);
|
||||||
//gEM.registerSystem!TestSystem2(0);
|
//gEM.registerSystem!TestSystem2(0);
|
||||||
|
|
||||||
dur = (MonoTime.currTime - time).total!"usecs";
|
dur = (MonoTime.currTime - time).total!"usecs";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue