arvidsson / Mix

C++ minimal entity-component system single header library
MIT License
121 stars 18 forks source link

Maybe think of some way to get components through base component type #9

Closed volcoma closed 8 years ago

volcoma commented 8 years ago

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();

arvidsson commented 8 years ago

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.