-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[Merged by Bors] - EntityMut: rename remove_intersection to remove and remove to take
#7810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
remove_intersection to remove and remove to takeEntityMut: rename remove_intersection to remove and remove to take
|
Just want to make sure I didn't choose the wrong method in |
| /// | ||
| /// # Panics | ||
| /// | ||
| /// Panics if there is no [`Component`] of the given type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So entity.remove::<T>() won't panic if the component doesn't exist on the entity? (Did it even panic before?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't think remove ever panicked (well, ig if you call unwrap when it returns None).
But there's a subtle difference when T is a tuple/bundle.
remove (take) does not remove anything unless the entity has all the components in the bundle. remove_intersection (remove) will remove the ones it does have.
It wasn't clear to me which one bevy_reflect should use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. Well ReflectComponent only operates on a single component anyways, so either should work fine 😄
|
@maniwani mind fixing the CI failures? Will merge after that, though we may need to manually add the changes into the 0.10 migration guide. |
c6776a5 to
1bae6b9
Compare
|
bors r+ |
… `take` (#7810) # Objective - A more intuitive distinction between the two. `remove_intersection` is verbose and unclear. - `EntityMut::remove` and `Commands::remove` should match. ## Solution - What the title says. --- ## Migration Guide Before ```rust fn clear_children(parent: Entity, world: &mut World) { if let Some(children) = world.entity_mut(parent).remove::<Children>() { for &child in &children.0 { world.entity_mut(child).remove_intersection::<Parent>(); } } } ``` After ```rust fn clear_children(parent: Entity, world: &mut World) { if let Some(children) = world.entity_mut(parent).take::<Children>() { for &child in &children.0 { world.entity_mut(child).remove::<Parent>(); } } } ```
|
Build failed:
|
|
bors r+ |
… `take` (#7810) # Objective - A more intuitive distinction between the two. `remove_intersection` is verbose and unclear. - `EntityMut::remove` and `Commands::remove` should match. ## Solution - What the title says. --- ## Migration Guide Before ```rust fn clear_children(parent: Entity, world: &mut World) { if let Some(children) = world.entity_mut(parent).remove::<Children>() { for &child in &children.0 { world.entity_mut(child).remove_intersection::<Parent>(); } } } ``` After ```rust fn clear_children(parent: Entity, world: &mut World) { if let Some(children) = world.entity_mut(parent).take::<Children>() { for &child in &children.0 { world.entity_mut(child).remove::<Parent>(); } } } ```
EntityMut: rename remove_intersection to remove and remove to takeEntityMut: rename remove_intersection to remove and remove to take
… `take` (bevyengine#7810) # Objective - A more intuitive distinction between the two. `remove_intersection` is verbose and unclear. - `EntityMut::remove` and `Commands::remove` should match. ## Solution - What the title says. --- ## Migration Guide Before ```rust fn clear_children(parent: Entity, world: &mut World) { if let Some(children) = world.entity_mut(parent).remove::<Children>() { for &child in &children.0 { world.entity_mut(child).remove_intersection::<Parent>(); } } } ``` After ```rust fn clear_children(parent: Entity, world: &mut World) { if let Some(children) = world.entity_mut(parent).take::<Children>() { for &child in &children.0 { world.entity_mut(child).remove::<Parent>(); } } } ```
Objective
remove_intersectionis verbose and unclear.EntityMut::removeandCommands::removeshould match.Solution
Migration Guide
Before
After