]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/handle.h
Make it possible to retrieve components and systems of a particular type
[libs/game.git] / source / game / handle.h
index 2e544c7238e75ca7d5418c9f5c7a05c65e61081e..b08bcf8e4f903028894702e8085df47174ce640f 100644 (file)
@@ -39,6 +39,13 @@ public:
        bool operator==(const Handle &other) const = default;
 };
 
+template<typename T, typename U>
+       requires std::is_base_of_v<U, T>
+Handle<T> dynamic_handle_cast(Handle<U> h)
+{
+       return Handle<T>::from_object(dynamic_cast<T *>(h.get()));
+}
+
 } // namespace Msp::Game
 
 #endif