mirror of
https://github.com/Reuh/ubiquitousse.git
synced 2025-10-28 01:29:31 +00:00
Fix error if onRemove in subsystem call :remove again
This commit is contained in:
parent
f607058753
commit
366bb63ed5
1 changed files with 24 additions and 20 deletions
|
|
@ -243,11 +243,14 @@ let system_mt = {
|
||||||
-- Returns all removed entities.
|
-- Returns all removed entities.
|
||||||
-- Complexity: O(1) per system.
|
-- Complexity: O(1) per system.
|
||||||
remove = :(e, ...)
|
remove = :(e, ...)
|
||||||
if e ~= nil and @_previous[e] then
|
if e ~= nil then
|
||||||
|
if @_previous[e] then
|
||||||
-- remove from subsystems
|
-- remove from subsystems
|
||||||
for _, s in ipairs(@systems) do
|
for _, s in ipairs(@systems) do
|
||||||
s:remove(e)
|
s:remove(e)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
if @_previous[e] then -- recheck in case it was removed already from a subsystem onRemove callback
|
||||||
-- remove from linked list
|
-- remove from linked list
|
||||||
let prev = @_previous[e]
|
let prev = @_previous[e]
|
||||||
if prev == true then
|
if prev == true then
|
||||||
|
|
@ -266,6 +269,7 @@ let system_mt = {
|
||||||
@entityCount -= 1
|
@entityCount -= 1
|
||||||
@onRemove(e[@name])
|
@onRemove(e[@name])
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if ... then
|
if ... then
|
||||||
return e, @remove(...)
|
return e, @remove(...)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue