mirror of
https://github.com/Ukendio/jecs.git
synced 2025-08-04 03:09:18 +00:00
Handle removal of (*, R) pairs
This commit is contained in:
parent
0fea5a259d
commit
c50c61b30c
2 changed files with 22 additions and 1 deletions
|
@ -1413,11 +1413,11 @@ local function world_delete(world: ecs_world_t, entity: i53)
|
|||
for i = tr, tr + tr_count - 1 do
|
||||
ids[types[i]] = true
|
||||
end
|
||||
|
||||
local n = #entities
|
||||
table.move(entities, 1, n, count + 1, children)
|
||||
count += n
|
||||
end
|
||||
|
||||
for _, child in children do
|
||||
for id in ids do
|
||||
world_remove(world, child, id)
|
||||
|
|
|
@ -289,6 +289,27 @@ TEST("world:contains()", function()
|
|||
end)
|
||||
|
||||
TEST("world:delete()", function()
|
||||
do CASE "remove (*, R) pairs when relationship is invalidated"
|
||||
print("-------")
|
||||
local world = jecs.world()
|
||||
local e1 = world:entity()
|
||||
local e2 = world:entity()
|
||||
|
||||
local A = world:component()
|
||||
local B = world:component()
|
||||
local C = world:component()
|
||||
|
||||
world:add(e1, pair(e2, A))
|
||||
world:add(e1, B) -- Some stable component that should not be removed in the process
|
||||
world:add(e1, pair(e2, C))
|
||||
world:delete(e2)
|
||||
|
||||
CHECK(not world:contains(e2))
|
||||
CHECK(not world:has(e1, pair(e2, A)))
|
||||
CHECK(world:has(e1, B))
|
||||
CHECK(not world:has(e1, pair(e2, C)))
|
||||
CHECK(world:contains(e1))
|
||||
end
|
||||
do CASE "remove pair when relationship is deleted"
|
||||
local world = jecs.world()
|
||||
local e1 = world:entity()
|
||||
|
|
Loading…
Reference in a new issue