diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-03-27 11:58:47 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-03-27 11:58:47 -0400 |
| commit | e4604d5b84a71ac3cc8fe1a148d0a6250c7a715c (patch) | |
| tree | 0f768c8b5d0b96cb459f92c7795c6c9353710ed1 /src/ecs.cpp | |
| parent | 11057d2aa423f9b565f3fead4c260999d1bdb53e (diff) | |
pke: generate uuid and save to project+scene files
Diffstat (limited to 'src/ecs.cpp')
| -rw-r--r-- | src/ecs.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ecs.cpp b/src/ecs.cpp index 4174bd0..048669d 100644 --- a/src/ecs.cpp +++ b/src/ecs.cpp @@ -5,6 +5,7 @@ #include "game-settings.hpp" #include "math-helpers.hpp" #include "physics.hpp" +#include "pk.h" #include "window.hpp" #include <btBulletDynamicsCommon.h> @@ -68,6 +69,10 @@ void ECS_Init() { } Entity_Base *ECS_CreateGenericEntity() { + /* 2025-03-26 - JCB + * The only place this is called immediately calls ECS_CreateEntity afterwards. + * There is no need to generate a uuid + */ pk_handle newHandle{Buckets_NewHandle(ecs.bc.generics)}; return &ecs.bc.generics.buckets[newHandle.bucketIndex][newHandle.itemIndex]; } @@ -78,6 +83,7 @@ EntityHandle ECS_CreateEntity(Entity_Base *entity, Entity_Base *parentEntity) { EntityHandle entityHandle{Buckets_NewHandle(ecs.bc.entityPtrs)}; entity->handle = entityHandle; if (parentEntity) entity->parentHandle = parentEntity->handle; + if (entity->uuid == pk_uuid_max || entity->uuid == pk_uuid_zed) entity->uuid = pk_uuid_new_v7(); ecs.bc.entityPtrs.buckets[entityHandle.bucketIndex][entityHandle.itemIndex] = entity; return entityHandle; } @@ -443,6 +449,9 @@ CompInstance *ECS_CreateInstance(Entity_Base *entity, CompGrBinds *entityTypeGrB new (comp) CompInstance{}; comp->entHandle = entity->handle; comp->instanceHandle = instanceHandle; + // TODO this should be passed in - currently generating a new one each time + // Consider making a Component_Base that has a UUID, and pass in similar to ECS_CreateEntity + if (comp->uuid == pk_uuid_zed || comp->uuid == pk_uuid_max) comp->uuid = pk_uuid_new_v7(); if (entityTypeGrBinds != nullptr) { comp->grBindsHandle = entityTypeGrBinds->grBindsHandle; |
