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

WithBundle missing WorldQuery implementation #2023

Closed
CGMossa opened this issue Apr 26, 2021 · 2 comments
Closed

WithBundle missing WorldQuery implementation #2023

CGMossa opened this issue Apr 26, 2021 · 2 comments
Labels
A-ECS Entities, components, systems, and events C-Docs An addition or correction to our documentation C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@CGMossa
Copy link
Contributor

CGMossa commented Apr 26, 2021

While fiddling with bundles, I wanted to do Query<(My, Components), WithBundle<MyBundle>>
but instead I'm met with this compilation error:

error: the trait `WorldQuery` is not implemented for `bevy::prelude::WithBundle<CattleFarmBundle>` 

According to @TehPers, it might only need this

impl<T: Bundle> WorldQuery for WithBundle<T> {
    type Fetch = WithBundleFetch<T>;
    type State = WithBundleState<T>;
}

I was asked to create this issue, so here it is.

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Apr 26, 2021
@cart
Copy link
Member

cart commented Apr 27, 2021

Yup it looks like we lost the WorldQuery impl during the ECS V2 rewrite. We should add it back :)

@cart
Copy link
Member

cart commented Apr 27, 2021

(and then check the new implementation for correctness because clearly that hasn't been done since the rewrite)

CGMossa added a commit to CGMossa/bevy that referenced this issue Apr 27, 2021
This addresses WithBundle missing WorldQuery implementation bevyengine#2023.
@bors bors bot closed this as completed in 86ad5bf Apr 28, 2021
NiklasEi pushed a commit to NiklasEi/bevy that referenced this issue May 1, 2021
In response to bevyengine#2023, here is a draft for a PR. 

Fixes bevyengine#2023

I've added an example to show how to use `WithBundle`, and also to test it out. 

Right now there is a bug: If a bundle and a query are "the same", then it doesn't filter out
what it needs to filter out. 

Example: 

```
Print component initated from bundle.
[examples/ecs/query_bundle.rs:57] x = Dummy( <========= This should not get printed
    111,
)
[examples/ecs/query_bundle.rs:57] x = Dummy(
    222,
)
Show all components
[examples/ecs/query_bundle.rs:50] x = Dummy(
    111,
)
[examples/ecs/query_bundle.rs:50] x = Dummy(
    222,
)
```

However, it behaves the right way, if I add one more component to the bundle,
so the query and the bundle doesn't look the same:

```
Print component initated from bundle.
[examples/ecs/query_bundle.rs:57] x = Dummy(
    222,
)
Show all components
[examples/ecs/query_bundle.rs:50] x = Dummy(
    111,
)
[examples/ecs/query_bundle.rs:50] x = Dummy(
    222,
)
```

I hope this helps. I'm definitely up for tinkering with this, and adding anything that I'm asked to add
or change. 





Co-authored-by: Carter Anderson <mcanders1@gmail.com>
ostwilkens pushed a commit to ostwilkens/bevy that referenced this issue Jul 27, 2021
In response to bevyengine#2023, here is a draft for a PR. 

Fixes bevyengine#2023

I've added an example to show how to use `WithBundle`, and also to test it out. 

Right now there is a bug: If a bundle and a query are "the same", then it doesn't filter out
what it needs to filter out. 

Example: 

```
Print component initated from bundle.
[examples/ecs/query_bundle.rs:57] x = Dummy( <========= This should not get printed
    111,
)
[examples/ecs/query_bundle.rs:57] x = Dummy(
    222,
)
Show all components
[examples/ecs/query_bundle.rs:50] x = Dummy(
    111,
)
[examples/ecs/query_bundle.rs:50] x = Dummy(
    222,
)
```

However, it behaves the right way, if I add one more component to the bundle,
so the query and the bundle doesn't look the same:

```
Print component initated from bundle.
[examples/ecs/query_bundle.rs:57] x = Dummy(
    222,
)
Show all components
[examples/ecs/query_bundle.rs:50] x = Dummy(
    111,
)
[examples/ecs/query_bundle.rs:50] x = Dummy(
    222,
)
```

I hope this helps. I'm definitely up for tinkering with this, and adding anything that I'm asked to add
or change. 





Co-authored-by: Carter Anderson <mcanders1@gmail.com>
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 C-Docs An addition or correction to our documentation C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants