ECS with entt
This commit is contained in:
40
editor/include/panels/scene_hierarchy.hpp
Normal file
40
editor/include/panels/scene_hierarchy.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef SCENE_HIERARCHY_HPP
|
||||
#define SCENE_HIERARCHY_HPP
|
||||
|
||||
#include "imgui.h"
|
||||
#include <open_engine.hpp>
|
||||
|
||||
namespace OpenEngine {
|
||||
class SceneHierarchy
|
||||
{
|
||||
public:
|
||||
SceneHierarchy() = default;
|
||||
SceneHierarchy(const Ref<Scene>& scene);
|
||||
|
||||
void SetContext(const Ref<Scene>& scene);
|
||||
|
||||
void OnImGuiRender();
|
||||
|
||||
private:
|
||||
void DrawEntityNode(Entity& entity);
|
||||
void DrawComponents(Entity& entity);
|
||||
|
||||
template <typename T>
|
||||
void DrawComponentDrawer(Entity& entity, const char* header)
|
||||
{
|
||||
if (entity.HasComponent<T>())
|
||||
if (ImGui::TreeNodeEx((void*)typeid(T).hash_code(), ImGuiTreeNodeFlags_DefaultOpen, "%s", header)) {
|
||||
entity.GetComponents<T>().OnImGuiRender(entity);
|
||||
ImGui::TreePop();
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Ref<Scene> scene;
|
||||
Entity selected_context, renamed_entity;
|
||||
double last_selected_time = 10.0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SCENE_HIERARCHY_HPP
|
||||
Reference in New Issue
Block a user