-
Notifications
You must be signed in to change notification settings - Fork 4
/
monitor.lua
77 lines (63 loc) · 1.65 KB
/
monitor.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
-- periodic timers
local _, addonData = ...
local LONG_TIME = 30
local SHORT_TIME = 0.2
local SECOND_TIME = 1
local monitor = {
second_t = {},
short_t = {},
long_t = {},
isStarted = true,
init = function(self)
addonData.debug:registerCategory("monitor")
self.short_t = self:create(SHORT_TIME, self.callback_short)
self.long_t = self:create(LONG_TIME, self.callback_long)
self.second_t = self:create(SECOND_TIME, self.callback_sec)
self:start()
end,
create = function(_, i, callback, timerRepeat)
local timer
if timerRepeat == nil then
timerRepeat = true
end
if timerRepeat then
timer = C_Timer.NewTicker(i, callback)
else
timer = C_Timer.NewTimer(i, callback)
end
timer.i = i
timer.callback = callback
timer.timerRepeat = timerRepeat
return timer
end,
start = function(self)
if not self.isStarted then
self.short_t = self:create(SHORT_TIME, self.callback_short)
self.second_t = self:create(SECOND_TIME, self.callback_sec)
self.isStarted = true
end
end,
stop = function(self)
if not self.short_t:IsCancelled() then
self.short_t:Cancel()
end
if not self.second_t:IsCancelled() then
self.second_t:Cancel()
end
self.isStarted = false
end,
callback_short = function()
addonData.summon:tick()
end,
callback_sec = function()
addonData.summon:timerSecondTick()
end,
callback_long = function()
addonData.raid:fishArea()
end,
callback = function(_, event, ...)
-- this is a generic debug monitor of events that are under observation
db("monitor", event, ...)
end,
}
addonData.monitor = monitor