mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Prevent iterator invalidation in world:each
Some checks are pending
Analysis / Run Luau Analyze (push) Waiting to run
Deploy VitePress site to Pages / build (push) Waiting to run
Deploy VitePress site to Pages / Deploy (push) Blocked by required conditions
Styling / Run Stylua (push) Waiting to run
Unit Testing / Run Luau Tests (push) Waiting to run
Some checks are pending
Analysis / Run Luau Analyze (push) Waiting to run
Deploy VitePress site to Pages / build (push) Waiting to run
Deploy VitePress site to Pages / Deploy (push) Blocked by required conditions
Styling / Run Stylua (push) Waiting to run
Unit Testing / Run Luau Tests (push) Waiting to run
This commit is contained in:
parent
4841915af3
commit
02cb4ad7a2
1 changed files with 7 additions and 3 deletions
10
jecs.luau
10
jecs.luau
|
@ -1562,17 +1562,21 @@ local function world_each(world: World, id): () -> ()
|
||||||
return NOOP
|
return NOOP
|
||||||
end
|
end
|
||||||
|
|
||||||
local last = 0
|
local entities = archetype.entities
|
||||||
|
local row = #entities
|
||||||
|
|
||||||
return function(): any
|
return function(): any
|
||||||
last += 1
|
local entity = entities[row]
|
||||||
local entity = archetype.entities[last]
|
|
||||||
while not entity do
|
while not entity do
|
||||||
archetype_id = next(idr_cache, archetype_id)
|
archetype_id = next(idr_cache, archetype_id)
|
||||||
if not archetype_id then
|
if not archetype_id then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
archetype = archetypes[archetype_id]
|
archetype = archetypes[archetype_id]
|
||||||
|
entities = archetype.entities
|
||||||
|
row = #entities
|
||||||
end
|
end
|
||||||
|
row -= 1
|
||||||
return entity
|
return entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue