Skip to content

Implement Bundle for every component and simplify API #2974

@alice-i-cecile

Description

@alice-i-cecile

What problem does this solve or what need does it fill?

The distinction between components and bundles is often lost on new users, and we end up with a lot of redundant, nearly-duplicated APIs.

What solution would you like?

Implement Bundle for every Component, representing the one element bundle containing only that component.

Remove all duplicated API surfaces, keeping the Component names but accepting bundles:

  • insert and insert_bundle -> insert
  • remove and remove_bundle -> remove
  • remove spawn_bundle; there's now less boilerplate and the design of this routinely confuses the mental model for new users

There are some additional benefits:

  • we can remove the #[bundle] annotation in the #[derive(Bundle)] crate
  • spawn_batch becomes much easier to work with for simple 0 and 1 component cases
  • users cannot accidentally derive component on a standard bundle, as conflicting impls will exist

What alternative(s) have you considered?

Just leave it as is.

Additional context

Design credit to @BoxyUwU, @TheRawMeatball and @Frizi. Originally described here: https://hackmd.io/EvBrYLQeQbCjE2eycBlo3w

Made possible by #2254!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions