diff --git a/elements/castbar.lua b/elements/castbar.lua index 70171b12..f6c64e5c 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,7 +312,10 @@ 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 local element = self.Castbar if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then @@ -357,7 +372,10 @@ 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 local element = self.Castbar if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then @@ -379,7 +397,10 @@ 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 local element = self.Castbar if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then @@ -410,7 +431,10 @@ 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 local element = self.Castbar if(not element:IsShown()) then return end