-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add a simple method to get a ComponentId for a given Component type #5060
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to use
Description
What problem does this solve or what need does it fill?
Being able to extract the ComponentId for a given component of type C is surprisingly unintuitive.
What solution would you like?
Create a public method on Component that mirrors Bundle::component_ids().
EDIT: see below; this isn't the right API. These methods should live on World and Components instead.
What alternative(s) have you considered?
- Use
world.init_component::<C>(). This is unintuitive, but basically works. - Convert the component type into a bundle, and call
(C, )::component_ids(&mut components, &mut storages).iter().next().unwrap(). Which is more than a little cursed.
Additional context
Discovered while working on #1481 with @plof27.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to use