Inheriting from entityx::Entity?

I’d like to make blueprints of entities that have some default components loaded in, and I’m not quite sure what the proper way to approach that is. For example, I’d like to have classes that look like this:

struct Transformable : public entityx::Entity
{
    typedef entityx::Entity super;

    Transformable()
    {
        super( entityManager.entities.create() );
        this->assign<Transform>()
        this->assign<...>()
    }

    ~Transformable()
    {
        super::destroy();

    }
}

Any tips or tricks would be helpful. So far it looks like it may be possible, but I want to make sure there’s no catches I should be aware about.

No this is not possible as you’ve described, but I would just create a free function. Something like:

void transformable(entityx::Entity e, Position pos) {
  e->assign<Transform>();
  e->assign<Position>(pos);
  e->assign<...>();
}
1 Like

Thanks for this. I’m just now reading through your recommended “Evolve your Heirarchy” article and now see that this type of inheritance defeats the purpose.