What is the use case for having multiple pools? Is it just organizational or there are other reasons for having multiple pools.
I ask because my pool is just a single uni-pool but looking at your example projects I see that you split pools sometimes. For example, in Entitas-Shmup, you have a core pool, an input pool and a bullet pool. It makes sense from an organizational perspective, but I was wondering about other utilities.
Advanced pool usage would make a great additional wiki article as well.
+1
My recent answer from the chat
When you can identify certain areas in your game that are decoupled from each other it can make sense to use separate pools for those. I explain why:
Imagine a Match 3 game where you have a grid of colored pieces that you have to match. You鈥檒l probably end up having components like Position, Color, Movable, Matchable, etc. Scale this up to a big game with tons of features and you might have 100+ Components only related to things those colored pieces can do. In order to be able to add any of those components to an entity, the entity gets created with a capacity to hold these 100+ components.
Now imagine you won a game and you return to a scrollable map where you see all the levels you played, and all the levels ahead of you. Now components like PlayerLives, LevelWon, Currency, etc are getting relevant. You might only have 10 or 20 Components related to the meta game.
If you have only on single Pool, an entity which you create is able to hold the 100+ components and the 20 components of the meta game, but you know for sure that you never will add any of those core game components. That is a waste of memory and each entity in the meta game can actually be much smaller. Other way around: you know for sure that in the coregame you will never add any of those PlayerLives or Currency components. That鈥檚 why you want to use a coregame pool and and a metagame pool. This step is made to reduce the memory footprint of entities.
[...]
Limitations to multiple pools:
An entity created in one pool can only work with components assigned to this pool. The good thing is, a component can be assigned to multiple pools and can therefore be used in all of them
I'm currently re-working the wiki. This questions definitely deserves a spot in the FAQ :)
see #103
Thanks for the clarification Simon. If you're adding that to the wiki I'd also discuss the proper way to clear out pool like we discussed when we were talking about how to restart a game.
I'll close this ticket out as you have #103 to track this.
Here's an example how to use a component in multiple pools
[Core, Meta, UI]
public class MyComponent : IComponent {
....
}
Most helpful comment
My recent answer from the chat