From 6c2f47bf701122421cb89e3a4ff21f0144844901 Mon Sep 17 00:00:00 2001 From: Ukendio Date: Fri, 17 May 2024 01:05:40 +0200 Subject: [PATCH] Add todo --- lib/init.lua | 5 +++-- tests/world.lua | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/init.lua b/lib/init.lua index aaa975a..5cf38ea 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -420,7 +420,7 @@ local function archetypeDelete(world: World, id: i53) world:remove(entity, id) end end - + componentIndex[id] = nil end end @@ -436,9 +436,10 @@ function World.delete(world: World, entityId: i53) local row = record.row archetypeDelete(world, entityId) + -- TODO: should traverse linked )component records to pairs including entityId archetypeDelete(world, ECS_PAIR(entityId, WILDCARD)) archetypeDelete(world, ECS_PAIR(WILDCARD, entityId)) - + if archetype then local entities = archetype.entities local last = #entities diff --git a/tests/world.lua b/tests/world.lua index 2d4bb6d..f0eff7d 100644 --- a/tests/world.lua +++ b/tests/world.lua @@ -276,6 +276,7 @@ TEST("world", function() local bob = world:entity() local alice = world:entity() + world:set(bob, Apples, "apples") world:set(bob, ECS_PAIR(Eats, Apples), "bob eats apples") world:set(alice, ECS_PAIR(Eats, Oranges), "alice eats oranges") @@ -283,11 +284,14 @@ TEST("world", function() local Wildcard = jecs.Wildcard local count = 0 - for _, data in world:query(ECS_PAIR(Wildcard, Apples)) do + for _, data in world:query(ECS_PAIR(Wildcard, Apples)) do count += 1 end + + world:delete(ECS_PAIR(Eats, Apples)) CHECK(count == 0) + CHECK(world:get(bob, ECS_PAIR(Eats, Apples)) == nil) end do CASE "should error when setting invalid pair"