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

Query for mixed composition with Change #113

Open
SchDen opened this issue Apr 8, 2023 · 1 comment
Open

Query for mixed composition with Change #113

SchDen opened this issue Apr 8, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@SchDen
Copy link

SchDen commented Apr 8, 2023

I have a problem with this composition:

defineQuery([
    Changed(FirstComponent),
    SecondComponent
])

I understand this composition as follows: if FirstComponent changed, and this entity also has SecondComponent, then give me a list of that entities.
It works well if I change FirstComponent, but in the case when I change SecondComponent - it also returns the same result. It looks like a bug, but maybe I use it wrong.

@SchDen
Copy link
Author

SchDen commented Apr 8, 2023

Test example:

  it('should return 0 eids', () => {
    const world = createWorld()
    const FirstComponent = defineComponent({ value: Types.f32 })
    const SecondComponent = defineComponent({ value: Types.f32 })

    const query = defineQuery([Changed(FirstComponent), SecondComponent])
    const eid1 = addEntity(world)
    const eid2 = addEntity(world)

    addComponent(world, FirstComponent, eid1)
    addComponent(world, SecondComponent, eid1)
    addComponent(world, FirstComponent, eid2)
    addComponent(world, SecondComponent, eid2)

    let ents = query(world)
    strictEqual(ents.length, 0)

    SecondComponent.value[eid1]++

    ents = query(world)

    strictEqual(ents.length, 0)
  })

It fails:
image

@NateTheGreatt NateTheGreatt added the bug Something isn't working label May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants