-
Notifications
You must be signed in to change notification settings - Fork 144
Proposal: New ECS implementation + bundles and accessors #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hmm but if I understand the bundle approach correctly that would mean that any bundle query would query every single component that constitutes an entity type, which would defeat the whole purpose of ECS of only accessing the data you need right? |
The bundles would be optimized by special-casing them in the ECS so that We could also remove the getter/setter methods for components, but we'd need to leave functions like |
Should we also mention the event graph plans here? |
Exactly what I'd love to have. |
@caelunshun do you have todo list, if some of us want to help out? Also should the addition of components and entities not be queued up and processed after the query anyway. Ie the ECS don't insert/remove components or spawn new entities until all queries are dropped (kinda like lock)? |
How about not having bundles for each entity type but instead bundles for capabilities? E.g. a |
In implementing custom components for plugins, I realized that the ECS implementation needs to allocate custom plugin components within the plugin's linear memory. We thus have two options:
hecs
; orI am inclined to proceed with the latter because a custom ECS designed to work with the plugin system will be more flexible. Also, I have some ideas to solve #397 that we can integrate into the new ECS.
New ECS design
This is my plan for the new ECS:
hecs
uses archetypes. Sparse sets are easier and safer to implement than archetypes, and they have better performance characteristics when inserting/deleting components at a high frequency. (Our component-based event system does a lot of insertions and deletions, which convinces me that sparse sets are the best choice for Feather.)Component
trait will not be implemented for allT
; each component type needs to implement the trait instead. While this is less convenient in some areas, it prevents querying for types that are not components, like bundles. (We'll provide a derive macro forComponent
to avoid too much boilerplate.)Bundle
struct, which is the set of components it spawns with. The ECS crate provides a derive macro that generates an accessor struct for the bundle that can be queried. The bundle accessor is a wrapper forEntityId
that provides convenience methods to access components, and it can also include methods that access multiple components, likeitem_in_main_hand()
. In code, this looks like:I opened this issue to collect feedback in the proposal, in the hope that we can resolve any issues with it before I implement something we don't want. So feedback is welcome from all.
The text was updated successfully, but these errors were encountered: