mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Set compatibleAchetype after without
This commit is contained in:
parent
f79e757eea
commit
d11fa2f4a3
3 changed files with 24 additions and 8 deletions
11
lib/init.lua
11
lib/init.lua
|
@ -408,10 +408,7 @@ function World.query(world: World, ...: i53): any
|
||||||
|
|
||||||
function preparedQuery:without(...)
|
function preparedQuery:without(...)
|
||||||
local components = { ... }
|
local components = { ... }
|
||||||
for i, component in components do
|
for i = #compatibleArchetypes, 1, -1 do
|
||||||
components[i] = component
|
|
||||||
end
|
|
||||||
for i = #compatibleArchetypes, 1, - 1 do
|
|
||||||
local archetype = compatibleArchetypes[i].archetype
|
local archetype = compatibleArchetypes[i].archetype
|
||||||
local shouldRemove = false
|
local shouldRemove = false
|
||||||
for _, componentId in components do
|
for _, componentId in components do
|
||||||
|
@ -424,6 +421,12 @@ function World.query(world: World, ...: i53): any
|
||||||
table.remove(compatibleArchetypes, i)
|
table.remove(compatibleArchetypes, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
lastArchetype, compatibleArchetype = next(compatibleArchetypes)
|
||||||
|
if not lastArchetype then
|
||||||
|
return noop()
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,23 @@ return function()
|
||||||
added += 1
|
added += 1
|
||||||
end
|
end
|
||||||
expect(added).to.equal(hm)
|
expect(added).to.equal(hm)
|
||||||
print(added, hm)
|
end)
|
||||||
|
|
||||||
|
it("should skip iteration", function()
|
||||||
|
local Position, Velocity = world:entity(), world:entity()
|
||||||
|
print(Position, Velocity)
|
||||||
|
local e = world:entity()
|
||||||
|
print(e)
|
||||||
|
world:set(e, Position, Vector3.zero)
|
||||||
|
world:set(e, Velocity, Vector3.one)
|
||||||
|
local added = 0
|
||||||
|
for i in world:query(Position):without(Velocity) do
|
||||||
|
print(i)
|
||||||
|
added += 1
|
||||||
|
end
|
||||||
|
expect(added).to.equal(0)
|
||||||
|
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("track changes", function()
|
it("track changes", function()
|
||||||
|
|
|
@ -23,9 +23,6 @@
|
||||||
"benches": {
|
"benches": {
|
||||||
"$path": "benches"
|
"$path": "benches"
|
||||||
},
|
},
|
||||||
"rewrite": {
|
|
||||||
"$path": "matterRewrite"
|
|
||||||
},
|
|
||||||
"mirror": {
|
"mirror": {
|
||||||
"$path": "mirror"
|
"$path": "mirror"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue