diff --git a/elements/castbar.lua b/elements/castbar.lua index 70171b12..9e8f1511 100644 --- a/elements/castbar.lua +++ b/elements/castbar.lua @@ -200,10 +200,22 @@ local function UpdatePips(element, numStages) end end -local function CastStart(self, event, unit) - if(self.unit ~= unit) then return end +--[[ Override: Castbar:ShouldShow(unit) +Handles check for which unit the castbar should show for. +Defaults to the object unit. + +* self - the Castbar widget +* unit - the unit for which the update has been triggered (string) +--]] +local function ShouldShow(element, unit) + return element.__owner.unit == unit +end +local function CastStart(self, event, unit) local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end local numStages, _ local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo(unit) @@ -300,9 +312,11 @@ local function CastStart(self, event, unit) end local function CastUpdate(self, event, unit, castID, spellID) - if(self.unit ~= unit) then return end - local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end + if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then return end @@ -357,9 +371,11 @@ local function CastUpdate(self, event, unit, castID, spellID) end local function CastStop(self, event, unit, castID, spellID) - if(self.unit ~= unit) then return end - local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end + if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then return end @@ -379,9 +395,11 @@ local function CastStop(self, event, unit, castID, spellID) end local function CastFail(self, event, unit, castID, spellID) - if(self.unit ~= unit) then return end - local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end + if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then return end @@ -410,9 +428,11 @@ local function CastFail(self, event, unit, castID, spellID) end local function CastInterruptible(self, event, unit) - if(self.unit ~= unit) then return end - local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end + if(not element:IsShown()) then return end element.notInterruptible = event == 'UNIT_SPELLCAST_NOT_INTERRUPTIBLE'