bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Update breakout to use Required Components

Open Mclilzee opened this issue 1 year ago • 5 comments

Objective

This PR update breakout to use the new 0.15 Required Component feature instead of the Bundle. Add more information in the comment about where to find more info about Required Components.

Solution

Replace #[derive(Bundle)] with a new Wall component and #[require()] Macro to include the other components.

Testing

Tested with cargo test as well tested the game manually with cargo run --example breakout It looks to me that it works like it used to before the changes. Tested on Arch Linux, Wayland

Mclilzee avatar Nov 30 '24 22:11 Mclilzee

Welcome, new contributor!

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

github-actions[bot] avatar Nov 30 '24 22:11 github-actions[bot]

@BenjaminBrienen Hey thanks for the review. I noticed the Waiting Author Tag, is there anything else that needs to be done?

Mclilzee avatar Dec 01 '24 19:12 Mclilzee

I think there was an error in CI, maybe a merge conflict. Looks good now :)

Edit: oh, it was the typo review comment

BenjaminBrienen avatar Dec 01 '24 19:12 BenjaminBrienen

Any thought about removing Transform from the required components for the Wall since Sprite itself requires Transform?

If we remove it, it is potentially less clear that the Wall will have Transform for those unfamiliar with Sprite and wouldn't know that Sprite itself requires Transform. Just something I thought about while cleaning up.

Edit: After giving it some more thought, I'm leaning towards keeping Transform for two reasons.

  1. It makes it clear that requiring a component even if it is already required by another component that we require would still compile and work.
  2. It shows that we may also require redundant components for the semantics of our component definition (what makes this component complete)

Mclilzee avatar Dec 02 '24 18:12 Mclilzee

It's more idiomatic to remove Transform, but I'd call out this behavior in a comment since this is learning material.

alice-i-cecile avatar Dec 02 '24 18:12 alice-i-cecile

@alice-i-cecile hey, this should be ready, I believe. I re-requested a review from the reviewers to take another look after implementing their changes, but they seem to be busy. I didn't want this to take a long time, as it's one of the core examples of bevy, I think we can move to final-review phase, I'm still new to all of this so learning by observing how things go.

As for the Transform we talked about above, we can open a different PR / Issue to discuss it as for now this PR is straight forward translation from Bundle to Required Component, doesn't need changes in implementation.

Mclilzee avatar Dec 06 '24 23:12 Mclilzee

Agreed. This is definitely a straight improvement, so I'm merging as is.

alice-i-cecile avatar Dec 07 '24 00:12 alice-i-cecile