Change 'components' to 'bundles' where it makes sense semantically (#1257)

change 'components' to 'bundles' where it makes sense semantically
This commit is contained in:
Nathan Stocks 2021-01-18 17:50:36 -07:00 committed by GitHub
parent 3c5f1f8a80
commit a0475e9ad5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 21 deletions

View File

@ -42,24 +42,24 @@ impl<'a> WorldBuilder<'a> {
self 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 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(); .unwrap();
self self
} }
pub fn spawn_batch<I>(&mut self, components_iter: I) -> &mut Self pub fn spawn_batch<I>(&mut self, bundle_iter: I) -> &mut Self
where where
I: IntoIterator, I: IntoIterator,
I::Item: Bundle, I::Item: Bundle,
{ {
self.world.spawn_batch(components_iter); self.world.spawn_batch(bundle_iter);
self self
} }
pub fn spawn(&mut self, components: impl DynamicBundle) -> &mut Self { pub fn spawn(&mut self, bundle: impl DynamicBundle) -> &mut Self {
self.current_entity = Some(self.world.spawn(components)); self.current_entity = Some(self.world.spawn(bundle));
self self
} }

View File

@ -69,8 +69,8 @@ impl Command for PushChildren {
} }
impl<'a> ChildBuilder<'a> { impl<'a> ChildBuilder<'a> {
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 {
self.commands.spawn(components); self.commands.spawn(bundle);
self.push_children self.push_children
.children .children
.push(self.commands.current_entity().unwrap()); .push(self.commands.current_entity().unwrap());
@ -85,11 +85,8 @@ impl<'a> ChildBuilder<'a> {
self.push_children.parent self.push_children.parent
} }
pub fn with_bundle( pub fn with_bundle(&mut self, bundle: impl DynamicBundle + Send + Sync + 'static) -> &mut Self {
&mut self, self.commands.with_bundle(bundle);
components: impl DynamicBundle + Send + Sync + 'static,
) -> &mut Self {
self.commands.with_bundle(components);
self self
} }

View File

@ -8,14 +8,14 @@ pub struct WorldChildBuilder<'a, 'b> {
} }
impl<'a, 'b> 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 let parent_entity = self
.parent_entities .parent_entities
.last() .last()
.cloned() .cloned()
.expect("There should always be a parent at this point."); .expect("There should always be a parent at this point.");
self.world_builder self.world_builder
.spawn(components) .spawn(bundle)
.with_bundle((Parent(parent_entity), PreviousParent(parent_entity))); .with_bundle((Parent(parent_entity), PreviousParent(parent_entity)));
let entity = self.world_builder.current_entity.unwrap(); let entity = self.world_builder.current_entity.unwrap();
{ {
@ -36,11 +36,8 @@ impl<'a, 'b> WorldChildBuilder<'a, 'b> {
self self
} }
pub fn with_bundle( pub fn with_bundle(&mut self, bundle: impl DynamicBundle + Send + Sync + 'static) -> &mut Self {
&mut self, self.world_builder.with_bundle(bundle);
components: impl DynamicBundle + Send + Sync + 'static,
) -> &mut Self {
self.world_builder.with_bundle(components);
self self
} }

View File

@ -26,7 +26,7 @@
//! and it gets more powerful every day! //! and it gets more powerful every day!
//! //!
//! ### This Crate //! ### 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 //! 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. //! in your project's `Cargo.toml` to meet your specific needs. See Bevy's `Cargo.toml` for a full list of features available.
//! //!