mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-02 04:13:58 -04:00
Added Instance:onEntityAdded and :onEntityRemoved
This commit is contained in:
parent
294242814f
commit
d53a931c3a
1 changed files with 16 additions and 2 deletions
|
@ -32,6 +32,8 @@ function Instance:addEntity(e)
|
|||
error("bad argument #1 to 'Instance:addEntity' (Entity expected, got "..type(e)..")", 2)
|
||||
end
|
||||
|
||||
self:onEntityAdded(e)
|
||||
|
||||
e.instances:add(self)
|
||||
self.entities:add(e)
|
||||
self:checkEntity(e)
|
||||
|
@ -83,6 +85,8 @@ function Instance:flush()
|
|||
for i = 1, self.systems.size do
|
||||
self.systems:get(i):__remove(e)
|
||||
end
|
||||
|
||||
self:onEntityRemoved(e)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -238,6 +242,16 @@ function Instance:clear()
|
|||
return self
|
||||
end
|
||||
|
||||
--- Default callback for adding an Entity.
|
||||
-- @param e The Entity that was added
|
||||
function Instance:onEntityAdded(e)
|
||||
end
|
||||
|
||||
--- Default callback for removing an Entity.
|
||||
-- @param e The Entity that was removed
|
||||
function Instance:onEntityRemoved(e)
|
||||
end
|
||||
|
||||
return setmetatable(Instance, {
|
||||
__call = function(_, ...) return Instance.new(...) end,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue