Supporting Entity Pooling - disabled entities, setting exclude-by-default components, and more? #1103
BrodyHiggerson
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
Soooooo....... I thought about this a little. Before flooding you with a wall of text 😅 let me ask this: are you familiar with the new entity storage and the way it works? Cuz I think it fits somehow your request or is a good starting point for a proper implementation at least. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all,
I have a set of archetypes of entities built up by processing json and creating one entity per file in a separate registry, keyed to an entt::hashed_string, with all of the components and their values set up as per that file, using entt's meta. When I want to create one of those entities, I simply pass in e.g. "Projectile"_hs, and my entity spawning code will find the archetypal entity keyed to that name, and then clone it into the provided, real-world registry, component-by-component.
In situations where I'd like to create a lot of these, the stamp can be a bottleneck.
I propose instead some possible features that could help in this and other situations:
An advantage of this approach is that we could potentially add a signal for when the entity is enabled/disabled, and execute that either for the entity itself only, or to call it on each component that it has. That way, if you wanted to react to the construction of, say, the projectile's ProjectileComponent, you could react to the enabling of it instead if it's going to be pooled (because it might not be useful to react to the creation of a component for an entity that's disabled, for example). But those are just some thoughts on the signalling, that could be totally different.
Either way, the goal here is to avoid requiring the user/game code to remember to always pass in the right exclude to avoid accidentally iterating entities still in the pool. Entity pooling should be able to be transparent from that POV, in my opinion - you ask for a Projectile in game code, you get a Projectile! And that's it, you shouldn't care how it was made/pooled.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions