3.0 KiB
| title | pull_requests | |
|---|---|---|
| `StaticBundle` has been split off from `Bundle` |
|
The StaticBundle trait has been split off from the Bundle trait to avoid conflating the concept of a type whose values can be inserted into an entity (Bundle) with the concept of a statically known set of components (StaticBundle). This required the update of existing APIs that were using Bundle as a statically known set of components to use StaticBundle instead.
Changes for most users will be zero or pretty minimal, since #[derive(Bundle)] will automatically derive StaticBundle and most types that implemented Bundle will now also implement StaticBundle. The main exception will be generic APIs or types, which now will need to update or add a bound on StaticBundle. For example:
// 0.16
#[derive(Bundle)]
struct MyBundleWrapper<T: Bundle> {
inner: T
}
fn my_register_bundle<T: Bundle>(world: &mut World) {
world.register_bundle::<T>();
}
// 0.17
#[derive(Bundle)]
struct MyBundleWrapper<T: Bundle + StaticBundle> { // Add a StaticBundle bound
inner: T
}
fn my_register_bundle<T: StaticBundle>(world: &mut World) { // Replace Bundle with StaticBundle
world.register_bundle::<T>();
}
The following APIs now require the StaticBundle trait instead of the Bundle trait:
World::register_bundle, which has been renamed toWorld::register_static_bundle- the
Btype parameter ofEntityRefExceptandEntityMutExcept EntityClonerBuilder::allowandEntityClonerBuilder::denyEntityCommands::clone_componentsandEntityCommands::move_componentsEntityWorldMut::clone_componentsandEntityWorldMut::move_components- the
Btype parameter ofIntoObserverSystem,Trigger,App::add_observer,World::add_observer,Observer::new,Commands::add_observer,EntityCommands::observeandEntityWorldMut::observe EntityWorldMut::remove_recursiveandCommands::remove_recursiveEntityCommands::remove,EntityCommands::remove_if,EntityCommands::try_remove_if,EntityCommands::try_remove,EntityCommands::remove_with_requires,EntityWorldMut::removeandEntityWorldMut::remove_with_requiresEntityWorldMut::takeEntityWorldMut::retainandEntityCommands::retain
The following APIs now require the StaticBundle trait in addition to the Bundle trait:
Commands::spawn_batch,Commands::insert_batch,Commands::insert_batch_if_new,Commands::try_insert_batch,Commands::try_insert_batch_if_new,bevy::ecs::command::spawn_batch,bevy::ecs::command::insert_batch,World::spawn_batch,World::insert_batch,World::insert_batch_if_new,World::try_insert_batchandWorld::try_insert_batch_if_newReflectBundle::new,impl FromType<B>forReflectBundleand#[reflect(Bundle)]ExtractComponent::Out
Moreover, some APIs have been renamed:
World::register_bundlehas been renamed toWorld::register_static_bundle- the
DynamicBundletrait has been renamed toComponentsFromBundle