Refactor NameplateStatus trigger logic to use unit identifiers instead of GUIDs

This commit is contained in:
2025-05-25 14:36:15 +02:00
parent b80a068054
commit 64905acbe5
2 changed files with 18 additions and 26 deletions

View File

@@ -1,30 +1,22 @@
-- 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
if UnitExists(unit) 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,
}
states[unit] = states[unit] or {}
states[unit].unit = unit
states[unit].frame = nameplate
states[unit].changed = true
states[unit].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
states[unit] = states[unit] or {}
states[unit].unit = unit
states[unit].show = false
states[unit].changed = true
elseif event == "FRAME_UPDATE" then
local theTime = GetTime()
if not aura_env.last or aura_env.last < theTime - 0.2 then
aura_env.last = theTime
@@ -32,12 +24,12 @@ function(states, event, unit, ...)
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
local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
states[unit] = states[unit] or {}
states[unit].unit = unit
states[unit].show = isPvp
states[unit].changed = true
states[unit].frame = nameplate
end
end
end