Hi
Im trying to implement ECS pattern in my game but I have a few questions
We have some entitites, all have position component (x and y) and sprite component, someones have a pickable component (boolean)
In the draw o rendering system, we iterate over 2 arrays, position array and sprite array, no problems
But, for instance, if I need to create a pick system (checks if a user clicks in a entity), the system needs to iterate over the position array (ok, all entities have) and need the pickable component, that no all entities uses.
I dont know what is the best aproach
- Create arrays for each system : echa system uses the data they need, (too much arrays??) , manager adds components in each array
- Iterate over entities : but this is not ecs pattern
- Create arrays of ids of entities for each system: each system has an array with the ids of the entities , and all the systems looks the same array of entities with the id of the entitite (the index) and check the components
- iterate over array of positions, and when we get the correct position, check if the entity of that component has a pickable component, I dont know if this is slow
What do you think, what is the way of doing this?
Thanks