forked from NeeRgY/Cell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils_Auras.lua
More file actions
109 lines (99 loc) · 3.62 KB
/
Copy pathUtils_Auras.lua
File metadata and controls
109 lines (99 loc) · 3.62 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
local _, Cell = ...
local F = Cell.funcs
function F.GetAuraTiming(auraInfo)
local expirationTime = auraInfo and auraInfo.expirationTime or 0
local duration = auraInfo and auraInfo.duration
if F.IsValueNonSecret(expirationTime) and F.IsValueNonSecret(duration) then
return (expirationTime or 0) - (duration or 0), duration or 0, false
end
return 0, 0, true
end
function F.GetAuraStackText(unit, auraInstanceID, count, minStacks)
minStacks = minStacks or 2
if Cell.isMidnight and unit and auraInstanceID and C_UnitAuras and C_UnitAuras.GetAuraApplicationDisplayCount then
local ok, text = pcall(C_UnitAuras.GetAuraApplicationDisplayCount, unit, auraInstanceID, minStacks, 99)
if ok and text ~= nil then
return text
end
end
if issecretvalue and issecretvalue(count) then
return ""
end
count = count or 0
if count == 0 or count == 1 or (minStacks > 1 and count < minStacks) then
return ""
end
return count
end
function F.ApplyAuraCooldown(cooldown, start, duration, unit, auraInstanceID)
if not cooldown then return false end
local timingReadable = F.IsValueNonSecret(start) and F.IsValueNonSecret(duration) and duration and duration ~= 0
if (not timingReadable) and Cell.isMidnight and unit and auraInstanceID
and C_UnitAuras and C_UnitAuras.GetAuraDuration
and cooldown.SetCooldownFromDurationObject then
local durationObj = C_UnitAuras.GetAuraDuration(unit, auraInstanceID)
if durationObj then
cooldown:SetCooldownFromDurationObject(durationObj)
cooldown:Show()
return true
end
end
if timingReadable then
if cooldown._SetCooldown then
cooldown:_SetCooldown(start, duration)
cooldown:Show()
return true
elseif cooldown.ShowCooldown then
cooldown:ShowCooldown(start, duration)
return true
end
end
return false
end
function F.BindAuraMeta(frame, unit, auraInstanceID)
if not frame then return end
frame._cellAuraUnit = unit
frame._cellAuraInstanceID = auraInstanceID
end
function F.ClearAuraMeta(frame)
if not frame then return end
frame._cellAuraUnit = nil
frame._cellAuraInstanceID = nil
end
function F.CopyAuraTable(aura)
if not aura then return nil end
if aura._cellOwned then return aura end
local copy = {
_cellOwned = true,
auraInstanceID = aura.auraInstanceID,
spellId = aura.spellId,
name = aura.name,
icon = aura.icon,
applications = aura.applications,
dispelName = aura.dispelName,
duration = aura.duration,
expirationTime = aura.expirationTime,
sourceUnit = aura.sourceUnit,
source = aura.source,
isHarmful = aura.isHarmful,
isHelpful = aura.isHelpful,
isNameplateOnly = aura.isNameplateOnly,
isRaid = aura.isRaid,
isBossAura = aura.isBossAura,
isFromPlayerOrPlayerPet = aura.isFromPlayerOrPlayerPet,
isStealable = aura.isStealable,
canApplyAura = aura.canApplyAura,
nameplateShowAll = aura.nameplateShowAll,
nameplateShowPersonal = aura.nameplateShowPersonal,
points = aura.points,
timeMod = aura.timeMod,
hideOnPartyFrames = aura.hideOnPartyFrames,
canActivePlayerDispel = aura.canActivePlayerDispel,
isTankRoleAura = aura.isTankRoleAura,
isHealerRoleAura = aura.isHealerRoleAura,
isDPSRoleAura = aura.isDPSRoleAura,
isPriorityAura = aura.isPriorityAura,
isRoleAura = aura.isRoleAura,
}
return copy
end