diff --git a/CHANGELOG.md b/CHANGELOG.md index 12cd1ad..28a4d81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## Unreleased +## 0.6.1 + +### Changed +- Entity types now unions with numbers should allow for easier time casting while not causing regressing previous behaviours + +### Fixed +- Fixed a critical bug with `(*, R)` pairs not being removed when `R` is deleted + ## 0.6.0 ### Added diff --git a/jecs.luau b/jecs.luau index 0033e34..416bc1f 100644 --- a/jecs.luau +++ b/jecs.luau @@ -1413,11 +1413,11 @@ local function world_delete(world: ecs_world_t, entity: i53) for i = tr, tr + tr_count - 1 do ids[types[i]] = true end + local n = #entities table.move(entities, 1, n, count + 1, children) count += n end - for _, child in children do for id in ids do world_remove(world, child, id) diff --git a/test/tests.luau b/test/tests.luau index d5e578f..eefe422 100644 --- a/test/tests.luau +++ b/test/tests.luau @@ -289,6 +289,27 @@ TEST("world:contains()", function() end) TEST("world:delete()", function() + do CASE "remove (*, R) pairs when relationship is invalidated" + print("-------") + 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(e2, A)) + world:add(e1, B) -- Some stable component that should not be removed in the process + world:add(e1, pair(e2, C)) + world:delete(e2) + + CHECK(not world:contains(e2)) + CHECK(not world:has(e1, pair(e2, A))) + CHECK(world:has(e1, B)) + CHECK(not world:has(e1, pair(e2, C))) + CHECK(world:contains(e1)) + end do CASE "remove pair when relationship is deleted" local world = jecs.world() local e1 = world:entity() diff --git a/wally.toml b/wally.toml index 24905d0..c4480ea 100644 --- a/wally.toml +++ b/wally.toml @@ -1,6 +1,6 @@ [package] name = "ukendio/jecs" -version = "0.6.0" +version = "0.6.1" registry = "https://github.com/UpliftGames/wally-index" realm = "shared" license = "MIT"