I need to write a function for an ECS that takes in a variable number of template parameters (Components) and no arguments and will return a list of entities with those components attached.
The format would look like this:
auto list = registry.getEntityGroupWithComponents<TransformComponent, RenderComponent>();
Within the function, I need to access a static ID of each Component class to determine which entities to return, something like this:
template <class... T>
std::vector<Entity> getEntityGroupWithComponents()
{
auto componentIDs = { T::s_id };
//return entities with all componentIDs in list
}
I've messed around quite a bit and can't come up with anything that produces this behavior, but I'm fairly sure it's possible since I think I've seen a similar API before. Any help would be appreciated, thanks!
Unsure about what you need, but probably something like
?
Depending on how an entity is constructed from a component id.