Hey there, I'm working on my own Entity Component System right now, too.
Your approach looks pretty much like my first one, which i redid because i ran into some inconveniences on the way.
One of them was that if you let your systems update one entity per time, you'll run into problems with the Collision and the Rendering system, because you'll have to make your own containers in order to check each Entity against each entity (for collisions), and you'll need to sort the entities for depth drawing (rendering).
My (not perfect, but improving) solution to the problem was to make a WorldIterator class, which's constructor takes information on what entities it's interested in, aswell as a reference to the world's entity container. Then I overloaded the operator++ to skip to the next entity that meets the requirements, and overloading the * and -> operators made accessing a lot nicer. I'm still in the development phase and haven't tested it yet, but I believe it to be a superior approach to the "one-entity-at-a-time-paradigm" that i see a lot of people use.
Another thing you should add (and that is in Artemis aswell) is the Component mapper. I saw you using a syntax like:
[source lang="cpp"]TMyComponent* myComponent = static_cast{TMyComponent*}(e->getComponent("MyComponent");myComponent->setSomeValue(5);myComponent = nullptr;[/source]
//For some reason it won't show these braces: <, So I'm using these instead: {
Now, while this works, it's pretty uncomfortable to type. What i suggest is to have the following syntax:
[source lang="cpp"]ComponentMapper{TMyComponent} mMyComponent;mMyComponent.grab(e);mMyComponent->setSomeValue(5);mMyComponent.release(); //You don't really need this, I did it cause it's cleaner.[/source]
And if you make the grab function return a bool if it succeeded or failed to retrieve the component, you can do some pretty cool things like:
[source lang="cpp"]// In the rendering System// blablabla drawing spriteif (mHealth.grab(e)){ if(mHealth->drawBar){ //Draw health bar }}[/source]
But overall, It's an OK approach and should be sufficient for most of what you'll set your mind to.
Greets, Xelvair
Edited by Xelvair, 18 July 2012 - 09:51 AM.