6namespace spark::core::details
8 template <
typename Impl>
9 AbstractGameObject<Impl>::AbstractGameObject(GameObject* parent)
10 : Composite(parent) {}
12 template <
typename Impl>
13 AbstractGameObject<Impl>::~AbstractGameObject()
16 SPARK_CORE_ASSERT(!m_initialized)
18 for (
const auto& [component, managed] : m_components | std::views::values)
23 template <
typename Impl>
29 static_cast<Impl*
>(
this)->onSpawn();
30 std::ranges::for_each(m_components | std::views::values | std::views::keys,
38 template <
typename Impl>
41 static_cast<Impl*
>(
this)->onUpdate(dt);
42 std::ranges::for_each(m_components | std::views::values | std::views::keys,
49 template <
typename Impl>
55 std::ranges::for_each(m_components | std::views::values | std::views::keys,
60 static_cast<Impl*
>(
this)->onDestroyed();
61 m_initialized =
false;
A component that can be attached to a GameObject to provide additional functionality.
Definition Component.h:20
virtual void onDetach()
Method called when the component is detached from a GameObject.
Definition Component.h:75
virtual void onAttach()
Method called when the component is attached to a GameObject.
Definition Component.h:64
virtual void onUpdate(float dt)
Method called on every frame.
Definition Component.h:70
A CRTP class to implement a GameObject. It is used to wrap the onSpawn, onUpdate and onDestroyed meth...
Definition AbstractGameObject.h:22