mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Optimize removal of children
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
Publish to NPM / publish (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
Publish to NPM / publish (push) Waiting to run
Unit Testing / Run Luau Tests (push) Waiting to run
This commit is contained in:
parent
4392f94126
commit
bacf056851
1 changed files with 14 additions and 3 deletions
15
jecs.luau
15
jecs.luau
|
@ -764,7 +764,7 @@ local function create_edge_for_remove(world: World, node: Archetype, edge: Graph
|
|||
return to
|
||||
end
|
||||
|
||||
local function archetype_traverse_add(world: World, id: i53, from: Archetype?): Archetype
|
||||
local function archetype_traverse_add(world: World, id: i53, from: Archetype): Archetype
|
||||
from = from or world.ROOT_ARCHETYPE
|
||||
local edge = archetype_ensure_edge(world, from.add, id)
|
||||
|
||||
|
@ -1156,6 +1156,7 @@ do
|
|||
local idr_t_archetype = archetypes[archetype_id]
|
||||
|
||||
local idr_t_types = idr_t_archetype.types
|
||||
local on_remove = idr_t.hooks.on_remove
|
||||
|
||||
for _, child in idr_t_archetype.entities do
|
||||
table.insert(children, child)
|
||||
|
@ -1177,8 +1178,18 @@ do
|
|||
end
|
||||
break
|
||||
else
|
||||
local to = archetype_traverse_remove(world, id, idr_t_archetype)
|
||||
if on_remove then
|
||||
for _, child in children do
|
||||
world_remove(world, child, id)
|
||||
on_remove(child)
|
||||
local r = entity_index_try_get_fast(entity_index, child) :: Record
|
||||
entity_move(entity_index, child, r, to)
|
||||
end
|
||||
else
|
||||
for _, child in children do
|
||||
local r = entity_index_try_get_fast(entity_index, child) :: Record
|
||||
entity_move(entity_index, child, r, to)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue