Skip to content

Commit 5d4a725

Browse files
committed
Accept Bundles for insert and remove. Deprecate insert_bundle and remove_bundle
1 parent 1a2aedd commit 5d4a725

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+460
-551
lines changed

benches/benches/bevy_ecs/components/add_remove_big_sparse_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Benchmark {
2727
entities.push(
2828
world
2929
.spawn()
30-
.insert_bundle((
30+
.insert((
3131
A(Mat4::from_scale(Vec3::ONE)),
3232
B(Mat4::from_scale(Vec3::ONE)),
3333
C(Mat4::from_scale(Vec3::ONE)),

benches/benches/bevy_ecs/components/add_remove_big_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Benchmark {
2626
entities.push(
2727
world
2828
.spawn()
29-
.insert_bundle((
29+
.insert((
3030
A(Mat4::from_scale(Vec3::ONE)),
3131
B(Mat4::from_scale(Vec3::ONE)),
3232
C(Mat4::from_scale(Vec3::ONE)),

benches/benches/bevy_ecs/components/insert_simple_unbatched.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Benchmark {
2323
pub fn run(&mut self) {
2424
let mut world = World::new();
2525
for _ in 0..10_000 {
26-
world.spawn().insert_bundle((
26+
world.spawn().insert((
2727
Transform(Mat4::from_scale(Vec3::ONE)),
2828
Position(Vec3::X),
2929
Rotation(Vec3::X),

benches/benches/bevy_ecs/iteration/iter_frag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ macro_rules! create_entities {
66
#[derive(Component)]
77
struct $variants(f32);
88
for _ in 0..20 {
9-
$world.spawn().insert_bundle(($variants(0.0), Data(1.0)));
9+
$world.spawn().insert(($variants(0.0), Data(1.0)));
1010
}
1111
)*
1212
};

benches/benches/bevy_ecs/iteration/iter_frag_foreach.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ macro_rules! create_entities {
66
#[derive(Component)]
77
struct $variants(f32);
88
for _ in 0..20 {
9-
$world.spawn().insert_bundle(($variants(0.0), Data(1.0)));
9+
$world.spawn().insert(($variants(0.0), Data(1.0)));
1010
}
1111
)*
1212
};

benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ macro_rules! create_entities {
66
#[derive(Component)]
77
struct $variants(f32);
88
for _ in 0..20 {
9-
$world.spawn().insert_bundle((
9+
$world.spawn().insert((
1010
$variants(0.0),
1111
Data::<0>(1.0),
1212
Data::<1>(1.0),

benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide_sparse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'w> Benchmark<'w> {
3636
pub fn new() -> Self {
3737
let mut world = World::new();
3838
for _ in 0..5 {
39-
world.spawn().insert_bundle((
39+
world.spawn().insert((
4040
Data::<0>(1.0),
4141
Data::<1>(1.0),
4242
Data::<2>(1.0),

benches/benches/bevy_ecs/iteration/iter_frag_wide.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ macro_rules! create_entities {
66
#[derive(Component)]
77
struct $variants(f32);
88
for _ in 0..20 {
9-
$world.spawn().insert_bundle((
9+
$world.spawn().insert((
1010
$variants(0.0),
1111
Data::<0>(1.0),
1212
Data::<1>(1.0),

benches/benches/bevy_ecs/iteration/iter_frag_wide_sparse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'w> Benchmark<'w> {
3636
let mut world = World::new();
3737

3838
for _ in 0..5 {
39-
world.spawn().insert_bundle((
39+
world.spawn().insert((
4040
Data::<0>(1.0),
4141
Data::<1>(1.0),
4242
Data::<2>(1.0),

benches/benches/bevy_ecs/iteration/iter_simple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<'w> Benchmark<'w> {
2121

2222
// TODO: batch this
2323
for _ in 0..10_000 {
24-
world.spawn().insert_bundle((
24+
world.spawn().insert((
2525
Transform(Mat4::from_scale(Vec3::ONE)),
2626
Position(Vec3::X),
2727
Rotation(Vec3::X),

benches/benches/bevy_ecs/iteration/iter_simple_foreach.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<'w> Benchmark<'w> {
2121

2222
// TODO: batch this
2323
for _ in 0..10_000 {
24-
world.spawn().insert_bundle((
24+
world.spawn().insert((
2525
Transform(Mat4::from_scale(Vec3::ONE)),
2626
Position(Vec3::X),
2727
Rotation(Vec3::X),

benches/benches/bevy_ecs/iteration/iter_simple_foreach_sparse_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<'w> Benchmark<'w> {
2323

2424
// TODO: batch this
2525
for _ in 0..10_000 {
26-
world.spawn().insert_bundle((
26+
world.spawn().insert((
2727
Transform(Mat4::from_scale(Vec3::ONE)),
2828
Position(Vec3::X),
2929
Rotation(Vec3::X),

benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'w> Benchmark<'w> {
3535

3636
// TODO: batch this
3737
for _ in 0..10_000 {
38-
world.spawn().insert_bundle((
38+
world.spawn().insert((
3939
Transform(Mat4::from_scale(Vec3::ONE)),
4040
Rotation(Vec3::X),
4141
Position::<0>(Vec3::X),

benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'w> Benchmark<'w> {
3737

3838
// TODO: batch this
3939
for _ in 0..10_000 {
40-
world.spawn().insert_bundle((
40+
world.spawn().insert((
4141
Transform(Mat4::from_scale(Vec3::ONE)),
4242
Rotation(Vec3::X),
4343
Position::<0>(Vec3::X),

benches/benches/bevy_ecs/iteration/iter_simple_sparse_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<'w> Benchmark<'w> {
2323

2424
// TODO: batch this
2525
for _ in 0..10_000 {
26-
world.spawn().insert_bundle((
26+
world.spawn().insert((
2727
Transform(Mat4::from_scale(Vec3::ONE)),
2828
Position(Vec3::X),
2929
Rotation(Vec3::X),

benches/benches/bevy_ecs/iteration/iter_simple_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl Benchmark {
2121

2222
// TODO: batch this
2323
for _ in 0..10_000 {
24-
world.spawn().insert_bundle((
24+
world.spawn().insert((
2525
Transform(Mat4::from_scale(Vec3::ONE)),
2626
Position(Vec3::X),
2727
Rotation(Vec3::X),

benches/benches/bevy_ecs/iteration/iter_simple_wide.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'w> Benchmark<'w> {
3535

3636
// TODO: batch this
3737
for _ in 0..10_000 {
38-
world.spawn().insert_bundle((
38+
world.spawn().insert((
3939
Transform(Mat4::from_scale(Vec3::ONE)),
4040
Rotation(Vec3::X),
4141
Position::<0>(Vec3::X),

benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'w> Benchmark<'w> {
3737

3838
// TODO: batch this
3939
for _ in 0..10_000 {
40-
world.spawn().insert_bundle((
40+
world.spawn().insert((
4141
Transform(Mat4::from_scale(Vec3::ONE)),
4242
Rotation(Vec3::X),
4343
Position::<0>(Vec3::X),

benches/benches/bevy_ecs/world/commands.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub fn insert_commands(criterion: &mut Criterion) {
9595
for entity in &entities {
9696
commands
9797
.entity(*entity)
98-
.insert_bundle((Matrix::default(), Vec3::default()));
98+
.insert((Matrix::default(), Vec3::default()));
9999
}
100100
drop(commands);
101101
command_queue.apply(&mut world);
@@ -238,7 +238,7 @@ pub fn get_or_spawn(criterion: &mut Criterion) {
238238
for i in 0..10_000 {
239239
commands
240240
.get_or_spawn(Entity::from_raw(i))
241-
.insert_bundle((Matrix::default(), Vec3::default()));
241+
.insert((Matrix::default(), Vec3::default()));
242242
}
243243
command_queue.apply(&mut world);
244244
});

crates/bevy_core_pipeline/src/core_3d/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub fn extract_core_3d_camera_phases(
213213
) {
214214
for (entity, camera) in &cameras_3d {
215215
if camera.is_active {
216-
commands.get_or_spawn(entity).insert_bundle((
216+
commands.get_or_spawn(entity).insert((
217217
RenderPhase::<Opaque3d>::default(),
218218
RenderPhase::<AlphaMask3d>::default(),
219219
RenderPhase::<Transparent3d>::default(),

crates/bevy_ecs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ struct PlayerBundle {
276276
let mut world = World::new();
277277

278278
// Spawn a new entity and insert the default PlayerBundle
279-
world.spawn().insert_bundle(PlayerBundle::default());
279+
world.spawn().insert(PlayerBundle::default());
280280

281281
// Bundles play well with Rust's struct update syntax
282-
world.spawn().insert_bundle(PlayerBundle {
282+
world.spawn().insert(PlayerBundle {
283283
position: Position { x: 1.0, y: 1.0 },
284284
..Default::default()
285285
});

crates/bevy_ecs/src/entity/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,19 @@
1616
//! |Spawn a new entity|[`Commands::spawn`]|[`World::spawn`]|
1717
//! |Spawn an entity with components|[`Commands::spawn_bundle`]|---|
1818
//! |Despawn an entity|[`EntityCommands::despawn`]|[`World::despawn`]|
19-
//! |Insert a component to an entity|[`EntityCommands::insert`]|[`EntityMut::insert`]|
20-
//! |Insert multiple components to an entity|[`EntityCommands::insert_bundle`]|[`EntityMut::insert_bundle`]|
21-
//! |Remove a component from an entity|[`EntityCommands::remove`]|[`EntityMut::remove`]|
19+
//! |Insert a component, bundle, or tuple of components and bundles to an entity|[`EntityCommands::insert`]|[`EntityMut::insert`]|
20+
//! |Remove a component, bundle, or tuple of components and bundles from an entity|[`EntityCommands::remove`]|[`EntityMut::remove`]|
2221
//!
2322
//! [`World`]: crate::world::World
2423
//! [`Commands::spawn`]: crate::system::Commands::spawn
2524
//! [`Commands::spawn_bundle`]: crate::system::Commands::spawn_bundle
2625
//! [`EntityCommands::despawn`]: crate::system::EntityCommands::despawn
2726
//! [`EntityCommands::insert`]: crate::system::EntityCommands::insert
28-
//! [`EntityCommands::insert_bundle`]: crate::system::EntityCommands::insert_bundle
2927
//! [`EntityCommands::remove`]: crate::system::EntityCommands::remove
3028
//! [`World::spawn`]: crate::world::World::spawn
3129
//! [`World::spawn_bundle`]: crate::world::World::spawn_bundle
3230
//! [`World::despawn`]: crate::world::World::despawn
3331
//! [`EntityMut::insert`]: crate::world::EntityMut::insert
34-
//! [`EntityMut::insert_bundle`]: crate::world::EntityMut::insert_bundle
3532
//! [`EntityMut::remove`]: crate::world::EntityMut::remove
3633
mod map_entities;
3734
mod serde;

0 commit comments

Comments
 (0)