|
|
|
@ -100,6 +100,11 @@ function Aura:New(unit, index, type) |
|
|
|
|
return self |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if C_UnitAuras.GetAuraDataByIndex then |
|
|
|
|
local unitAuraInfo = C_UnitAuras.GetAuraDataByIndex(unit:GetOMToken(), index, type) |
|
|
|
|
return Aura:CreateFromUnitAuraInfo(unitAuraInfo, index, type) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local name, icon, count, dispelType, duration, expirationTime, source, isStealable, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, castByPlayer, nameplateShowAll, timeMod, v1, v2, v3, v4 = |
|
|
|
|
UnitAura(unit:GetOMToken(), index, type) |
|
|
|
|
---@class Bastion.Aura |
|
|
|
@ -137,10 +142,10 @@ function Aura:New(unit, index, type) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local foodAndDrinkStrings = { |
|
|
|
|
[5] = "Refreshment", |
|
|
|
|
[1] = MINIMAP_TRACKING_VENDOR_FOOD, -- Food & Drink |
|
|
|
|
[2] = POWER_TYPE_FOOD, -- Food |
|
|
|
|
[4] = TUTORIAL_TITLE12, -- Drink |
|
|
|
|
[3] = TUTORIAL_TITLE12, -- Drink |
|
|
|
|
[4] = "Refreshment", |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
---@type { [number]: boolean } |
|
|
|
@ -151,9 +156,10 @@ function Aura:IsFoodOrDrink() |
|
|
|
|
if cachedFoodAndDrinkIDs[self.aura.spellId] then |
|
|
|
|
return cachedFoodAndDrinkIDs[self.aura.spellId] |
|
|
|
|
else |
|
|
|
|
if self.aura.name then |
|
|
|
|
local name = self:GetName() |
|
|
|
|
if type(name) == "string" then |
|
|
|
|
for i = 1, #foodAndDrinkStrings do |
|
|
|
|
if self.aura.name:find(foodAndDrinkStrings[i]) then |
|
|
|
|
if name:find(foodAndDrinkStrings[i]) then |
|
|
|
|
cachedFoodAndDrinkIDs[self.aura.spellId] = true |
|
|
|
|
return true |
|
|
|
|
end |
|
|
|
@ -165,46 +171,40 @@ function Aura:IsFoodOrDrink() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Constructor |
|
|
|
|
---@param unitAuraInfo AuraData |
|
|
|
|
---@param unitAuraInfo? AuraData |
|
|
|
|
---@param index? number |
|
|
|
|
---@param type? "HELPFUL"|"HARMFUL" |
|
|
|
|
---@return Bastion.Aura |
|
|
|
|
function Aura:CreateFromUnitAuraInfo(unitAuraInfo) |
|
|
|
|
---@class Bastion.Aura |
|
|
|
|
local self = setmetatable({}, Aura) |
|
|
|
|
--[[ |
|
|
|
|
applications |
|
|
|
|
charges |
|
|
|
|
isNameplateOnly |
|
|
|
|
isRaid |
|
|
|
|
maxCharges |
|
|
|
|
]] |
|
|
|
|
-- |
|
|
|
|
--print(unitAuraInfo.name, unitAuraInfo.sourceUnit, unitAuraInfo.expirationTime, unitAuraInfo.duration) |
|
|
|
|
self.aura = { |
|
|
|
|
auraInstanceID = unitAuraInfo.auraInstanceID, |
|
|
|
|
canApplyAura = unitAuraInfo.canApplyAura, |
|
|
|
|
castByPlayer = unitAuraInfo.isFromPlayerOrPlayerPet, |
|
|
|
|
count = unitAuraInfo.applications, |
|
|
|
|
dispelType = unitAuraInfo.dispelName or "", |
|
|
|
|
duration = unitAuraInfo.duration, |
|
|
|
|
expirationTime = unitAuraInfo.expirationTime, |
|
|
|
|
icon = unitAuraInfo.icon, |
|
|
|
|
isBossDebuff = unitAuraInfo.isBossAura, |
|
|
|
|
isStealable = unitAuraInfo.isStealable, |
|
|
|
|
name = unitAuraInfo.name, |
|
|
|
|
nameplateShowAll = unitAuraInfo.nameplateShowAll, |
|
|
|
|
nameplateShowPersonal = unitAuraInfo.nameplateShowPersonal, |
|
|
|
|
points = unitAuraInfo.points, |
|
|
|
|
source = unitAuraInfo.sourceUnit, |
|
|
|
|
spellId = unitAuraInfo.spellId, |
|
|
|
|
timeMod = unitAuraInfo.timeMod, |
|
|
|
|
|
|
|
|
|
index = nil, |
|
|
|
|
type = unitAuraInfo.isHarmful and "HARMFUL" or "HELPFUL", |
|
|
|
|
} |
|
|
|
|
function Aura:CreateFromUnitAuraInfo(unitAuraInfo, index, type) |
|
|
|
|
if unitAuraInfo then |
|
|
|
|
---@class Bastion.Aura |
|
|
|
|
self.aura = { |
|
|
|
|
name = unitAuraInfo.name, |
|
|
|
|
icon = unitAuraInfo.icon, |
|
|
|
|
count = unitAuraInfo.applications, |
|
|
|
|
dispelType = unitAuraInfo.dispelName, |
|
|
|
|
duration = unitAuraInfo.duration, |
|
|
|
|
expirationTime = unitAuraInfo.expirationTime, |
|
|
|
|
source = unitAuraInfo.sourceUnit, |
|
|
|
|
isStealable = unitAuraInfo.isStealable, |
|
|
|
|
nameplateShowPersonal = unitAuraInfo.nameplateShowPersonal, |
|
|
|
|
spellId = unitAuraInfo.spellId, |
|
|
|
|
canApplyAura = unitAuraInfo.canApplyAura, |
|
|
|
|
isBossDebuff = unitAuraInfo.isBossAura, |
|
|
|
|
castByPlayer = unitAuraInfo.isFromPlayerOrPlayerPet, |
|
|
|
|
nameplateShowAll = unitAuraInfo.nameplateShowAll, |
|
|
|
|
timeMod = unitAuraInfo.timeMod, |
|
|
|
|
auraInstanceID = unitAuraInfo.auraInstanceID, |
|
|
|
|
points = unitAuraInfo.points, |
|
|
|
|
index = index, |
|
|
|
|
type = type or unitAuraInfo.isHarmful and "HARMFUL" or "HELPFUL", |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
-- Register spell in spellbook |
|
|
|
|
Bastion.Globals.SpellBook:GetSpell(self.aura.spellId) |
|
|
|
|
return self |
|
|
|
|
-- Register spell in spellbook |
|
|
|
|
Bastion.Globals.SpellBook:GetSpell(self.aura.spellId) |
|
|
|
|
return self |
|
|
|
|
end |
|
|
|
|
return Aura:New() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Check if the aura is valid |
|
|
|
@ -400,4 +400,8 @@ function Aura:IsDispelableBySpell(spell) |
|
|
|
|
return false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function Aura:GetPoints() |
|
|
|
|
return self.aura.points |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Bastion.Aura = Aura |
|
|
|
|