I am learning about ECS reading, reading about specs and storage. Unfortunately the docs are several notches above my head, and I this thread does not reply to my question.
How does a storage work?
Why would you need a VecStorage and why default is the dense one?
As I understand it, each entity in the system consists of some combination of components, and each type of component is stored in a "storage" of some kind. So the basic idea is that if the entity has id 5, then its health component would be index five in the health storage, and its position component would be index five in another storage, namely the position storage. However the entity might not have an inventory, so index five in the inventory storage would be empty.
Depending on how many entities have a certain component, the storage will either have a few or many empty slots, and different storages are optimized for different numbers of empty slots. For example, a vector only supports iterating through the entire list, which is expensive if only 1% of entities have that component. On the other hand, a
HashMapStorage would allow you to instantly jump across many empty slots, which makes it good for rare components.
I watched this talk yesterday, and it really helped me understand some things about ECSes that I did not understand before. I can certainly recommend it.
Thank you Alice, it makes a lot of sense. I will certainly watch it!
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.