Skip to content

Instantly share code, notes, and snippets.

@danielytics
Created April 21, 2022 23:27
Show Gist options
  • Save danielytics/73c77a600b22b1be71071f849f52e399 to your computer and use it in GitHub Desktop.
Save danielytics/73c77a600b22b1be71071f849f52e399 to your computer and use it in GitHub Desktop.
using storage_type = typename entt::storage_traits<entt::entity, MyComponent::storage_type;
storage_type::const_iterable g_iterable;
storage_type::const_iterable::const_iterator g_iterator;
extern "C" void setup ()
{
const auto& storage = registry.storage<MyComponent>();
g_iterable = storage.each();
g_iterator = g_iterable.begin();
}
extern "C" std::uint32_t get_next (const MyComponent** component)
{
if (g_iterator != g_iterable.end()) {
const auto&& [entity, comp] = *g_iterator;
++g_iterator;
*component = &comp;
return static_cast<std::uint32_t>(entity);
} else {
*component = nullptr;
return static_cast<std::uint32_t>(entt::entity{entt::null});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment