Ukendio / jecs

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

[BUG] world:clear() does not invoke hooks #132

Closed vnnh closed 3 weeks ago

vnnh commented 1 month ago

Calling world:clear(id) does not invoke any OnRemove hooks for components that the entity might have.

local component = world:component()
world:set(component,jecs.OnAdd,function()
    print("added")
end)
world:set(component,jecs.OnRemove,function()
    print("removed")
end)

local entity = world:entity()
world:add(entity,component)
world:clear(entity)
-- only prints added
-- changing the :clear() to :delete() prints removed as expected
Ukendio commented 3 weeks ago

Fixed in #141