Recently I started learning about ECS and I decided to try and create a very basic implementation on my own. I made myself an enum with the component names and two basic components:
enum Components {
VerticesComponent, ColorComponent
};
struct VerticesComponent {
int id = Components::VerticesComponent;
float vertices[];
};
struct ColorComponent {
int id = Components::ColorComponent;
float red;
float green;
float blue;
float alpha;
};
Then I added a struct for an entity:
struct Entity {
int id;
std::vector<int> components;
};
And then I realised that my approach is flawed because I only add the index of a component to my entity but not the actual data stored in the component. So my question is: how can I properly connect an entity with a component?