mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Handle cycles in deletion
This commit is contained in:
parent
49d5bd0d4a
commit
33f359a150
2 changed files with 18 additions and 0 deletions
|
@ -908,6 +908,9 @@ do
|
|||
|
||||
for archetype_id in idr.cache do
|
||||
local compatibleArchetype = archetypes[archetype_id]
|
||||
if #compatibleArchetype.entities == 0 then
|
||||
continue
|
||||
end
|
||||
local records = compatibleArchetype.records
|
||||
|
||||
local skip = false
|
||||
|
|
|
@ -847,6 +847,21 @@ TEST("world:delete", function()
|
|||
CHECK(not world:contains(entity))
|
||||
end
|
||||
end
|
||||
|
||||
do CASE "cycle"
|
||||
local world = jecs.World.new()
|
||||
local Likes = world:component()
|
||||
world:add(Likes, jecs.Delete)
|
||||
local bob = world:entity()
|
||||
local alice = world:entity()
|
||||
|
||||
world:add(bob, pair(Likes, alice))
|
||||
world:add(alice, pair(Likes, bob))
|
||||
|
||||
world:delete(bob)
|
||||
CHECK(not world:contains(bob))
|
||||
CHECK(not world:contains(alice))
|
||||
end
|
||||
end)
|
||||
|
||||
TEST("world:contains", function()
|
||||
|
|
Loading…
Reference in a new issue