From 1fcb4ccca024fba3ef8cfc855b86cd5fe074ed4d Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sun, 15 Mar 2026 00:24:18 +0100 Subject: [PATCH] Add UID assignment on object creation --- entitysystem/ecs.cpp | 4 +++- entitysystem/ecs.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/entitysystem/ecs.cpp b/entitysystem/ecs.cpp index 99b6c292..8de653c0 100644 --- a/entitysystem/ecs.cpp +++ b/entitysystem/ecs.cpp @@ -13,7 +13,9 @@ entt::entity ECS::CreateObject() { const auto e = world_.create(); world_.emplace(e); - world_.emplace(e); + // add UID + auto id = world_.emplace(e); + id.Id = nextId_++; return e; } diff --git a/entitysystem/ecs.h b/entitysystem/ecs.h index 901c035f..444666a8 100644 --- a/entitysystem/ecs.h +++ b/entitysystem/ecs.h @@ -13,7 +13,9 @@ class ECS final { private: - entt::registry world_; + entt::registry world_; // scene registry + std::uint64_t nextId_ = 1; // 0 is invalid/none + public: // @@ -147,5 +149,5 @@ class ECS final }; extern ECS& GetComponentSystem(); -#define CS GetComponentSystem(); +#define CS GetComponentSystem() #endif // EU07_ECS_H