Skip to content

Commit

Permalink
Added feature for event arguments analyze with delay
Browse files Browse the repository at this point in the history
  • Loading branch information
MysteryDragon committed Nov 8, 2021
1 parent 5b01899 commit 45ed40e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
51 changes: 51 additions & 0 deletions DelayedEventHandler.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local EventArgumentBag = ZO_Object:Subclass()

function EventArgumentBag:New()
local object = ZO_Object.New(self)

object.allEventArgs = {}

return object
end

function EventArgumentBag:Push(args)
table.insert(self.allEventArgs, args)
end

function EventArgumentBag:ContainsArgumentWithValue(name, value)
for _, arguments in ipairs(self.allEventArgs) do
if arguments[name] == value then
return true
end
end

return false
end

local Handler = {}

local eventStorage = {}

function Handler.Add(name, arguments, releaseFunction, delayInMs)
if eventStorage[name] == nil then
eventStorage[name] = {
callId = nil,
argsBag = EventArgumentBag:New(),
}
end

eventStorage[name].argsBag:Push(arguments)

if eventStorage[name].callId == nil then
eventStorage[name].callId = zo_callLater(
function()
releaseFunction(eventStorage[name].argsBag)
eventStorage[name] = nil
end,
delayInMs
)
end
end

RaidNotifier = RaidNotifier or {}
RaidNotifier.DelayedEventHandler = Handler
1 change: 1 addition & 0 deletions RaidNotifier.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Util.lua
BuffsDebuffs.lua
Settings.lua
UI.lua
DelayedEventHandler.lua

RaidNotifier.xml
Bindings.xml
Expand Down

0 comments on commit 45ed40e

Please sign in to comment.