Enable classic aura support

main
4n0n 2 years ago
parent 98d46b6b42
commit 2413d15d39
  1. 9
      src/Aura/Aura.lua
  2. 75
      src/AuraTable/AuraTable.lua
  3. 20
      src/List/List.lua

@ -60,7 +60,10 @@ function Aura:New(unit, index, type)
type = nil, type = nil,
} }
Bastion.SpellBook:GetSpell(self.aura.spellId)
if self.aura.spellId then
Bastion.SpellBook:GetSpell(self.aura.spellId)
end
return self return self
end end
@ -89,7 +92,9 @@ function Aura:New(unit, index, type)
index = index, index = index,
type = type, type = type,
} }
Bastion.SpellBook:GetSpell(self.aura.spellId) if self.aura.spellId then
Bastion.SpellBook:GetSpell(self.aura.spellId)
end
return self return self
end end

@ -18,16 +18,21 @@ function AuraTable:New(unit)
local self = setmetatable({}, AuraTable) local self = setmetatable({}, AuraTable)
self.unit = unit self.unit = unit
self.auras = {}
self.auras = {}
self.playerAuras = {} self.playerAuras = {}
self.guid = unit:GetGUID() self.guid = unit:GetGUID()
self.instanceIDLookup = {} self.instanceIDLookup = {}
return self return self
end end
function AuraTable:OnUpdate(auras) function AuraTable:OnUpdate(a)
if not a then
self:Update()
return
end
local isFullUpdate = auras.isFullUpdate local isFullUpdate = auras.isFullUpdate
if isFullUpdate then if isFullUpdate then
@ -110,6 +115,33 @@ end
-- Get a units buffs -- Get a units buffs
function AuraTable:GetUnitBuffs() function AuraTable:GetUnitBuffs()
if Tinkr.classic then
for i = 1, 40 do
local aura = Bastion.Aura:New(self.unit, i, 'HELPFUL')
if not aura:IsValid() then
break
end
local spellId = aura:GetSpell():GetID()
if Bastion.UnitManager['player']:IsUnit(aura:GetSource()) then
if not self.playerAuras[spellId] then
self.playerAuras[spellId] = {}
end
table.insert(self.playerAuras[spellId], aura)
else
if not self.auras[spellId] then
self.auras[spellId] = {}
end
table.insert(self.auras[spellId], aura)
end
end
return
end
AuraUtil_ForEachAura(self.unit.unit, 'HELPFUL', nil, function(a) AuraUtil_ForEachAura(self.unit.unit, 'HELPFUL', nil, function(a)
local aura = Bastion.Aura:CreateFromUnitAuraInfo(a) local aura = Bastion.Aura:CreateFromUnitAuraInfo(a)
@ -121,6 +153,33 @@ end
-- Get a units debuffs -- Get a units debuffs
function AuraTable:GetUnitDebuffs() function AuraTable:GetUnitDebuffs()
if Tinkr.classic then
for i = 1, 40 do
local aura = Bastion.Aura:New(self.unit, i, 'HARMFUL')
if not aura:IsValid() then
break
end
local spellId = aura:GetSpell():GetID()
if Bastion.UnitManager['player']:IsUnit(aura:GetSource()) then
if not self.playerAuras[spellId] then
self.playerAuras[spellId] = {}
end
table.insert(self.playerAuras[spellId], aura)
else
if not self.auras[spellId] then
self.auras[spellId] = {}
end
table.insert(self.auras[spellId], aura)
end
end
return
end
AuraUtil_ForEachAura(self.unit.unit, 'HARMFUL', nil, function(a) AuraUtil_ForEachAura(self.unit.unit, 'HARMFUL', nil, function(a)
local aura = Bastion.Aura:CreateFromUnitAuraInfo(a) local aura = Bastion.Aura:CreateFromUnitAuraInfo(a)
@ -207,11 +266,14 @@ function AuraTable:Find(spell)
end end
for k, a in pairs(aurasub) do for k, a in pairs(aurasub) do
print(a)
if a ~= nil then if a ~= nil then
if a:IsUp() then -- Handle expired and non refreshed dropoffs not coming in UNIT_AURA if a:IsUp() then -- Handle expired and non refreshed dropoffs not coming in UNIT_AURA
return a return a
else else
self:RemoveInstanceID(a:GetAuraInstanceID()) if not Tinkr.classic then
self:RemoveInstanceID(a:GetAuraInstanceID())
end
end end
end end
end end
@ -221,7 +283,8 @@ end
---@return Aura ---@return Aura
function AuraTable:FindMy(spell) function AuraTable:FindMy(spell)
local aurasub = self.playerAuras[spell:GetID()] local auras = self:GetMyUnitAuras()
local aurasub = auras[spell:GetID()]
if not aurasub then if not aurasub then
return Bastion.Aura:New() return Bastion.Aura:New()
@ -232,7 +295,9 @@ function AuraTable:FindMy(spell)
if a:IsUp() then -- Handle expired and non refreshed dropoffs not coming in UNIT_AURA if a:IsUp() then -- Handle expired and non refreshed dropoffs not coming in UNIT_AURA
return a return a
else else
self:RemoveInstanceID(a:GetAuraInstanceID()) if not Tinkr.classic then
self:RemoveInstanceID(a:GetAuraInstanceID())
end
end end
end end
end end

@ -1,7 +1,25 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
---@class List ---@class List
local List = {} local List = {
-- Add overload
---@param self List
---@param value any
---@return List
__add = function(self, value)
self:push(value)
return self
end,
-- Subtract overload
---@param self List
---@param value any
---@return List
__sub = function(self, value)
self:remove(value)
return self
end,
}
List.__index = List List.__index = List
function List:New(from) function List:New(from)

Loading…
Cancel
Save