From 0fb6e94a2fa8c535d36b80e2d543fdfc85dbbff2 Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Thu, 23 Jun 2022 15:41:22 -0400 Subject: [PATCH] Added new folder icon New entities can be added to the world root --- docs/tasks/core.todo | 2 +- docs/tasks/editor.todo | 16 ++-- src/internal_data/data_headers/new_folder.h | 28 ++++++ src/internal_data/data_manager.cpp | 10 +-- src/run_modes/editor/component_guis.cpp | 2 +- .../editor/contents/content_manager.cpp | 6 +- src/run_modes/editor/panels/asset_browser.cpp | 37 +++++++- src/run_modes/editor/panels/asset_browser.h | 3 +- src/run_modes/editor/panels/world_tree.cpp | 85 +++++++++++++++++-- src/run_modes/editor/panels/world_tree.h | 9 ++ src/world/components.h | 8 +- src/world/entity.h | 1 - src/world/world.cpp | 24 +++++- src/world/world.h | 17 +++- 14 files changed, 212 insertions(+), 36 deletions(-) create mode 100644 src/internal_data/data_headers/new_folder.h diff --git a/docs/tasks/core.todo b/docs/tasks/core.todo index d54fb5a..d27127a 100644 --- a/docs/tasks/core.todo +++ b/docs/tasks/core.todo @@ -68,7 +68,7 @@ Core: ✔ Functionality for adding/working with components (through EnTT) @done(22-06-01 14:01) Components: - ☐ Tag + ✔ Tag @done(22-06-23 15:49) ☐ Transform ☐ SpriteRenderer ☐ Animation Controller diff --git a/docs/tasks/editor.todo b/docs/tasks/editor.todo index 6154190..9cee506 100644 --- a/docs/tasks/editor.todo +++ b/docs/tasks/editor.todo @@ -34,11 +34,9 @@ Editor: ✔ Save/Update contents file @done (3/3/2022, 3:16:23 PM) GUI Panels: - Project Overview (Tree view): + World View: - Scene View: - - Scene Hierarchy (Tree View): + World Hierarchy (Tree View): Asset Viewer: ✔ Get references to the EditorAsset objects instead of the raw file locations @done(22-06-01 18:48) @@ -46,11 +44,18 @@ Editor: ✔ Double click folders in content view to open @done(22-06-21 15:17) ✔ Drag and Drop asset files to move them to different folders @done(22-06-21 15:18) ✔ Add directory back button to content view @done(22-06-21 15:45) + ☐ Add folder drag/drop + ☐ Design the content area tool bar + + + Properties: + ☐ Implement showing components on selected Entity Tools: Tile Map Editor: ✔ Switch to NFD dialogs (or move tile set import to the main editor) @high @done(22-05-23 16:01) ☐ Allow Tile Maps to be named + ☐ Stamp system Tile Map Canvas: ☐ Implement a proper camera system and do not use panel scrolling @high @@ -73,6 +78,3 @@ Editor: ☐ Stamp creation - - - Properties: \ No newline at end of file diff --git a/src/internal_data/data_headers/new_folder.h b/src/internal_data/data_headers/new_folder.h new file mode 100644 index 0000000..a753a2e --- /dev/null +++ b/src/internal_data/data_headers/new_folder.h @@ -0,0 +1,28 @@ +/****************************************************************************** +* new_folder.h +* This file was automatically genereated from the source file: new_folder.png +* Generated by data2c version 0.1.1 +******************************************************************************/ + +namespace lunarium_data_newdir +{ + const unsigned int new_folderDataSize = 1088; + const unsigned int new_folderDataWidth = 17; + const unsigned int new_folderDataHeight = 16; + const unsigned int new_folderDataNumChannels = 4; + const unsigned char new_folderData[] = { 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 84, 145, 255, 170, 85, 3, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 183, 255, 159, 80, 16, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 153, 85, 198, 255, 153, 85, 198, 255, 153, 85, 198, 255, 153, 85, 198, 255, 153, 84, 210, 255, 153, 84, 210, 255, + 153, 84, 210, 255, 152, 85, 184, 255, 153, 85, 90, 255, 153, 84, 85, 255, 153, 84, 85, 255, 153, 84, 85, 255, 153, 84, 85, 255, 153, 84, 85, 255, 153, 84, 85, 255, 153, 84, 85, 255, 153, 84, 85, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 202, 123, 71, 255, 87, 57, 42, 255, 225, 136, 77, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 185, 113, 67, 255, 36, 28, 28, 255, 215, 130, 75, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 185, 113, 67, 255, 36, 28, 28, 255, 215, 130, 75, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 185, 113, 67, 255, 36, 28, 28, 255, 215, 130, 75, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 166, 102, 61, 255, 117, 74, 49, 255, 117, 74, 49, 255, 117, 74, 49, 255, 91, + 60, 43, 255, 36, 28, 28, 255, 102, 66, 46, 255, 117, 74, 49, 255, 117, 74, 49, 255, 117, 74, 49, 255, 206, 125, 72, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 145, 90, 56, 255, 85, 56, 41, 255, 85, 56, 41, 255, 85, 56, 41, 255, 69, 47, 37, 255, 36, 28, 28, 255, 76, 51, 39, 255, 85, + 56, 41, 255, 85, 56, 41, 255, 85, 56, 41, 255, 194, 118, 69, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 185, 113, 67, 255, 36, 28, 28, 255, 215, 130, 75, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 185, 113, 67, 255, 36, 28, 28, 255, 215, 130, 75, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 185, 113, 67, 255, 36, 28, 28, 255, 215, 130, 75, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 185, 113, 67, 255, 36, 28, 28, 255, 215, 130, 75, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, + 153, 85, 255, 255, 153, 85, 255, 252, 151, 84, 255, 244, 146, 82, 255, 253, 152, 84, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255, 255, 153, 85, 255 + }; +} \ No newline at end of file diff --git a/src/internal_data/data_manager.cpp b/src/internal_data/data_manager.cpp index 823692c..a8f1167 100644 --- a/src/internal_data/data_manager.cpp +++ b/src/internal_data/data_manager.cpp @@ -18,7 +18,7 @@ #include "data_headers/open_font.h" #include "data_headers/roboto_font.h" #include "data_headers/folder16.h" -#include "data_headers/new_dir_icon.h" +#include "data_headers/new_folder.h" #include "data_headers/up_arrow_icon.h" #include @@ -49,13 +49,13 @@ namespace lunarium ///////////////////////////////////////// // new_dir_icon format = ImageFormat::RGB; - if (lunarium_data_newdir::new_dir_iconDataNumChannels == 4) + if (lunarium_data_newdir::new_folderDataNumChannels == 4) { format = ImageFormat::RGBA; } - pData = new unsigned char[lunarium_data_newdir::new_dir_iconDataSize]; - memcpy(pData, lunarium_data_newdir::new_dir_iconData, lunarium_data_newdir::new_dir_iconDataSize); - mNewFolderIcon = new Image(pData, lunarium_data_newdir::new_dir_iconDataWidth, lunarium_data_newdir::new_dir_iconDataHeight, format); + pData = new unsigned char[lunarium_data_newdir::new_folderDataSize]; + memcpy(pData, lunarium_data_newdir::new_folderData, lunarium_data_newdir::new_folderDataSize); + mNewFolderIcon = new Image(pData, lunarium_data_newdir::new_folderDataWidth, lunarium_data_newdir::new_folderDataHeight, format); Core::Graphics().RegisterImage(*mNewFolderIcon); mNewFolderIcon->FreeRawData(); ////////////////////////////////////////// diff --git a/src/run_modes/editor/component_guis.cpp b/src/run_modes/editor/component_guis.cpp index 050c7f4..ec135c7 100644 --- a/src/run_modes/editor/component_guis.cpp +++ b/src/run_modes/editor/component_guis.cpp @@ -22,6 +22,6 @@ namespace lunarium { namespace editor void CompGui::RenderTransformComp(TransformComponent& comp) { - + } }} \ No newline at end of file diff --git a/src/run_modes/editor/contents/content_manager.cpp b/src/run_modes/editor/contents/content_manager.cpp index b311125..b171360 100644 --- a/src/run_modes/editor/contents/content_manager.cpp +++ b/src/run_modes/editor/contents/content_manager.cpp @@ -145,6 +145,8 @@ namespace lunarium { namespace editor OpRes ContentManager::Save() { + Logger::Info(Editor::LogCat, "Updating content_meta.json..."); + if (!mpProject) { return OpRes::Fail("ConentManager::Save failed: no project set"); @@ -305,7 +307,7 @@ namespace lunarium { namespace editor delete iter->second; mAssets.erase(iter); - Save(); + Save().LogIfFailed(Editor::LogCat, "Asset was removed"); } @@ -316,7 +318,7 @@ namespace lunarium { namespace editor std::filesystem::path r = mpProject->MakeRelativeToAssets(to); asset->mLocation = r; - Save(); + Save().LogIfFailed(Editor::LogCat, "Asset was moved"); } bool ContentManager::IsValidAsset(nlohmann::json& node) diff --git a/src/run_modes/editor/panels/asset_browser.cpp b/src/run_modes/editor/panels/asset_browser.cpp index 250c69e..2e4f4e7 100644 --- a/src/run_modes/editor/panels/asset_browser.cpp +++ b/src/run_modes/editor/panels/asset_browser.cpp @@ -7,6 +7,8 @@ ******************************************************************************/ #include "asset_browser.h" +#include +#include #include #include #include @@ -48,6 +50,8 @@ namespace editor return false; } + //DoNewFolder(); + // Directory tree // TODO: Figure out a better way to size stuff other // than using this guess-work magic numbers @@ -69,6 +73,8 @@ namespace editor // Contents DoContentArea(wind_size); + HandlePopupActions(); + ImGui::End(); return true; } @@ -143,6 +149,14 @@ namespace editor mSyncTree = true; } + ImGui::SameLine(); + if (ImGui::ImageButton((ImTextureID)DataManager::mNewFolderIcon->GetGLTextureID64(), + ImVec2(DataManager::mNewFolderIcon->GetWidth(), DataManager::mNewFolderIcon->GetHeight()), + ImVec2(0, 0), ImVec2(1, 1), 4)) + { + mNewFolder = true; + } + ImGui::EndChild(); ImGui::Separator(); @@ -216,7 +230,11 @@ namespace editor // TODO: Buttons for creating/importing new assets ImGui::EndPopup(); } + } + + void AssetBrowser::DoNewFolder() + { if (ImGui::BeginPopupContextItem("New Folder Name")) { char name_buf[64] = "New Folder"; @@ -228,11 +246,24 @@ namespace editor mNewFolder = false; ImGui::CloseCurrentPopup(); } + + if (Core::Input().IsKeyDown(KeyCode::ESCAPE, true)) + { + mNewFolder = false; + ImGui::CloseCurrentPopup(); + } ImGui::EndPopup(); } + } + + void AssetBrowser::HandlePopupActions() + { if (mNewFolder) + { + DoNewFolder(); ImGui::OpenPopup("New Folder Name"); + } } void AssetBrowser::HandleAssetDrop(std::filesystem::path dir) @@ -243,12 +274,10 @@ namespace editor { EditorAsset* pAsset = *((EditorAsset**) payload->Data); // EditorAsset* pAsset = ((EditorAsset*) payload->Data); - Logger::Info(Editor::LogCat, "Dropping asset: %s - To: %s", - pAsset->GetFileLocation().stem().string().c_str(), dir.string().c_str()); + // Logger::Info(Editor::LogCat, "Dropping asset: %s - To: %s", + // pAsset->GetFileLocation().stem().string().c_str(), dir.string().c_str()); - // TODO: Handle moving the asset ContentManager::GetInstance().MoveAsset(pAsset, dir / pAsset->GetFileLocation().filename()); - Logger::Debug(Editor::LogCat, "Asset Location: %s", pAsset->GetFileLocation().string().c_str()); } ImGui::EndDragDropTarget(); } diff --git a/src/run_modes/editor/panels/asset_browser.h b/src/run_modes/editor/panels/asset_browser.h index 8a5023f..848f35a 100644 --- a/src/run_modes/editor/panels/asset_browser.h +++ b/src/run_modes/editor/panels/asset_browser.h @@ -46,12 +46,13 @@ namespace editor bool mSyncTree; private: - + void HandlePopupActions(); void HandleAssetDrop(std::filesystem::path dir); void DoDirTree(std::filesystem::path dir); void DoContentArea(ImVec2 wind_size); void DoContextMenu(); + void DoNewFolder(); }; } } diff --git a/src/run_modes/editor/panels/world_tree.cpp b/src/run_modes/editor/panels/world_tree.cpp index 03f3e22..7944355 100644 --- a/src/run_modes/editor/panels/world_tree.cpp +++ b/src/run_modes/editor/panels/world_tree.cpp @@ -7,16 +7,20 @@ ******************************************************************************/ #include "world_tree.h" +#include #include +#include +#include #include #include +#include namespace lunarium { namespace editor { WorldTree::WorldTree() - : Panel("World Tree", gui::PanelDockZone::DDZ_LEFT, true), mpWorld(nullptr) + : Panel("World Tree", gui::PanelDockZone::DDZ_LEFT, true), mpWorld(new lunarium::World), mDoNewEntity(false) { } @@ -42,21 +46,90 @@ namespace editor return false; } - if (ImGui::TreeNode("World Root")) + if (ImGui::TreeNode("World Root") && mpWorld) { - // TODO: Build tree of world contents + // List all world entities + // This will fail if we end up implementing child entities + // In that case this needs to become recursive + int idx = 0; + for (auto iter = mpWorld->EntitiesBegin(); !mpWorld->EntitiesIsEnd(iter); iter++, idx++) + { + std::string name = "Entity"; + name += std::to_string(idx); + if ((*iter)->HasComponent()) + { + name = (*iter)->GetComponent().Info; + } + + if (ImGui::TreeNode(name.c_str())) + { + + ImGui::TreePop(); + } + } ImGui::TreePop(); } + + DoContextMenu(); + HandlePopupEvents(); + ImGui::End(); + return true; + } + + void WorldTree::DoContextMenu() + { if (ImGui::BeginPopupContextWindow(0, ImGuiPopupFlags_MouseButtonRight)) { - + if (ImGui::Button("Create New Entity")) + { + if (!mpWorld) + { + Logger::Warn(Editor::LogCat, "Can not create new entity - World pointer is null"); + } + else + { + mDoNewEntity = true; + } + } ImGui::EndPopup(); } + } - ImGui::End(); - return true; + void WorldTree::HandlePopupEvents() + { + if (mDoNewEntity) + { + PopupNewEntity(); + ImGui::OpenPopup("New Entity"); + } + } + + void WorldTree::PopupNewEntity() + { + if (ImGui::BeginPopupContextItem("New Entity")) + { + char name_buf[64] = "NewEntity"; + ImGui::TextUnformatted("Entity Name: "); + ImGui::SameLine(); + if (ImGui::InputText("##Entity Name", name_buf, 64, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue)) + { + LUUID id = mpWorld->CreateEntity(); + mpWorld->GetEntity(id)->AddComponent(); + TagComponent& tc = mpWorld->GetEntity(id)->GetComponent(); + tc.Info = name_buf; + mDoNewEntity = false; + ImGui::CloseCurrentPopup(); + } + + if (Core::Input().IsKeyDown(KeyCode::ESCAPE, true)) + { + mDoNewEntity = false; + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } } } } \ No newline at end of file diff --git a/src/run_modes/editor/panels/world_tree.h b/src/run_modes/editor/panels/world_tree.h index d6dcacc..d37fa44 100644 --- a/src/run_modes/editor/panels/world_tree.h +++ b/src/run_modes/editor/panels/world_tree.h @@ -29,6 +29,15 @@ namespace editor private: lunarium::World* mpWorld; + + // Context menus + void DoContextMenu(); + + // Popup events + bool mDoNewEntity; + + void HandlePopupEvents(); + void PopupNewEntity(); }; } } diff --git a/src/world/components.h b/src/world/components.h index acbb5b5..c96dfec 100644 --- a/src/world/components.h +++ b/src/world/components.h @@ -34,7 +34,13 @@ namespace lunarium { glm::vec3 Position = { 0.0f, 0.0f, 0.0f }; glm::vec3 Rotation = { 0.0f, 0.0f, 0.0f }; - glm::vec3 Scale = { 1.0f, 1.0f, 1.0f };; + glm::vec3 Scale = { 1.0f, 1.0f, 1.0f }; + + TransformComponent() + : Position(glm::vec3(0.0f, 0.0f, 0.0f)), Rotation(glm::vec3(0.0f, 0.0f, 0.0f)), Scale(glm::vec3(1.0f, 1.0f, 1.0f)) + { + + } glm::mat4 GetTransform() { diff --git a/src/world/entity.h b/src/world/entity.h index ffb4bdd..3e05b7e 100644 --- a/src/world/entity.h +++ b/src/world/entity.h @@ -19,7 +19,6 @@ namespace lunarium class Entity { public: - // TODO: Maybe change this to take the World instead of the registry Entity(World& w); Entity(World& w, LUUID uuid, entt::entity handle = entt::null); diff --git a/src/world/world.cpp b/src/world/world.cpp index c7b780a..74a65f8 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -76,23 +76,39 @@ namespace lunarium //Logger::Error(LogCategory::GAME_SYSTEM, "World::CreateEntity not implemented!"); Entity* new_ent = new Entity(*this); - if (mEntities.find(new_ent->GetUUID()) != mEntities.end()) + if (mEntitiesByUUID.find(new_ent->GetUUID()) != mEntitiesByUUID.end()) { Logger::Warn(LogCategory::GAME_SYSTEM, "UUID collision when creating new entity! UUID: %d", new_ent->GetUUID()); } - mEntities[new_ent->GetUUID()] = new_ent; + mEntitiesByUUID[new_ent->GetUUID()] = new_ent; + mEntities.push_back(new_ent); return new_ent->GetUUID(); } Entity* World::GetEntity(LUUID id) { - if (mEntities.find(id) == mEntities.end()) + if (mEntitiesByUUID.find(id) == mEntitiesByUUID.end()) { Logger::Warn(LogCategory::GAME_SYSTEM, "Entity with id: %d not found.", id); } - return mEntities[id]; + return mEntitiesByUUID[id]; + } + + unsigned int World::GetNumEntities() const + { + return mEntities.size(); + } + + std::vector::iterator World::EntitiesBegin() + { + return mEntities.begin(); + } + + bool World::EntitiesIsEnd(std::vector::iterator& iter) + { + return iter == mEntities.end(); } } \ No newline at end of file diff --git a/src/world/world.h b/src/world/world.h index 7648b07..1bd77a4 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -32,6 +32,12 @@ namespace lunarium namespace lunarium { + struct EntityIterator + { + Entity* mEntity; + int Index; + }; + class World { public: @@ -65,20 +71,25 @@ namespace lunarium entt::registry* GetEntityRegistry(); LUUID CreateEntity(); Entity* GetEntity(LUUID id); + unsigned int GetNumEntities() const; + std::vector::iterator EntitiesBegin(); + bool EntitiesIsEnd(std::vector::iterator& iter); private: entt::registry mECSRegistry; - //Camera* mpCamera; - //std::vector mWorldObjects; + std::vector mEntities; lunarium::Script* mpWorldScript; + + // TODO: Move these into a TileMap class? + // This would allow worlds to support non-tile based levels/worlds Sizei mRegionSize; // in tiles Sizei mWorldSize; // num regions ex. 10x10 Vec2i mActiveRegion; // TEST STUFF - std::map mEntities; + std::map mEntitiesByUUID; };