mirror of
https://github.com/brues-code/pfUI.git
synced 2026-11-07 11:08:56 +00:00
Fold librange into pfUI.api.UnitInRange
This commit is contained in:
+8
-8
@@ -150,8 +150,7 @@ function pfUI.api.checkversion(chkmajor, chkminor, chkfix)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- [ UnitInRange ]
|
-- [ UnitInRange ]
|
||||||
-- Returns whether a party/raid member is nearby.
|
-- Returns whether a party/raid member is nearby, by the configured range check.
|
||||||
-- It takes care of the rangecheck module if existing.
|
|
||||||
-- unit [string] A unit to query (string, unitID)
|
-- unit [string] A unit to query (string, unitID)
|
||||||
-- return: [bool] "1" if in range otherwise "nil"
|
-- return: [bool] "1" if in range otherwise "nil"
|
||||||
function pfUI.api.UnitInRange(unit)
|
function pfUI.api.UnitInRange(unit)
|
||||||
@@ -166,20 +165,21 @@ function pfUI.api.UnitInRange(unit)
|
|||||||
-- returned nil above, matching the pre-collapse behavior.
|
-- returned nil above, matching the pre-collapse behavior.
|
||||||
if C.unitframes.rangecheck == "0" then return 1 end
|
if C.unitframes.rangecheck == "0" then return 1 end
|
||||||
|
|
||||||
-- UnitXP precise mode: skip librange entirely, use direct distance check
|
-- UnitXP precise mode: direct distance check against the configured range
|
||||||
if C.unitframes.rangecheck_mode == "unitxp" and _G.UnitXP then
|
if C.unitframes.rangecheck_mode == "unitxp" and _G.UnitXP then
|
||||||
local threshold = tonumber(C.unitframes.rangecheck_distance) or 40
|
local threshold = tonumber(C.unitframes.rangecheck_distance) or 40
|
||||||
local success, distance = pcall(_G.UnitXP, "distanceBetween", "player", unit)
|
local success, distance = pcall(_G.UnitXP, "distanceBetween", "player", unit)
|
||||||
if success and distance then
|
if success and distance then
|
||||||
return distance <= threshold and 1 or nil
|
return distance <= threshold and 1 or nil
|
||||||
end
|
end
|
||||||
-- fallthrough to librange if UnitXP fails
|
-- fallthrough to the 40y check if UnitXP fails
|
||||||
end
|
end
|
||||||
|
|
||||||
if pfUI.api.librange then
|
-- ClassicAPI's 40y check, _G-qualified since the bare name is this function
|
||||||
return pfUI.api.librange:UnitInSpellRange(unit)
|
-- inside the pfUI environment. A unit it can't place (outside the client's
|
||||||
end
|
-- sync range) counts as in range.
|
||||||
return nil
|
local inRange, checked = _G.UnitInRange(unit)
|
||||||
|
return (inRange or not checked) and 1 or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- [ UnitHasBuff ]
|
-- [ UnitHasBuff ]
|
||||||
|
|||||||
+1
-1
@@ -1719,7 +1719,7 @@ function pfUI.uf:RefreshUnitState(unit)
|
|||||||
unit.power.bar:SetMinMaxValues(0, 100)
|
unit.power.bar:SetMinMaxValues(0, 100)
|
||||||
SetBarValue(unit.hp.bar, 0)
|
SetBarValue(unit.hp.bar, 0)
|
||||||
SetBarValue(unit.power.bar, 0)
|
SetBarValue(unit.power.bar, 0)
|
||||||
elseif unit.config.faderange == "1" and not pfUI.api.UnitInRange(unit.label .. unit.id, 4) and not unlock then
|
elseif unit.config.faderange == "1" and not pfUI.api.UnitInRange(unit.label .. unit.id) and not unlock then
|
||||||
alpha = unit.alpha_outrange
|
alpha = unit.alpha_outrange
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
<Include file="..\libs\libtipscan.lua"/>
|
<Include file="..\libs\libtipscan.lua"/>
|
||||||
<Include file="..\libs\libspell.lua"/>
|
<Include file="..\libs\libspell.lua"/>
|
||||||
<Include file="..\libs\libdebuff.lua"/>
|
<Include file="..\libs\libdebuff.lua"/>
|
||||||
<Include file="..\libs\librange.lua"/>
|
|
||||||
<Include file="..\libs\libunitscan.lua"/>
|
<Include file="..\libs\libunitscan.lua"/>
|
||||||
<Include file="..\libs\libhealth.lua"/>
|
<Include file="..\libs\libhealth.lua"/>
|
||||||
<Include file="..\libs\libthrottle.lua"/>
|
<Include file="..\libs\libthrottle.lua"/>
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
-- load pfUI environment
|
|
||||||
setfenv(1, pfUI:GetEnvironment())
|
|
||||||
|
|
||||||
--[[ librange ]]--
|
|
||||||
-- A thin wrapper over ClassicAPI's UnitInRange: a fixed 40y healing-range
|
|
||||||
-- check computed C-side from unit positions, valid for any unit. There is
|
|
||||||
-- no cache or scan loop -- the check is cheap enough to run per query,
|
|
||||||
-- which also sidesteps the staleness a cached scan hit on zone changes and
|
|
||||||
-- roster re-indexing.
|
|
||||||
--
|
|
||||||
-- librange:UnitInSpellRange(unit)
|
|
||||||
-- Returns `1` if the unit is within range, `nil` otherwise.
|
|
||||||
|
|
||||||
if pfUI.api.librange then return end
|
|
||||||
|
|
||||||
local librange = {}
|
|
||||||
|
|
||||||
function librange:UnitInSpellRange(unit)
|
|
||||||
-- _G-qualified: bare `UnitInRange` resolves to pfUI.api.UnitInRange inside
|
|
||||||
-- the pfUI environment (which calls us), so this must reach ClassicAPI's
|
|
||||||
-- global directly or it recurses.
|
|
||||||
local inRange, checked = _G.UnitInRange(unit)
|
|
||||||
-- position miss (e.g. a unit outside the client's sync range): we can't
|
|
||||||
-- tell, so default to in-range -- matches the old cache's nil behavior.
|
|
||||||
if not checked then return 1 end
|
|
||||||
return inRange and 1 or nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- add librange to pfUI API
|
|
||||||
pfUI.api.librange = librange
|
|
||||||
Reference in New Issue
Block a user