diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2023-11-07 16:19:39 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2023-11-15 13:16:34 -0500 |
| commit | 546e179d6095d07342b9b8f29f3b20eaaf3cf274 (patch) | |
| tree | 2b362e7f1722563e5255c1532e88421db1c4ea1e | |
| parent | f18bcfbb4ff2bedae2f4565b823f822a31b1344c (diff) | |
Expose method to get CompGrBinds by GrBindsHandle.
This is useful because if you are working with an instance,
the instance has a GrBindsHandle but not the EntityHandle that
owns the CompGrBinds
| -rw-r--r-- | src/ecs.cpp | 7 | ||||
| -rw-r--r-- | src/ecs.hpp | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/ecs.cpp b/src/ecs.cpp index ee9201e..16a5b58 100644 --- a/src/ecs.cpp +++ b/src/ecs.cpp @@ -331,6 +331,13 @@ CompGrBinds *ECS_GetGrBinds(EntityHandle entHandle) { auto i = Buckets_GetItemIndex(grBindsHandle_t); return &Comp_GrBinds_BucketContainer.buckets[b].compGrBinds[i]; } +CompGrBinds *ECS_GetGrBinds(GrBindsHandle grBindsHandle) { + if (grBindsHandle == GrBindsHandle_MAX) return nullptr; + GrBindsHandle_T grBindsHandle_t{static_cast<GrBindsHandle_T>(grBindsHandle)}; + auto b = Buckets_GetBucketIndex(grBindsHandle_t); + auto i = Buckets_GetItemIndex(grBindsHandle_t); + return &Comp_GrBinds_BucketContainer.buckets[b].compGrBinds[i]; +} uint64_t ECS_GetGrBinds_BucketCount() { return Comp_GrBinds_BucketContainer.bucketCounter + 1; diff --git a/src/ecs.hpp b/src/ecs.hpp index 480ba0c..28e52ad 100644 --- a/src/ecs.hpp +++ b/src/ecs.hpp @@ -29,6 +29,7 @@ Entity *ECS_GetEntities(uint64_t bucketIndex, uint64_t &itemCount); CompGrBinds &ECS_CreateGrBinds(EntityHandle entHandle); CompGrBinds *ECS_GetGrBinds(EntityHandle entHandle); +CompGrBinds *ECS_GetGrBinds(GrBindsHandle grBindsHandle); uint64_t ECS_GetGrBinds_BucketCount(); CompGrBinds *ECS_GetGrBinds(uint64_t bucketIndex, uint64_t &itemCount); |
