bevy/examples/ecs
Carter Anderson cd15f0f5be Accept Bundles for insert and remove. Deprecate insert/remove_bundle (#6039)
# Objective

Take advantage of the "impl Bundle for Component" changes in #2975 / add the follow up changes discussed there.

## Solution

- Change `insert` and `remove` to accept a Bundle instead of a Component (for both Commands and World)
- Deprecate `insert_bundle`, `remove_bundle`, and `remove_bundle_intersection`
- Add `remove_intersection`

---

## Changelog

- Change `insert` and `remove` now accept a Bundle instead of a Component (for both Commands and World)
- `insert_bundle` and `remove_bundle` are deprecated
 

## Migration Guide

Replace `insert_bundle` with `insert`:
```rust
// Old (0.8)
commands.spawn().insert_bundle(SomeBundle::default());
// New (0.9)
commands.spawn().insert(SomeBundle::default());
```

Replace `remove_bundle` with `remove`:
```rust
// Old (0.8)
commands.entity(some_entity).remove_bundle::<SomeBundle>();
// New (0.9)
commands.entity(some_entity).remove::<SomeBundle>();
```

Replace `remove_bundle_intersection` with `remove_intersection`:
```rust
// Old (0.8)
world.entity_mut(some_entity).remove_bundle_intersection::<SomeBundle>();
// New (0.9)
world.entity_mut(some_entity).remove_intersection::<SomeBundle>();
```

Consider consolidating as many operations as possible to improve ergonomics and cut down on archetype moves:
```rust
// Old (0.8)
commands.spawn()
  .insert_bundle(SomeBundle::default())
  .insert(SomeComponent);

// New (0.9) - Option 1
commands.spawn().insert((
  SomeBundle::default(),
  SomeComponent,
))

// New (0.9) - Option 2
commands.spawn_bundle((
  SomeBundle::default(),
  SomeComponent,
))
```

## Next Steps

Consider changing `spawn` to accept a bundle and deprecate `spawn_bundle`.
2022-09-21 21:47:53 +00:00
..
component_change_detection.rs Accept Bundles for insert and remove. Deprecate insert/remove_bundle (#6039) 2022-09-21 21:47:53 +00:00
custom_query_param.rs Accept Bundles for insert and remove. Deprecate insert/remove_bundle (#6039) 2022-09-21 21:47:53 +00:00
ecs_guide.rs Accept Bundles for insert and remove. Deprecate insert/remove_bundle (#6039) 2022-09-21 21:47:53 +00:00
event.rs Make Resource trait opt-in, requiring #[derive(Resource)] V2 (#5577) 2022-08-08 21:36:35 +00:00
fixed_timestep.rs Split time functionality into bevy_time (#4187) 2022-05-26 00:27:18 +00:00
generic_system.rs Accept Bundles for insert and remove. Deprecate insert/remove_bundle (#6039) 2022-09-21 21:47:53 +00:00
hierarchy.rs Consistently use PI to specify angles in examples. (#5825) 2022-08-30 19:52:11 +00:00
iter_combinations.rs Implement Bundle for Component. Use Bundle tuples for insertion (#2975) 2022-09-20 20:17:08 +00:00
parallel_query.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
removal_detection.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
startup_system.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00
state.rs Make Resource trait opt-in, requiring #[derive(Resource)] V2 (#5577) 2022-08-08 21:36:35 +00:00
system_chaining.rs Make Resource trait opt-in, requiring #[derive(Resource)] V2 (#5577) 2022-08-08 21:36:35 +00:00
system_closure.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00
system_param.rs Accept Bundles for insert and remove. Deprecate insert/remove_bundle (#6039) 2022-09-21 21:47:53 +00:00
system_sets.rs Remove last uses of string-labels (#5420) 2022-09-03 18:06:41 +00:00
timers.rs Accept Bundles for insert and remove. Deprecate insert/remove_bundle (#6039) 2022-09-21 21:47:53 +00:00