forked from kratob/GuiBarHero3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGcd.lua
45 lines (38 loc) · 914 Bytes
/
Gcd.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
local Gcd = {}
local Gcd_mt = { __index = Gcd }
function Gcd:Release()
self.frame:UnregisterAllEvents()
self.frame:SetScript("OnEvent", nil)
end
function Gcd:Create(frame)
gcd = {}
setmetatable(gcd, Gcd_mt)
Gcd:Initialize(frame)
return gcd
end
function Gcd:Initialize(frame)
self.next_gcd = 0
self.duration = 1.5
self.frame = frame
frame.owner = gcd
frame:SetScript("OnEvent", Gcd.OnEvent)
frame:RegisterEvent("SPELL_UPDATE_COOLDOWN")
end
function Gcd:OnEvent()
self = self.owner
local cooldownInfo = C_Spell.GetSpellCooldown(61304)
if cooldownInfo and cooldownInfo.startTime and cooldownInfo.duration then
self.next_gcd = cooldownInfo.startTime + cooldownInfo.duration
self.duration = cooldownInfo.duration
else
self.next_gcd = 0
self.duration = 1.5
end
end
function Gcd:GetNext()
return self.next_gcd
end
function Gcd:GetDuration()
return self.duration
end
GuiBarHero.Gcd = Gcd