On Tuesday, 8 October 2013 at 10:35:53 UTC, Kiith-Sa wrote:
In my implementation I don't even use a getComponent equivalent; a process() (or opApply() in the older version I linked) function directly takes component references, and all components are in plain arrays. Processing of a System is done (in generated code) by iterating over the components the System specifies in its signature, which is cache-friendly, and means the components needed are always available directly to the process() function without any lookup. However, this is a less flexible approach than what you're doing (although intentional, again, to eventually enable very easy threading).

Looks similar to what I do in my engine, although entities and components are not classes.

Basic example:

struct State2D
{
    Vector2 position;
    float rotation;
}

struct BoundKill {} // Acts as a tag

class BoundManager : Manager!(State2D, BoundKill)
{
override void process(Entity entity, State2D state, BoundKill tag)
    {
        if (state.y < 0)
            world.remove(entity);
    }
}

And entity is just a struct containing size_t id

Reply via email to