From 0d5f05fa6480cadff40929732d2592746f32bfbc Mon Sep 17 00:00:00 2001 From: Justin van der Leij Date: Tue, 20 Feb 2018 23:46:11 +0100 Subject: [PATCH] Fixed some things regarding deregistering --- fluid/instance.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fluid/instance.lua b/fluid/instance.lua index d185846..8d8005c 100644 --- a/fluid/instance.lua +++ b/fluid/instance.lua @@ -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