mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-02 19:50:02 +00:00
Event-drive nameplate target state; drop per-tick poll and targetPlateGuid
frameState.hasTarget/targetGuid were polled via UnitExists("target") every
central-loop tick, while targetPlateGuid held the same guid but was already
event-driven -- redundant. Set frameState target fields in PLAYER_TARGET_CHANGED
(seeded on PLAYER_ENTERING_WORLD for a target held across reload), remove the
poll, and collapse targetPlateGuid into frameState.targetGuid (the castbar
frame now reads that). The central loop's only remaining per-tick poll is
GetTime().
This commit is contained in:
@@ -73,7 +73,6 @@ pfUI:RegisterModule("nameplates", function ()
|
||||
-- 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.
|
||||
local plateByGuid = {}
|
||||
local targetPlateGuid = nil
|
||||
|
||||
-- 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
|
||||
@@ -499,7 +498,7 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
|
||||
CacheConfig()
|
||||
this:SetGameVariables()
|
||||
RebuildRaidGuidCache()
|
||||
targetPlateGuid = UnitExists("target") and UnitGUID("target") or nil
|
||||
frameState.hasTarget, frameState.targetGuid = UnitExists("target"), UnitGUID("target")
|
||||
end
|
||||
|
||||
-- Handle friendly zone nameplate disable feature
|
||||
@@ -662,7 +661,7 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
|
||||
end
|
||||
|
||||
elseif event == "PLAYER_TARGET_CHANGED" then
|
||||
targetPlateGuid = UnitExists("target") and UnitGUID("target") or nil
|
||||
frameState.hasTarget, frameState.targetGuid = UnitExists("target"), UnitGUID('target')
|
||||
-- Flag the target's plate for update
|
||||
local plate = C_NamePlate.GetNamePlateForUnit("target")
|
||||
if plate and plate.nameplate then
|
||||
@@ -691,7 +690,6 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
|
||||
|
||||
-- PERF: Cache GetTime() once per frame
|
||||
frameState.now = now
|
||||
frameState.hasTarget, frameState.targetGuid = UnitExists("target")
|
||||
|
||||
if this.eventcache then
|
||||
this.eventcache = nil
|
||||
@@ -1671,8 +1669,8 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
|
||||
-- loop's nameplates_castbar gate.)
|
||||
nameplates.castbarFrame = CreateFrame("Frame", nil, UIParent)
|
||||
nameplates.castbarFrame:SetScript("OnUpdate", function()
|
||||
if not cfg.showcastbar or not targetPlateGuid then return end
|
||||
local nameplate = plateByGuid[targetPlateGuid]
|
||||
if not cfg.showcastbar or not frameState.targetGuid then return end
|
||||
local nameplate = plateByGuid[frameState.targetGuid]
|
||||
if not nameplate then return end
|
||||
nameplates.UpdateCastbar(nameplate, GetTime())
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user