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