Not Queries do not seem to update
briancw opened this issue · 2 comments
briancw commented
Not queries will correctly identify entities without components the first time they are run, but on subsequent runs will not accurately return components without entities.
import {createWorld, addEntity, addComponent, removeComponent, defineComponent, defineQuery, Not} from 'bitecs'
const Foo = defineComponent()
const notFooQuery = defineQuery([Not(Foo)])
const fooQuery = defineQuery([Foo])
const world = createWorld()
const eid1 = addEntity(world)
console.log('Foo:', fooQuery(world))
console.log('Not Foo:', notFooQuery(world))
addComponent(world, Foo, eid1)
console.log('Foo:', fooQuery(world))
console.log('Not Foo:', notFooQuery(world))
removeComponent(world, Foo, eid1)
console.log('Foo:', fooQuery(world))
console.log('Not Foo:', notFooQuery(world))
The fooQuery accurately returns components with or without the Foo component each time.
The notFooQuery returns the same output all three times.
NateTheGreatt commented
good catch! i know what's wrong. will have a patch out for that later this evening
NateTheGreatt commented
@briancw 0.3.15
has been published to npm with a fix for this issue 👍