mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-28 10:50:03 +00:00
Remove until end of range for relationship
This commit is contained in:
parent
765a7f9a36
commit
f9bacf3f54
2 changed files with 20 additions and 3 deletions
|
@ -1260,7 +1260,7 @@ local function world_delete(world: ecs_world_t, entity: i53)
|
||||||
local tr = idr_r_archetype.records[rel]
|
local tr = idr_r_archetype.records[rel]
|
||||||
local tr_count = idr_r_archetype.counts[rel]
|
local tr_count = idr_r_archetype.counts[rel]
|
||||||
local types = idr_r_archetype.types
|
local types = idr_r_archetype.types
|
||||||
for i = tr, tr_count - 1 do
|
for i = tr, tr_count do
|
||||||
ids[types[tr]] = true
|
ids[types[tr]] = true
|
||||||
end
|
end
|
||||||
local n = #entities
|
local n = #entities
|
||||||
|
|
|
@ -34,10 +34,8 @@ TEST("world:add()", function()
|
||||||
world:add(e, _1)
|
world:add(e, _1)
|
||||||
world:add(e, _2)
|
world:add(e, _2)
|
||||||
|
|
||||||
print("----idempotent")
|
|
||||||
world:add(e, _2) -- should have 0 effects
|
world:add(e, _2) -- should have 0 effects
|
||||||
CHECK(d.archetype(e) == "1_2")
|
CHECK(d.archetype(e) == "1_2")
|
||||||
print(d.archetype(e))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do CASE("archetype move")
|
do CASE("archetype move")
|
||||||
|
@ -238,6 +236,25 @@ TEST("world:contains()", function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
TEST("world:delete()", function()
|
TEST("world:delete()", function()
|
||||||
|
do CASE "remove pair when relationship is deleted"
|
||||||
|
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(A, e2))
|
||||||
|
world:add(e1, pair(B, e2))
|
||||||
|
world:add(e1, pair(C, e2))
|
||||||
|
world:delete(A)
|
||||||
|
|
||||||
|
CHECK(not world:has(e1, pair(A, e2)))
|
||||||
|
CHECK(world:has(e1, pair(B, e2)))
|
||||||
|
CHECK(world:has(e1, pair(C, e2)))
|
||||||
|
end
|
||||||
|
|
||||||
do CASE "invoke OnRemove hook on all components of deleted entity"
|
do CASE "invoke OnRemove hook on all components of deleted entity"
|
||||||
local world = jecs.world()
|
local world = jecs.world()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue