This commit is contained in:
Ukendio 2024-05-17 01:05:40 +02:00
parent 5533cd1c64
commit 6c2f47bf70
2 changed files with 8 additions and 3 deletions

View file

@ -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

View file

@ -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"