I'm trying to integrate ECS design into my game engine.
Currently I'm trying to mimic the components of unity (although not pure ECS) with
Mesh object) and
MeshRenderer (holds various attributes such as
receiveShadows etc..) components.
I also have
MeshRenderer system which I defined such as that it gets all entities with
MeshRenderer components so it could basically render these meshes.
The logic of the
MeshRenderer system would basically be:
- iterate the entities
- grab the
- grab the
- use relevant
Shaders from the
Materialto draw the mesh
This is all fine but I wish to represent lights as entities as-well. I've made relevant components such as
SpotLight etc.. that holds relevant information such as attenuation, color, shadow map (another object that holds
RenderBuffer object of the shadow map) etc..
Now it seems to me that this
MeshRenderer system should also take into account any entity with
XXXLight components as-well since part of the rendering of an object is to also take into account any lights in the scene and also generate relevant shadows from/upon it.
Problem is that the system is defined to operate on entities with
MeshRenderer component and I'm not sure what to do. Should I make it so systems could operate on a list of entities with relevant components? Wouldn't it make the logic of the system's
Update method a mess which entity is render-able mesh and which is light and then plug it all together?
I'm wondering what would be the best course of action here, what can I do?