mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Use next() in World.__iter
This commit is contained in:
parent
7990f94a06
commit
3bb4872199
1 changed files with 3 additions and 5 deletions
|
@ -463,7 +463,7 @@ function World.clear(world: World, entityId: i53)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
moveEntity(world, entityId, record, world.ROOT_ARCHETYPE)
|
moveEntity(world.entityIndex, entityId, record, ROOT_ARCHETYPE)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ensureArchetype(world: World, types, prev): Archetype
|
local function ensureArchetype(world: World, types, prev): Archetype
|
||||||
|
@ -845,7 +845,6 @@ type WorldIterator = (() -> (i53, { [unknown]: unknown? })) & (() -> ()) & (() -
|
||||||
|
|
||||||
function World.__iter(world: World): WorldIterator
|
function World.__iter(world: World): WorldIterator
|
||||||
local entityIndex = world.entityIndex
|
local entityIndex = world.entityIndex
|
||||||
local dense = entityIndex.dense
|
|
||||||
local sparse = entityIndex.sparse
|
local sparse = entityIndex.sparse
|
||||||
local last
|
local last
|
||||||
|
|
||||||
|
@ -854,14 +853,13 @@ function World.__iter(world: World): WorldIterator
|
||||||
local i = 0
|
local i = 0
|
||||||
local function iterator()
|
local function iterator()
|
||||||
i+=1
|
i+=1
|
||||||
local entityId = dense[i]
|
local entityId, record = next(sparse, last)
|
||||||
if not entityId then
|
if not entityId then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
last = lastEntity
|
last = entityId
|
||||||
|
|
||||||
local record = sparse[entityId]
|
|
||||||
local archetype = record.archetype
|
local archetype = record.archetype
|
||||||
if not archetype then
|
if not archetype then
|
||||||
-- Returns only the entity id as an entity without data should not return
|
-- Returns only the entity id as an entity without data should not return
|
||||||
|
|
Loading…
Reference in a new issue