X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fentity.h;h=8dc5139558abeba8a676e6fdac67747c53e26df3;hb=4f15b79cebd6f76ff49e94c19f66ad479b66c55d;hp=c28cbe5075b94567709ba562f33698097e959e29;hpb=c809f54b802727926bae40e9fe67d0e3c94fd2c0;p=libs%2Fgame.git diff --git a/source/game/entity.h b/source/game/entity.h index c28cbe5..8dc5139 100644 --- a/source/game/entity.h +++ b/source/game/entity.h @@ -35,6 +35,12 @@ public: void add_component(Handle); void remove_component(Handle); + const std::vector> &get_components() const { return components; } + + template + Handle get_component(); + + Handle get_transform() const { return transform; } void add_child(Handle); void remove_child(Handle); @@ -43,10 +49,18 @@ public: Handle get_root(); const std::vector> &get_children() const { return children; } Stage &get_stage(); - Handle get_transform() const { return transform; } }; +template +inline Handle Entity::get_component() +{ + for(Handle c: components) + if(Handle tc = dynamic_handle_cast(c)) + return tc; + return nullptr; +} + inline Handle Entity::get_root() { Handle e = Handle::from_object(this);