mirror of
https://github.com/brues-code/pfUI.git
synced 2026-11-09 03:38:58 +00:00
Expire cached aggro on UNIT_TARGET
UnitHasAggro caches a positive answer for 1s and a negative one for 0.3s, so the aggro glow lagged a taunt or a mob turning on a healer by up to that long. A retarget now expires the entries it can affect: every unit that had aggro and the retargeting unit's new target. The rest stay cached, so the scan runs no more often. Mobs without a token of their own fire it with their GUID, and "<guid>target" composes.
This commit is contained in:
@@ -313,6 +313,7 @@ function pfUI.api.UnitHasAggro(unit)
|
|||||||
if not data then data = { }; aggrodata[unit] = data end
|
if not data then data = { }; aggrodata[unit] = data end
|
||||||
data.check = now
|
data.check = now
|
||||||
data.state = 0
|
data.state = 0
|
||||||
|
data.guid = UnitGUID(unit)
|
||||||
|
|
||||||
if UnitExists(unit) and UnitIsFriend(unit, "player") then
|
if UnitExists(unit) and UnitIsFriend(unit, "player") then
|
||||||
for i = 1, table.getn(aggroScan) do
|
for i = 1, table.getn(aggroScan) do
|
||||||
@@ -329,6 +330,21 @@ function pfUI.api.UnitHasAggro(unit)
|
|||||||
return data.state
|
return data.state
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- A unit turned to someone else, so two kinds of cached answer may be stale:
|
||||||
|
-- every unit that had aggro (the attacker may have left it) and the new
|
||||||
|
-- target. Those recompute on their next read instead of riding out the
|
||||||
|
-- cache; the rest stay cached, since the retarget changes nothing for them.
|
||||||
|
-- Units without a token of their own (a raid member's target) still fire it
|
||||||
|
-- with their GUID, which composes with "target" like any token.
|
||||||
|
pfUI.events:RegisterFrameEventAndCallback("UNIT_TARGET", function(_, unit)
|
||||||
|
local target = UnitGUID(unit .. "target")
|
||||||
|
for _, data in pairs(aggrodata) do
|
||||||
|
if data.state > 0 or (target and data.guid == target) then
|
||||||
|
data.check = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
function pfUI.uf:UpdateVisibility()
|
function pfUI.uf:UpdateVisibility()
|
||||||
local self = self or this
|
local self = self or this
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user