Lugen
This sentence confuse me. Why "addresses to array indexes" or do you simply mean that they are just indices, not pointers?
This was my initial design. Now I'm looking for a simpler solution that is easier to implement and understand. I might still use a combination of indices and pointers.
Lugen
Anyway, I don't think I can help I'm afraid but entity systems interest me and I would like to get a better understanding of your approach.
Is that the entire system by the way, or is it unfinished? I'm not seeing where the entity id is assigned to the component index. Why do you iterate through the entire array in add_position_component?
It's unfinished and very much a work in progress.
My approach is to only have to allocate the data that is needed. This means that while a huge number of entities, as simple integers, can be created, the component SOAs will only be allocated as needed. Overall, a stateless system where the developer can add or remove components at any time, and the system can handle the changes without any issues. Hopefully, I can make every component independent of another, with theoretically unlimited combinations, only limited by the developers imagination and cleverness. Writing the actual functions to work on component combinations without conflict will be much more of a challenge, overall.
So, I need a way to reference which components are used by an entity, and that will either require pointers or storing the index of the component that entity is using. Whichever is more efficient, and reduces redundant resources the most. I'm also currently implementing a "free" array which stores pointers no entity is using, but I'm uncertain if it's really needed in the end.
Once the system basics work rock solidly, I'm going to implement other stuff on top of that. I constantly test, build, run through valgrind, everytime I make major changes and know something might have gone wonky.
After that, and implementing some other basic stuff, I'll see about adding my project. :)