#ifndef SCENE_HIERARCHY_HPP #define SCENE_HIERARCHY_HPP #include #include #include namespace OpenEngine { using ComponentDrawer = std::function; struct ComponentUI { std::string name; std::function draw_func; std::function remove_func; }; class SceneHierarchy { public: SceneHierarchy() = default; SceneHierarchy(const Ref& scene); void Init(const Ref& scene); void OnImGuiRender(); Entity GetSelectedEntity() const { return selected_context; }; void SetSelectedEntity(Entity entity) { selected_context = entity; }; void ClearSelection() { selected_context = {}; }; private: void DrawEntityNode(Entity& entity); void DrawComponents(Entity& entity); private: template static void RegisterDrawer(const std::string& name, std::function func) { drawers[entt::type_id().hash()] = { name, func, [](entt::registry& reg, entt::entity ent) { reg.remove(ent); } }; } inline static std::map drawers; Ref scene; Entity selected_context, renamed_entity; double last_selected_time = 10.0; }; } #endif // SCENE_HIERARCHY_HPP