From 93ba567d6724aed796e637c874cfbc9c554c409f Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Sun, 17 Jan 2021 19:22:32 -0700 Subject: [PATCH 1/2] change 'components' to 'bundles' where it makes sense semantically --- crates/bevy_ecs/src/core/world_builder.rs | 12 ++++++------ crates/bevy_transform/src/hierarchy/child_builder.rs | 11 ++++------- .../src/hierarchy/world_child_builder.rs | 8 ++++---- src/lib.rs | 2 +- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/crates/bevy_ecs/src/core/world_builder.rs b/crates/bevy_ecs/src/core/world_builder.rs index 18590683a25c1..471826e4f2d78 100644 --- a/crates/bevy_ecs/src/core/world_builder.rs +++ b/crates/bevy_ecs/src/core/world_builder.rs @@ -42,24 +42,24 @@ impl<'a> WorldBuilder<'a> { self } - pub fn with_bundle(&mut self, components: impl DynamicBundle) -> &mut Self { + pub fn with_bundle(&mut self, bundle: impl DynamicBundle) -> &mut Self { self.world - .insert(self.current_entity.expect("Cannot add component because the 'current entity' is not set. You should spawn an entity first."), components) + .insert(self.current_entity.expect("Cannot add bundle because the 'current entity' is not set. You should spawn an entity first."), bundle) .unwrap(); self } - pub fn spawn_batch(&mut self, components_iter: I) -> &mut Self + pub fn spawn_batch(&mut self, bundle_iter: I) -> &mut Self where I: IntoIterator, I::Item: Bundle, { - self.world.spawn_batch(components_iter); + self.world.spawn_batch(bundle_iter); self } - pub fn spawn(&mut self, components: impl DynamicBundle) -> &mut Self { - self.current_entity = Some(self.world.spawn(components)); + pub fn spawn(&mut self, bundle: impl DynamicBundle) -> &mut Self { + self.current_entity = Some(self.world.spawn(bundle)); self } diff --git a/crates/bevy_transform/src/hierarchy/child_builder.rs b/crates/bevy_transform/src/hierarchy/child_builder.rs index 81267f799e154..ab1ce6216de35 100644 --- a/crates/bevy_transform/src/hierarchy/child_builder.rs +++ b/crates/bevy_transform/src/hierarchy/child_builder.rs @@ -69,8 +69,8 @@ impl Command for PushChildren { } impl<'a> ChildBuilder<'a> { - pub fn spawn(&mut self, components: impl DynamicBundle + Send + Sync + 'static) -> &mut Self { - self.commands.spawn(components); + pub fn spawn(&mut self, bundle: impl DynamicBundle + Send + Sync + 'static) -> &mut Self { + self.commands.spawn(bundle); self.push_children .children .push(self.commands.current_entity().unwrap()); @@ -85,11 +85,8 @@ impl<'a> ChildBuilder<'a> { self.push_children.parent } - pub fn with_bundle( - &mut self, - components: impl DynamicBundle + Send + Sync + 'static, - ) -> &mut Self { - self.commands.with_bundle(components); + pub fn with_bundle(&mut self, bundle: impl DynamicBundle + Send + Sync + 'static) -> &mut Self { + self.commands.with_bundle(bundle); self } diff --git a/crates/bevy_transform/src/hierarchy/world_child_builder.rs b/crates/bevy_transform/src/hierarchy/world_child_builder.rs index b2122fe135f5c..d5477614ae5f5 100644 --- a/crates/bevy_transform/src/hierarchy/world_child_builder.rs +++ b/crates/bevy_transform/src/hierarchy/world_child_builder.rs @@ -8,14 +8,14 @@ pub struct WorldChildBuilder<'a, 'b> { } impl<'a, 'b> WorldChildBuilder<'a, 'b> { - pub fn spawn(&mut self, components: impl DynamicBundle + Send + Sync + 'static) -> &mut Self { + pub fn spawn(&mut self, bundle: impl DynamicBundle + Send + Sync + 'static) -> &mut Self { let parent_entity = self .parent_entities .last() .cloned() .expect("There should always be a parent at this point."); self.world_builder - .spawn(components) + .spawn(bundle) .with_bundle((Parent(parent_entity), PreviousParent(parent_entity))); let entity = self.world_builder.current_entity.unwrap(); { @@ -38,9 +38,9 @@ impl<'a, 'b> WorldChildBuilder<'a, 'b> { pub fn with_bundle( &mut self, - components: impl DynamicBundle + Send + Sync + 'static, + bundle: impl DynamicBundle + Send + Sync + 'static, ) -> &mut Self { - self.world_builder.with_bundle(components); + self.world_builder.with_bundle(bundle); self } diff --git a/src/lib.rs b/src/lib.rs index 9c602e8244360..a659925e163cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ //! and it gets more powerful every day! //! //! ### This Crate -//! The `bevy` crate is just a container crate that makes it easier to consume Bevy components. +//! The `bevy` crate is just a container crate that makes it easier to consume Bevy subcrates. //! The defaults provide a "full" engine experience, but you can easily enable / disable features //! in your project's `Cargo.toml` to meet your specific needs. See Bevy's `Cargo.toml` for a full list of features available. //! From 41ef2dfde901e457ea5f8fa2d06a726fe44b7dc8 Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Sun, 17 Jan 2021 19:38:25 -0700 Subject: [PATCH 2/2] vscode's auto-invocation of rustfmt missed this somehow --- crates/bevy_transform/src/hierarchy/world_child_builder.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/bevy_transform/src/hierarchy/world_child_builder.rs b/crates/bevy_transform/src/hierarchy/world_child_builder.rs index d5477614ae5f5..858532739d433 100644 --- a/crates/bevy_transform/src/hierarchy/world_child_builder.rs +++ b/crates/bevy_transform/src/hierarchy/world_child_builder.rs @@ -36,10 +36,7 @@ impl<'a, 'b> WorldChildBuilder<'a, 'b> { self } - pub fn with_bundle( - &mut self, - bundle: impl DynamicBundle + Send + Sync + 'static, - ) -> &mut Self { + pub fn with_bundle(&mut self, bundle: impl DynamicBundle + Send + Sync + 'static) -> &mut Self { self.world_builder.with_bundle(bundle); self }