|
|
|
@ -16,8 +16,12 @@ local EventManager = { |
|
|
|
|
events = {}, |
|
|
|
|
eventHandlers = {}, |
|
|
|
|
wowEventHandlers = {}, |
|
|
|
|
selfCombatEventHandlers = {}, |
|
|
|
|
CombatEventHandlers = {}, |
|
|
|
|
selfCombatEventHandlers = { |
|
|
|
|
["*"] = {}, |
|
|
|
|
}, |
|
|
|
|
CombatEventHandlers = { |
|
|
|
|
["*"] = {}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
EventManager.__index = EventManager |
|
|
|
|
|
|
|
|
@ -117,21 +121,38 @@ 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 |
|
|
|
|
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 |
|
|
|
|
if self.CombatEventHandlers[subevent] then |
|
|
|
|
for _, callback in ipairs(self.CombatEventHandlers[subevent]) do |
|
|
|
|
end |
|
|
|
|
if self.CombatEventHandlers[key] then |
|
|
|
|
for _, callback in ipairs(self.CombatEventHandlers[key]) do |
|
|
|
|
callback(timestamp, subevent, ...) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Bastion.EventManager = EventManager |
|
|
|
|
|
|
|
|
|