diff options
Diffstat (limited to 'src/crepe/ComponentManager.h')
-rw-r--r-- | src/crepe/ComponentManager.h | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/crepe/ComponentManager.h b/src/crepe/ComponentManager.h index c8c196c..e37bc4a 100644 --- a/src/crepe/ComponentManager.h +++ b/src/crepe/ComponentManager.h @@ -1,15 +1,18 @@ #pragma once -#include <cstdint> #include <memory> #include <typeindex> #include <unordered_map> #include <vector> +#include <forward_list> #include "Component.h" +#include "api/Vector2.h" namespace crepe { +class GameObject; + /** * \brief Manages all components * @@ -18,18 +21,10 @@ namespace crepe { */ class ComponentManager { public: - /** - * \brief Get the instance of the ComponentManager - * - * \return The instance of the ComponentManager - */ - static ComponentManager & get_instance(); - ComponentManager(const ComponentManager &) = delete; - ComponentManager(ComponentManager &&) = delete; - ComponentManager & operator=(const ComponentManager &) = delete; - ComponentManager & operator=(ComponentManager &&) = delete; - ~ComponentManager(); + ComponentManager(); // dbg_trace + ~ComponentManager(); // dbg_trace +public: /** * \brief Add a component to the ComponentManager * @@ -100,8 +95,8 @@ public: template <typename T> std::vector<std::reference_wrapper<T>> get_components_by_type() const; -private: - ComponentManager(); + // TODO: doxygen + GameObject & new_object(const std::string & name, const std::string & tag = "", const Vector2 & position = { 0, 0 }, double rotation = 0, double scale = 0); private: /** @@ -118,6 +113,10 @@ private: std::unordered_map<std::type_index, std::vector<std::vector<std::unique_ptr<Component>>>> components; + + //! ID of next GameObject + game_object_id_t next_id = 0; + std::forward_list<std::unique_ptr<GameObject>> objects; }; } // namespace crepe |