mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-26 01:50:01 +00:00
Add next method
This commit is contained in:
parent
ea110ea2a9
commit
def75e3b49
1 changed files with 76 additions and 66 deletions
14
lib/init.lua
14
lib/init.lua
|
@ -798,8 +798,11 @@ function World.query(world: World, ...): Query
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function preparedQuery:__iter()
|
function preparedQuery:__tostring()
|
||||||
return function()
|
return "query"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function iter()
|
||||||
local archetype = compatibleArchetype.archetype
|
local archetype = compatibleArchetype.archetype
|
||||||
local row: number = next(archetype.entities, lastRow) :: number
|
local row: number = next(archetype.entities, lastRow) :: number
|
||||||
while row == nil do
|
while row == nil do
|
||||||
|
@ -866,6 +869,13 @@ function World.query(world: World, ...): Query
|
||||||
|
|
||||||
return entityId, unpack(queryOutput, 1, queryLength)
|
return entityId, unpack(queryOutput, 1, queryLength)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function preparedQuery:__iter()
|
||||||
|
return iter
|
||||||
|
end
|
||||||
|
|
||||||
|
function preparedQuery:next()
|
||||||
|
return iter()
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable({}, preparedQuery) :: any
|
return setmetatable({}, preparedQuery) :: any
|
||||||
|
|
Loading…
Reference in a new issue