You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.1 KiB

if not WeakAuras.IsLibsOK() then return end
--- @type string, Private
local AddonName, Private = ...
local isDragonriding = nil
local function HandleEvent(self, event, arg1)
local dragonridingSpellIds = C_MountJournal.GetCollectedDragonridingMounts()
local oldIsDragonriding = isDragonriding
if not IsMounted() then
isDragonriding = false
else
for _, mountId in ipairs(dragonridingSpellIds) do
local spellId = select(2, C_MountJournal.GetMountInfoByID(mountId))
if C_UnitAuras.GetPlayerAuraBySpellID(spellId) then
isDragonriding = true
end
end
end
if oldIsDragonriding ~= isDragonriding then
Private.callbacks:Fire("WA_DRAGONRIDING_UPDATE")
end
if event == "PLAYER_ENTERING_WORLD" and arg1 == true then
C_Timer.After(2, HandleEvent)
end
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_MOUNT_DISPLAY_CHANGED")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:SetScript("OnEvent", HandleEvent)
Private.IsDragonriding = function ()
return isDragonriding
end