diff --git a/src/EventManager/EventManager.lua b/src/EventManager/EventManager.lua index 9dc8cbd..6cf36f5 100644 --- a/src/EventManager/EventManager.lua +++ b/src/EventManager/EventManager.lua @@ -16,8 +16,12 @@ local EventManager = { events = {}, eventHandlers = {}, wowEventHandlers = {}, - selfCombatEventHandlers = {}, - CombatEventHandlers = {}, + selfCombatEventHandlers = { + ["*"] = {}, + }, + CombatEventHandlers = { + ["*"] = {}, + }, } EventManager.__index = EventManager @@ -117,18 +121,35 @@ function EventManager:RegisterCombatEvent(subevents, handler) end end ----@param timestamp number ----@param subevent string ---@param ... any -function EventManager:CLEUHandler(timestamp, subevent, ...) - if self.selfCombatEventHandlers[subevent] and self.playerGUID and select(2, ...) == self.playerGUID then - for _, callback in ipairs(self.selfCombatEventHandlers[subevent]) do - callback(timestamp, subevent, ...) +function EventManager:CLEUHandler(...) + ---@type number + local timestamp = select(1, ...) + ---@type string + local subevent = select(2, ...) + ---@type string + local sourceGUID = select(4, ...) + ---@type string + local destGUID = select(8, ...) + + local keys = { + subevent, + "*" + } + + local isSelf = self.playerGUID and sourceGUID == self.playerGUID + for _, key in ipairs(keys) do + if isSelf then + if self.selfCombatEventHandlers[key] then + for _, callback in ipairs(self.selfCombatEventHandlers[key]) do + callback(timestamp, subevent, ...) + end + end end - end - if self.CombatEventHandlers[subevent] then - for _, callback in ipairs(self.CombatEventHandlers[subevent]) do - callback(timestamp, subevent, ...) + if self.CombatEventHandlers[key] then + for _, callback in ipairs(self.CombatEventHandlers[key]) do + callback(timestamp, subevent, ...) + end end end end