From 546e179d6095d07342b9b8f29f3b20eaaf3cf274 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Tue, 7 Nov 2023 16:19:39 -0500 Subject: 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 --- src/ecs.cpp | 7 +++++++ src/ecs.hpp | 1 + 2 files changed, 8 insertions(+) (limited to 'src') 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)}; + 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); -- cgit v1.2.3