Skip to content

Commit

Permalink
v0.1.1-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
ActivexDiamond committed Jul 20, 2023
1 parent c7c51d3 commit 088fa6e
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cat-paw/core/patterns/event/EventSystem.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,32 @@ function EventSystem:_fire(eventInstance)
end

------------------------------ API ------------------------------
function EventSystem:detach(target)
for i = #self.rootSubscribers, 1, -1 do
if self.rootSubscribers[i] == target then
table.remove(self.rootSubscribers, i)
end
end

for k, target in pairs(self.rootSubscribers) do

end

for e, subscriber in pairs(self.events) do
if subscriber == target then
self.events[e][target] = nil
end
end
end

EventSystem.attach = overload({
EventSystem, 'table', Event,
function(self, target, event)
--print("case 1", self, target, event, event.class, event:isSubclassOf(Event), event == Event)
self:_rawAttach(target, event, target[event])
end,

EventSystem, 'table', 'table',
function(self, target, events)
--print("case 2", self, target, events, events.class, events == Event)
--print(events[1].class, events[1] == Event, events[1]:isSubclassOf(Event))
for _, e in pairs(events) do
self:_rawAttach(target, e, target[e])
end
Expand Down

0 comments on commit 088fa6e

Please sign in to comment.