mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-26 14:00:48 +00:00
Resolve target castbar plate via cached GUID, not per-frame lookup
The unthrottled target castbar frame called C_NamePlate.GetNamePlateForUnit every frame. Stash the target's GUID on PLAYER_TARGET_CHANGED (seeded on PLAYER_ENTERING_WORLD for a target held across reload) and resolve the plate through plateByGuid instead -- a table lookup plus a real idle skip when there's no target. The plate is looked up per frame (not cached) so a plate spawning/despawning while the unit stays targeted still resolves correctly.
This commit is contained in:
@@ -69,6 +69,7 @@ pfUI:RegisterModule("nameplates", function ()
|
|||||||
-- guid -> nameplate, maintained on NAME_PLATE_UNIT_ADDED/_REMOVED so a cast
|
-- guid -> nameplate, maintained on NAME_PLATE_UNIT_ADDED/_REMOVED so a cast
|
||||||
-- event can find its plate in O(1) and only cache casts we actually show.
|
-- event can find its plate in O(1) and only cache casts we actually show.
|
||||||
local plateByGuid = {}
|
local plateByGuid = {}
|
||||||
|
local targetPlateGuid = nil
|
||||||
|
|
||||||
-- One-shot C_Spell poll. Only used to seed a plate that spawns while its
|
-- One-shot C_Spell poll. Only used to seed a plate that spawns while its
|
||||||
-- unit is already mid-cast (its SPELL_START_OTHER fired before the plate
|
-- unit is already mid-cast (its SPELL_START_OTHER fired before the plate
|
||||||
@@ -497,6 +498,7 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
|
|||||||
CacheConfig()
|
CacheConfig()
|
||||||
this:SetGameVariables()
|
this:SetGameVariables()
|
||||||
RebuildRaidGuidCache()
|
RebuildRaidGuidCache()
|
||||||
|
targetPlateGuid = UnitExists("target") and UnitGUID("target") or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handle friendly zone nameplate disable feature
|
-- Handle friendly zone nameplate disable feature
|
||||||
@@ -650,6 +652,7 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
|
|||||||
end
|
end
|
||||||
|
|
||||||
elseif event == "PLAYER_TARGET_CHANGED" then
|
elseif event == "PLAYER_TARGET_CHANGED" then
|
||||||
|
targetPlateGuid = UnitExists("target") and UnitGUID("target") or nil
|
||||||
-- Flag the target's plate for update
|
-- Flag the target's plate for update
|
||||||
local plate = C_NamePlate.GetNamePlateForUnit("target")
|
local plate = C_NamePlate.GetNamePlateForUnit("target")
|
||||||
if plate and plate.nameplate then
|
if plate and plate.nameplate then
|
||||||
@@ -1669,10 +1672,10 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
|
|||||||
-- loop's nameplates_castbar gate.)
|
-- loop's nameplates_castbar gate.)
|
||||||
nameplates.castbarFrame = CreateFrame("Frame", nil, UIParent)
|
nameplates.castbarFrame = CreateFrame("Frame", nil, UIParent)
|
||||||
nameplates.castbarFrame:SetScript("OnUpdate", function()
|
nameplates.castbarFrame:SetScript("OnUpdate", function()
|
||||||
if not cfg.showcastbar then return end
|
if not cfg.showcastbar or not targetPlateGuid then return end
|
||||||
local frame = C_NamePlate.GetNamePlateForUnit("target")
|
local nameplate = plateByGuid[targetPlateGuid]
|
||||||
if not frame or not frame.nameplate then return end
|
if not nameplate then return end
|
||||||
nameplates.UpdateCastbar(frame.nameplate, GetTime())
|
nameplates.UpdateCastbar(nameplate, GetTime())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- set nameplate game settings
|
-- set nameplate game settings
|
||||||
|
|||||||
Reference in New Issue
Block a user