Created
April 21, 2022 23:27
-
-
Save danielytics/73c77a600b22b1be71071f849f52e399 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ∁ | |
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