-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added feature for event arguments analyze with delay
- Loading branch information
1 parent
5b01899
commit 45ed40e
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ Util.lua | |
BuffsDebuffs.lua | ||
Settings.lua | ||
UI.lua | ||
DelayedEventHandler.lua | ||
|
||
RaidNotifier.xml | ||
Bindings.xml | ||
|