(fix/Prototypes) Add inRange trigger properly to Prototypes too
(cherry picked from commit ade6cb124a76fbb5ebd1a91936f1cb188d70789f)
This commit is contained in:
@@ -73,7 +73,7 @@ local loaded_auras = {}; -- id to bool map
|
|||||||
local LoadEvent, HandleEvent, HandleUnitEvent, TestForTriState, TestForToggle, TestForLongString, TestForMultiSelect
|
local LoadEvent, HandleEvent, HandleUnitEvent, TestForTriState, TestForToggle, TestForLongString, TestForMultiSelect
|
||||||
local ConstructTest, ConstructFunction
|
local ConstructTest, ConstructFunction
|
||||||
|
|
||||||
|
local inRangeUnits = {}
|
||||||
local nameplateExists = {}
|
local nameplateExists = {}
|
||||||
|
|
||||||
function WeakAuras.UnitExistsFixed(unit, smart)
|
function WeakAuras.UnitExistsFixed(unit, smart)
|
||||||
@@ -1241,6 +1241,7 @@ function GenericTrigger.UnloadAll()
|
|||||||
wipe(loaded_auras);
|
wipe(loaded_auras);
|
||||||
wipe(loaded_events);
|
wipe(loaded_events);
|
||||||
wipe(loaded_unit_events);
|
wipe(loaded_unit_events);
|
||||||
|
wipe(inRangeUnits);
|
||||||
Private.CancelAllDelayedTriggers();
|
Private.CancelAllDelayedTriggers();
|
||||||
Private.UnregisterAllEveryFrameUpdate();
|
Private.UnregisterAllEveryFrameUpdate();
|
||||||
end
|
end
|
||||||
@@ -1260,6 +1261,9 @@ function GenericTrigger.UnloadDisplays(toUnload)
|
|||||||
for unit, events in pairs(loaded_unit_events) do
|
for unit, events in pairs(loaded_unit_events) do
|
||||||
for eventname, auras in pairs(events) do
|
for eventname, auras in pairs(events) do
|
||||||
auras[id] = nil;
|
auras[id] = nil;
|
||||||
|
if eventname == "UNIT_IN_RANGE_UPDATE" and not next(auras) then
|
||||||
|
inRangeUnits[unit] = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1424,6 +1428,9 @@ function LoadEvent(id, triggernum, data)
|
|||||||
loaded_unit_events[u][event] = loaded_unit_events[u][event] or {};
|
loaded_unit_events[u][event] = loaded_unit_events[u][event] or {};
|
||||||
loaded_unit_events[u][event][id] = loaded_unit_events[u][event][id] or {}
|
loaded_unit_events[u][event][id] = loaded_unit_events[u][event][id] or {}
|
||||||
loaded_unit_events[u][event][id][triggernum] = data;
|
loaded_unit_events[u][event][id][triggernum] = data;
|
||||||
|
if event == "UNIT_IN_RANGE_UPDATE" then
|
||||||
|
inRangeUnits[u] = true
|
||||||
|
end
|
||||||
end, unit, includePets
|
end, unit, includePets
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@@ -3831,6 +3838,34 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Player In Range
|
||||||
|
do
|
||||||
|
local inRangeFrame = nil
|
||||||
|
|
||||||
|
local function PlayerInRangeUpdate(self, elapsed)
|
||||||
|
Private.StartProfileSystem("generictrigger player in range");
|
||||||
|
self.elapsed = self.elapsed + elapsed
|
||||||
|
if self.elapsed >= 1.0 then
|
||||||
|
self.elapsed = 0
|
||||||
|
for unit in next, inRangeUnits do
|
||||||
|
if UnitExists(unit) then
|
||||||
|
WeakAuras.ScanUnitEvents("UNIT_IN_RANGE_UPDATE", unit)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Private.StopProfileSystem("generictrigger player in range");
|
||||||
|
end
|
||||||
|
|
||||||
|
function WeakAuras.WatchForPlayerInRange()
|
||||||
|
if not inRangeFrame then
|
||||||
|
inRangeFrame = CreateFrame("Frame")
|
||||||
|
inRangeFrame.elapsed = 0
|
||||||
|
Private.frames["Player In Range Frame"] = inRangeFrame
|
||||||
|
end
|
||||||
|
inRangeFrame:SetScript("OnUpdate", PlayerInRangeUpdate)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Nameplates
|
-- Nameplates
|
||||||
do
|
do
|
||||||
local watchNameplates
|
local watchNameplates
|
||||||
|
|||||||
@@ -1640,6 +1640,9 @@ Private.event_prototypes = {
|
|||||||
end,
|
end,
|
||||||
loadFunc = function(trigger)
|
loadFunc = function(trigger)
|
||||||
AddWatchedUnits(trigger.unit, nil, trigger.use_unitisunit and trigger.unitisunit or nil)
|
AddWatchedUnits(trigger.unit, nil, trigger.use_unitisunit and trigger.unitisunit or nil)
|
||||||
|
if trigger.use_inRange then
|
||||||
|
WeakAuras.WatchForPlayerInRange()
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
force_events = unitHelperFunctions.UnitChangedForceEvents,
|
force_events = unitHelperFunctions.UnitChangedForceEvents,
|
||||||
name = L["Unit Characteristics"],
|
name = L["Unit Characteristics"],
|
||||||
@@ -1861,7 +1864,7 @@ Private.event_prototypes = {
|
|||||||
enable = function(trigger)
|
enable = function(trigger)
|
||||||
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
|
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
|
||||||
end,
|
end,
|
||||||
init = "UnitInRange(unit)"
|
init = "Private.ExecEnv.UnitInRangeFixed(unit)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "hostility",
|
name = "hostility",
|
||||||
@@ -2301,6 +2304,9 @@ Private.event_prototypes = {
|
|||||||
loadFunc = function(trigger)
|
loadFunc = function(trigger)
|
||||||
local includePets = trigger.use_includePets == true and trigger.includePets or nil
|
local includePets = trigger.use_includePets == true and trigger.includePets or nil
|
||||||
AddWatchedUnits(trigger.unit, includePets)
|
AddWatchedUnits(trigger.unit, includePets)
|
||||||
|
if trigger.use_inRange then
|
||||||
|
WeakAuras.WatchForPlayerInRange()
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
force_events = unitHelperFunctions.UnitChangedForceEventsWithPets,
|
force_events = unitHelperFunctions.UnitChangedForceEventsWithPets,
|
||||||
name = L["Health"],
|
name = L["Health"],
|
||||||
@@ -2607,7 +2613,7 @@ Private.event_prototypes = {
|
|||||||
enable = function(trigger)
|
enable = function(trigger)
|
||||||
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
|
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
|
||||||
end,
|
end,
|
||||||
init = "UnitInRange(unit)"
|
init = "Private.ExecEnv.UnitInRangeFixed(unit)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "nameplateType",
|
name = "nameplateType",
|
||||||
@@ -2727,6 +2733,9 @@ Private.event_prototypes = {
|
|||||||
end
|
end
|
||||||
local includePets = trigger.use_includePets == true and trigger.includePets or nil
|
local includePets = trigger.use_includePets == true and trigger.includePets or nil
|
||||||
AddWatchedUnits(trigger.unit, includePets)
|
AddWatchedUnits(trigger.unit, includePets)
|
||||||
|
if trigger.use_inRange then
|
||||||
|
WeakAuras.WatchForPlayerInRange()
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
force_events = unitHelperFunctions.UnitChangedForceEventsWithPets,
|
force_events = unitHelperFunctions.UnitChangedForceEventsWithPets,
|
||||||
name = L["Power"],
|
name = L["Power"],
|
||||||
@@ -3109,7 +3118,7 @@ Private.event_prototypes = {
|
|||||||
enable = function(trigger)
|
enable = function(trigger)
|
||||||
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
|
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
|
||||||
end,
|
end,
|
||||||
init = "UnitInRange(unit)"
|
init = "Private.ExecEnv.UnitInRangeFixed(unit)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "nameplateType",
|
name = "nameplateType",
|
||||||
|
|||||||
Reference in New Issue
Block a user