Repository navigation
Update to bevy 0.19 - #242
Conversation
ManevilleF
left a comment
There was a problem hiding this comment.
Thanks for the PR. Could you explain why you removed the Component derives from all those types ?
Co-authored-by: Félix Lescaudey de Maneville <felix.maneville@gmail.com>
The same type can no longer be both a resource and a component, see https://bevy.org/learn/migration-guides/0-18-to-0-19/#derive-resource-implements-the-component-trait. I was updating a bunch of my dependencies at the same time and I forgot to come back to the decision about what to do about the derives after I got my project to compile. I don't use these, so I don't know if component or resource is the most useful. Maybe the more principled solution is to remove both and let users do their own wrappers? |
|
I also didn't notice the clippy issues, I'm fixing those as well |
|
I agree, we should remove both and add an entry in the docs that the user needs to make its own wrapper |
|
Stumbled upon this PR while updating my project to bevy 0.19 so I thought I'd pitch in. My reasoning is that deriving Resource locks users into a singleton-like pattern. While if you were to choose component, users could still mark an entity as the primary source using one of the following patterns: #[derive(Resource)]
struct PrimaryHexLayout(Entity);
fn my_setup_system(mut commands Commands) {
let layout = /* construct HexLayout */
let entity = commands.spawn(layout).id();
commands.insert_resource(PrimaryHexLayout(entity));
}
fn my_query_system(primary_layout: Res<PrimaryHexLayout>, layouts: Query<&HexLayout>) {
let layout = layouts.get(primary_layout.0);
}or preferably: #[derive(Component)]
struct PrimaryHexLayout;
fn my_setup_system(mut commands Commands) {
let layout = /* construct HexLayout */
commands.spawn((layout, PrimaryHexLayout));
}
fn my_query_system(primary_layout: Single<&HexLayout, With<PrimaryLayout>>) {
let layout = *primary_layout;
} |
|
Fair point, The idea was to simplify the developer experience, but the decision So I think we should remove both, or at least Do we use those component/resources derives in tests/examples ? |
Resource is used in one place, it was easy to replace with a wrapper. I pushed a commit removing the affected derives. I added notes to the changelog and updated docs a bit, let me know if you want more docs somewhere. There is only one derive left behind the |
I tested a couple of examples, seems to work