NateTheGreatt / bitECS

Flexible, minimal, data-oriented ECS library for Typescript
Mozilla Public License 2.0
944 stars 84 forks source link

Not Queries do not seem to update #27

Closed briancw closed 3 years ago

briancw commented 3 years ago

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 3 years ago

good catch! i know what's wrong. will have a patch out for that later this evening

NateTheGreatt commented 3 years ago

@briancw 0.3.15 has been published to npm with a fix for this issue 👍