mirror of
https://github.com/Ukendio/jecs.git
synced 2025-06-19 15:59:18 +00:00
Handle removal of (*, R) pairs
This commit is contained in:
parent
0fea5a259d
commit
3174e8d80b
4 changed files with 31 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue