mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 09:00:02 +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_count = idr_r_archetype.counts[rel]
|
||||
local types = idr_r_archetype.types
|
||||
for i = tr, tr_count - 1 do
|
||||
for i = tr, tr_count do
|
||||
ids[types[tr]] = true
|
||||
end
|
||||
local n = #entities
|
||||
|
|
|
@ -34,10 +34,8 @@ TEST("world:add()", function()
|
|||
world:add(e, _1)
|
||||
world:add(e, _2)
|
||||
|
||||
print("----idempotent")
|
||||
world:add(e, _2) -- should have 0 effects
|
||||
CHECK(d.archetype(e) == "1_2")
|
||||
print(d.archetype(e))
|
||||
end
|
||||
|
||||
do CASE("archetype move")
|
||||
|
@ -238,6 +236,25 @@ TEST("world:contains()", function()
|
|||
end)
|
||||
|
||||
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"
|
||||
local world = jecs.world()
|
||||
|
||||
|
|
Loading…
Reference in a new issue