16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 03:09:18 +02:00

Add UID assignment on object creation

This commit is contained in:
2026-03-15 00:24:18 +01:00
parent 5f1ec0401a
commit 1fcb4ccca0
2 changed files with 7 additions and 3 deletions

View File

@@ -13,7 +13,9 @@ entt::entity ECS::CreateObject()
{
const auto e = world_.create();
world_.emplace<ECSComponent::Transform>(e);
world_.emplace<ECSComponent::Identification>(e);
// add UID
auto id = world_.emplace<ECSComponent::Identification>(e);
id.Id = nextId_++;
return e;
}

View File

@@ -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