Skip to content

Commit

Permalink
Handle cycles in deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Aug 13, 2024
1 parent 49d5bd0 commit 33f359a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions test/tests.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 33f359a

Please sign in to comment.