struct PhysicsBodyComponent
{
// some general data
};
struct RigidBodyComponent : public PhysicsBodyComponent
{
// some specific data
};
struct SoftBodyComponent : public PhysicsBodyComponent
{
// some specific data
};
auto e = world.CreateEntity();
e.AddComponent();
Better to add two components, the general and the specific one, than to rely on inheritance. I don't think it makes sense to have a hierarchy with components as it should be just data.
struct PhysicsBodyComponent { // some general data }; struct RigidBodyComponent : public PhysicsBodyComponent { // some specific data }; struct SoftBodyComponent : public PhysicsBodyComponent { // some specific data }; auto e = world.CreateEntity(); e.AddComponent();
// somewhere else maybe a system's requirements RequireComponent();
auto& component = e.GetComponent();