-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneighborDown.lua
104 lines (77 loc) · 2.63 KB
/
neighborDown.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
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
--[[
This aura tracks the death and revival of group members.
]]
-------------------------------------------------------------------------------
-- init
aura_env.groupMembers = {}
aura_env.makeDeadState = function(unit)
local state = {
["changed"] = true,
["show"] = true,
["unit"] = unit,
["dead"] = true,
}
return state
end
-------------------------------------------------------------------------------
-- TSU: GROUP_ROSTER_UPDATE, UNIT_HEALTH
function(allstates, event, ...)
if event == "GROUP_ROSTER_UPDATE" then
-- Hide all states in 'allstates'.
for _, state in pairs(allstates) do
state.changed = true
state.show = false
end
-- Iterate through the group to calculate the set of valid group unit
-- IDs and to insert a state in 'allstates' if the unit is dead.
local groupMembers = {}
for unit in WA_IterateGroupMembers() do
groupMembers[unit] = true
if UnitIsDeadOrGhost(unit) then
allstates[unit] = aura_env.makeDeadState(unit)
end
end
aura_env.groupMembers = groupMembers
return true
elseif event == "UNIT_HEALTH" then
local unit = ...
if not aura_env.groupMembers[unit] then
-- 'unit' is not in our group.
return false
end
if UnitIsDeadOrGhost(unit) then
-- This unit has died. Insert a state.
allstates[unit] = aura_env.makeDeadState(unit)
return true
else
local state = allstates[unit]
if state == nil or not state.dead then
-- This unit is already marked as alive.
return false
end
-- This unit is newly alive. Update the state.
local duration = aura_env.config.duration
state.dead = false
state.progressType = "timed"
state.expirationTime = GetTime() + duration
state.duration = duration
state.autoHide = true
state.changed = true
return true
end
end
end
-------------------------------------------------------------------------------
-- Custom Variables
{
["expirationTime"] = true,
["duration"] = true,
["dead"] = "bool"
}
-------------------------------------------------------------------------------
-- On Show
local parent = aura_env.region:GetParent()
local dimension = math.min(parent:GetHeight(), parent:GetWidth())
dimension = dimension * aura_env.config.scale
aura_env.region:SetHeight(dimension)
aura_env.region:SetWidth(dimension)