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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user