alecthomas / entityx

EntityX - A fast, type-safe C++ Entity-Component system
MIT License
2.23k stars 295 forks source link

Inheriting from Entity? #243

Closed jasonmeverett closed 4 years ago

jasonmeverett commented 4 years ago

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.

alecthomas commented 4 years ago

Can we move these discussions to https://discourse.swapoff.org/c/entityx/7? GitHub is not really a great conversation/help platform. If you'd like to move these questions over there, I'm happy to chat.