Merge upstream changes

This commit is contained in:
Ukendio 2024-05-10 14:31:22 +02:00
parent f063a5cf24
commit cf694bddd1
2 changed files with 8 additions and 4 deletions

View file

@ -469,14 +469,17 @@ function World.set(world: World, entityId: i53, componentId: i53, data: unknown)
to.columns[archetypeRecord][record.row] = data
end
local function archetypeTraverseRemove(world: World, componentId: i53, archetype: Archetype?): Archetype
local from = (archetype or world.ROOT_ARCHETYPE) :: Archetype
local function archetypeTraverseRemove(world: World, componentId: i53, from: Archetype): Archetype
local edge = ensureEdge(from, componentId)
local remove = edge.remove
if not remove then
local to = table.clone(from.types)
table.remove(to, table.find(to, componentId))
local at = table.find(to, componentId)
if not at then
return from
end
table.remove(to, at)
remove = ensureArchetype(world, to, from)
edge.remove = remove :: never
end

View file

@ -160,7 +160,7 @@ TEST("world", function()
end
do CASE "show allow remove that doesn't exist on entity"
do CASE "should allow remove that doesn't exist on entity"
local world = jecs.World.new()
local Health = world:entity()
@ -171,6 +171,7 @@ TEST("world", function()
world:remove(id, Poison)
CHECK(world:get(id, Poison) == nil)
print(world:get(id, Health))
CHECK(world:get(id, Health) == 50)
end