mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 20:39:18 +02:00
Add UID assignment on object creation
This commit is contained in:
@@ -13,7 +13,9 @@ entt::entity ECS::CreateObject()
|
|||||||
{
|
{
|
||||||
const auto e = world_.create();
|
const auto e = world_.create();
|
||||||
world_.emplace<ECSComponent::Transform>(e);
|
world_.emplace<ECSComponent::Transform>(e);
|
||||||
world_.emplace<ECSComponent::Identification>(e);
|
// add UID
|
||||||
|
auto id = world_.emplace<ECSComponent::Identification>(e);
|
||||||
|
id.Id = nextId_++;
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,9 @@
|
|||||||
class ECS final
|
class ECS final
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
entt::registry world_;
|
entt::registry world_; // scene registry
|
||||||
|
std::uint64_t nextId_ = 1; // 0 is invalid/none
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
@@ -147,5 +149,5 @@ class ECS final
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern ECS& GetComponentSystem();
|
extern ECS& GetComponentSystem();
|
||||||
#define CS GetComponentSystem();
|
#define CS GetComponentSystem()
|
||||||
#endif // EU07_ECS_H
|
#endif // EU07_ECS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user