Skip to content
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

Finish enhancing ReflectCommandExt to work with Bundles #15152

Conversation

Niashi24
Copy link
Contributor

Objective

Solution

  • Modified bevy_ecs::reflect::entity_commands::remove_reflect to handle both components and bundles
  • Modified documentation of ReflectCommandExt methods to reflect that one can now use bundles with these commands.

Testing

  • Three tests were added to match the ones for inserting components.

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added this to the 0.15 milestone Sep 11, 2024
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use A-Reflection Runtime information about types labels Sep 11, 2024
@alice-i-cecile
Copy link
Member

@miniex could I get your review on this follow-up work? :)

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Straightforward, with good docs changes and tests. Thanks!

/// - If the component data is invalid. See [`PartialReflect::apply`] for further details.
/// - If [`AppTypeRegistry`] does not have the reflection data for the given
/// [`Component`](crate::component::Component) or [`Bundle`](crate::bundle::Bundle).
/// - If the component or bundle data is invalid. See [`PartialReflect::apply`] for further details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, it would be good to also write how to handle errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a panic, would you not handle it like you would handle other bevy panics? Not familiar with how to handle panics myself, but if there's some documentation for it we can link it here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we don't have specific guidance here currently; I'm not sure there's more to add.

/// commands.entity(prefab.entity)
/// .remove_reflect(prefab.component.reflect_type_path().to_owned());
/// .remove_reflect(prefab.data.reflect_type_path().to_owned());
/// }
///
/// ```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to include safe removal methods and error handling examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by safe removal methods? Would this not be considered safe since it doesn't panic?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My English is bad. I meant “safe” to mean preventing unexpected behavior, not preventing panic.

But based on the replies above, I don't think it's necessary. The overall feel of the finished code.

/// commands.entity(prefab.entity)
/// .remove_reflect(prefab.component.reflect_type_path().to_owned());
/// .remove_reflect(prefab.data.reflect_type_path().to_owned());
/// }
///
/// ```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My English is bad. I meant “safe” to mean preventing unexpected behavior, not preventing panic.

But based on the replies above, I don't think it's necessary. The overall feel of the finished code.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Sep 11, 2024
@alice-i-cecile
Copy link
Member

Awesome, thank you both.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 11, 2024
Merged via the queue into bevyengine:main with commit 8bfe635 Sep 11, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events A-Reflection Runtime information about types C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants