For those not familiar OpenEcs, it works much like the EntityX library.
I'm using OpenEcs library and I need do this kind of thing to create an entity with components:
entities.create_with<Velocity, Position>();
The template used in this method is:
template<typename ...Components>
Well, what I want to do is build this <Velocity, Position>
dynamically, like this:
vector<size_t> components = {1, 2};
auto& componentList = // something
for (auto& component : components)
{
switch (component)
{
case 1:
componentList.add(Velocity);
break;
case 2:
componentList.add(Position);
break;
default:
break;
}
}
entities.create_with<componentList>();
PS: I can do separately too, for example
entity.add<Velocity>();
But, for performance gains, the first way is better, how can I do to work like the first way?