-Events system update order is now choosen according to system priority

-added mixin for adding exluded components using it's type
-demos:
 *added GUI for selecting templates and choosing tools
 *change SpaceInvades SideMove system to not using events for better performance and multithreading
 *added Entites spawning support
 *fixed some Snake demo bugs
 *GUI work's better now
This commit is contained in:
Mergul 2020-02-09 15:24:26 +01:00
parent 19fc440ed6
commit 1f78f2506c
9 changed files with 436 additions and 60 deletions

View file

@ -223,6 +223,24 @@ export struct EntityManager
}
}
extern (C) static int comapreEventCaller(const void* a, const void* b) nothrow @nogc
{
EventCaller _a = *cast(EventCaller*) a;
EventCaller _b = *cast(EventCaller*) b;
if (_a.system.priority < _b.system.priority)
return -1;
else if (_a.system.priority == _b.system.priority)
return 0;
else
return 1;
}
foreach(ref event; events)
{
qsort(event.callers.ptr, event.callers.length, EventCaller.sizeof, &comapreEventCaller);
}
//qsort(event_callers.ptr, event_callers.length, EventInfo.sizeof, &compareUShorts);
foreach(EntityInfo* info;&entities_infos.byValue)
{
generateListeners(info);
@ -569,11 +587,11 @@ export struct EntityManager
//components_info.excluded ~= CompInfo(str,str);
}
}
else static if (checkExcludedComponentsSomething!Sys)
else //static if (checkExcludedComponentsSomething!Sys)
{
foreach (str; Sys.ExcludedComponents)
{
components_info.addExcluded(CompInfo(str,str));
components_info.addExcluded(CompInfo(str.stringof,str.stringof));
//components_info.excluded ~= CompInfo(str,str);
}