From 436e9557655f7ed2d61f345c993cdaca2c3934a4 Mon Sep 17 00:00:00 2001 From: Duckie Date: Thu, 26 Oct 2023 23:21:12 +0530 Subject: [PATCH] feat: worldoutliner create/destroy entity --- Editor/Panels/WorldOutliner.h | 7 +++++++ Engine/ECS/Scene.h | 1 + 2 files changed, 8 insertions(+) diff --git a/Editor/Panels/WorldOutliner.h b/Editor/Panels/WorldOutliner.h index 53bab075..fd2a4a1f 100644 --- a/Editor/Panels/WorldOutliner.h +++ b/Editor/Panels/WorldOutliner.h @@ -45,6 +45,13 @@ namespace DT ImGui::Begin("World Outliner", &isOpen); + // Entity control + if (ImGui::Button("Create Entity", ImVec2(ImGui::GetWindowSize().x, 0.0f))) + selectedEntity = sceneManager->activeScene.CreateEntity(); + if (ImGui::Button("Destroy Entity", ImVec2(ImGui::GetWindowSize().x, 0.0f))) + sceneManager->activeScene.DestroyEntity(selectedEntity).Fatal("WorldOutlinerPanel::Tick()"); + + // Entity list for (Entity entity : sceneManager->activeScene.GetEntities()) { std::string label; diff --git a/Engine/ECS/Scene.h b/Engine/ECS/Scene.h index 3e615cee..a35c34e0 100644 --- a/Engine/ECS/Scene.h +++ b/Engine/ECS/Scene.h @@ -48,6 +48,7 @@ namespace DT { PROFILE(); + components.insert(std::make_pair(entityCounter, std::unordered_map>())); return entityCounter++; }