48 lines
1.1 KiB
Lua
48 lines
1.1 KiB
Lua
-- NAME_PLATE_UNIT_ADDED NAME_PLATE_UNIT_REMOVED FRAME_UPDATE
|
|
function(states, event, unit, ...)
|
|
if event == "NAME_PLATE_UNIT_ADDED" and unit or event == "NAME_PLATE_UNIT_REMOVED" and unit then
|
|
local GUID = UnitGUID(unit)
|
|
if GUID then
|
|
local isPvp = UnitIsPVP(unit)
|
|
local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
|
|
|
|
states[GUID] = {
|
|
GUID = GUID,
|
|
unit = unit,
|
|
frame = nameplate,
|
|
progressType = "static",
|
|
autoHide = true,
|
|
changed = true,
|
|
show = isPvp,
|
|
}
|
|
end
|
|
elseif event == "NAME_PLATE_UNIT_REMOVED" and unit then
|
|
local GUID = UnitGUID(unit)
|
|
local state = states[GUID]
|
|
if state then
|
|
state.show = false
|
|
state.changed = true
|
|
end
|
|
end
|
|
if event == "FRAME_UPDATE" then
|
|
local theTime = GetTime()
|
|
if not aura_env.last or aura_env.last < theTime - 0.2 then
|
|
aura_env.last = theTime
|
|
for i = 1, 40 do
|
|
local unit = "nameplate" .. i
|
|
if UnitExists(unit) then
|
|
local isPvp = UnitIsPVP(unit)
|
|
local GUID = UnitGUID(unit)
|
|
local state = states[GUID]
|
|
if state then
|
|
state.show = isPvp
|
|
state.changed = true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return true
|
|
end
|