mirror of
https://github.com/Ukendio/jecs.git
synced 2025-07-03 21:49:16 +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
|
||||
|
||||
function preparedQuery:__iter()
|
||||
return function()
|
||||
function preparedQuery:__tostring()
|
||||
return "query"
|
||||
end
|
||||
|
||||
local function iter()
|
||||
local archetype = compatibleArchetype.archetype
|
||||
local row: number = next(archetype.entities, lastRow) :: number
|
||||
while row == nil do
|
||||
|
@ -866,6 +869,13 @@ function World.query(world: World, ...): Query
|
|||
|
||||
return entityId, unpack(queryOutput, 1, queryLength)
|
||||
end
|
||||
|
||||
function preparedQuery:__iter()
|
||||
return iter
|
||||
end
|
||||
|
||||
function preparedQuery:next()
|
||||
return iter()
|
||||
end
|
||||
|
||||
return setmetatable({}, preparedQuery) :: any
|
||||
|
|
Loading…
Reference in a new issue