X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fgame%2Fentity.h;h=c4cf83c119b26bce36fce09ac1238be2bebcd1d2;hb=76d859d1429782901799c9886f833cd331b670ce;hp=c28cbe5075b94567709ba562f33698097e959e29;hpb=c809f54b802727926bae40e9fe67d0e3c94fd2c0;p=libs%2Fgame.git diff --git a/source/game/entity.h b/source/game/entity.h index c28cbe5..c4cf83c 100644 --- a/source/game/entity.h +++ b/source/game/entity.h @@ -36,6 +36,11 @@ public: void add_component(Handle); void remove_component(Handle); + template + Handle get_component(); + + Handle get_transform() const { return transform; } + void add_child(Handle); void remove_child(Handle); @@ -43,10 +48,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);