Ukendio / jecs

A fast, portable Entity Component System for Luau
https://ukendio.github.io/jecs/
MIT License
146 stars 26 forks source link

Empty entity does not respect cleanup policy #127

Closed vnnh closed 1 month ago

vnnh commented 1 month ago

When world_delete is called, the given entity must have an archetype for archetype_delete to be called, which handles cleanup policies that might be related to the entity. Therefore, when an entity is empty, the cleanup policies are not respected.

local parent = world:entity()
local tag = world:entity()

local child = world:entity()
world:add(child, jecs.pair(jecs.ChildOf, parent))
world:delete(parent)
print(world:contains(child)) -- => true

local entity = world:entity()
world:add(entity, tag)
world:delete(tag)
print(world:has(entity, tag)) -- => true

Adding the following to the top will result in the expected behavior where both statements print false:

world:add(parent, world:component())
world:add(tag, world:component())
Ukendio commented 1 month ago

Resolved in #129