Julia provides a good compile-time dispatch, however, when a run-time dispatch is required, Julia is not so fast. While Overseer provides a possible solution, it is about updating an entire system at a time, and while it may be performant for similar algorithms, getting all entities in, for example, a || b && c requires some union/intersection. In contrast, this library will focus on determining the behavior of individual entities with a complex combination of traits in a performant manner.
So, here’s how this ECS will work.
It will store traits as 64-bit integers (Higher than this and it will error out. 64 is a hard limit because of the number of bits in a 64-bits integer.) It will mask out the irrelevant bits in each lookup and then perform a perfect hash to look up the result from a lookup table. The result could be a wrapped function from FunctionWrappers, a boolean, a number for if/else (for a small number of choices), a function parameter, a callable object, a 3x3 matrix, etc…
Basic features such as looking up individual bits will be implemented. There are several tricks you can do with this technique such as joining traits from different entities using “OR” instruction and so on. Request your feature here as I am implementing it.
The implementation is here and is still incomplete.
Please make a feature request here so I can improve it.