From 4ec877f656f5dda468de56d919a6eab2267dc9be Mon Sep 17 00:00:00 2001 From: SweetId <2630750+SweetId@users.noreply.github.com> Date: Thu, 12 Oct 2023 19:15:02 -0400 Subject: [PATCH] add EditorNameComponent by default --- include/NazaraEditor/Core/Application/BaseApplication.hpp | 2 +- src/NazaraEditor/Core/Application/BaseApplication.cpp | 6 +++++- src/NazaraEditor/Editor/main.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/NazaraEditor/Core/Application/BaseApplication.hpp b/include/NazaraEditor/Core/Application/BaseApplication.hpp index 4e68cfe..13c22bc 100644 --- a/include/NazaraEditor/Core/Application/BaseApplication.hpp +++ b/include/NazaraEditor/Core/Application/BaseApplication.hpp @@ -37,7 +37,7 @@ namespace Nz bool CloseLevel(); bool OpenLevel(const std::filesystem::path& path); - entt::handle CreateEntity(); + entt::handle CreateEntity(const std::string& name); template void RegisterWindow() diff --git a/src/NazaraEditor/Core/Application/BaseApplication.cpp b/src/NazaraEditor/Core/Application/BaseApplication.cpp index dab2efd..27f8bb3 100644 --- a/src/NazaraEditor/Core/Application/BaseApplication.cpp +++ b/src/NazaraEditor/Core/Application/BaseApplication.cpp @@ -1,4 +1,5 @@ #include +#include namespace Nz { @@ -49,9 +50,12 @@ namespace Nz return m_level; } - entt::handle EditorBaseApplication::CreateEntity() + entt::handle EditorBaseApplication::CreateEntity(const std::string& name) { entt::handle entity = m_level.CreateEntity(); + Nz::EditorNameComponent& nameComponent = entity.emplace(); + nameComponent.SetName(name); + entity.emplace(); OnEntityCreated(entity); diff --git a/src/NazaraEditor/Editor/main.cpp b/src/NazaraEditor/Editor/main.cpp index ec8948a..fa0ef9f 100644 --- a/src/NazaraEditor/Editor/main.cpp +++ b/src/NazaraEditor/Editor/main.cpp @@ -44,7 +44,7 @@ int WinMain(int argc, char* argv[]) .type(entt::type_hash::value()) .func<&Nz::ReflectComponent, Nz::EditorNameComponent>>(entt::hashed_string("Reflect")); - entt::handle entity = app.CreateEntity(); + entt::handle entity = app.CreateEntity("TestEntity"); return app.Run(); } \ No newline at end of file