Fixed some things regarding deregistering

This commit is contained in:
Justin van der Leij 2018-02-20 23:46:11 +01:00
parent fae3c4a427
commit 0d5f05fa64

View file

@ -39,24 +39,26 @@ function Instance:removeEntity(e)
end
end
function Instance:addSystem(system, eventName)
function Instance:addSystem(system, eventName, callback)
if not self.namedSystems[system] then
self.systems[#self.systems + 1] = system
self.namedSystems[system] = system
end
self.eventManager:register(eventName, system)
self.eventManager:register(eventName, system, callback)
return self
end
function Instance:removeSystem(system)
function Instance:removeSystem(system, callback)
for index, other in ipairs(self.systems) do
if system == other then
table.remove(self.systems, index)
end
end
self.eventManager:deregister(eventName, system, callback)
self.namedSystems[system] = nil
return self