I've been working on creating my own entity component system, and I'm set on being able to get a component by doing the following:
const auto& component = entity->GetComponent<ComponentType>();
the above function would then look something like this:
template <typename TyComponent>
TyComponent* Entity<T>::GetComponent() const
{
return &(GetComponent(TyComponent::Id());
}
Which then returns a component based on the associated id if found, else nullptr.
- Is what I'm doing viable?
- Is there a way to ensure only types derived from Component can be used as a parameter for GetComponent?
Aucun commentaire:
Enregistrer un commentaire