Trigger:SetState now also takes doUpdate boolean
If the state the state does change and the trigger is active and doUpdate is true, then the indicator is updated with the given data.
This commit is contained in:
@@ -51,7 +51,7 @@ end
|
|||||||
--- Reset the AuraTrigger to the default state
|
--- Reset the AuraTrigger to the default state
|
||||||
function AuraTrigger:Reset()
|
function AuraTrigger:Reset()
|
||||||
self.count = 0
|
self.count = 0
|
||||||
self:SetState(self.count >= self.requiredCount)
|
self:SetState(self.count >= self.requiredCount, nil, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Check if a given aura matches this AuraTrigger
|
---Check if a given aura matches this AuraTrigger
|
||||||
@@ -73,7 +73,7 @@ function AuraTrigger:AddAura(aura)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.count = self.count + 1
|
self.count = self.count + 1
|
||||||
self:SetState(self.count >= self.requiredCount, {stacks=aura.applications})
|
self:SetState(self.count >= self.requiredCount, {stacks=aura.applications}, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Inform the trigger about an updated aura
|
---Inform the trigger about an updated aura
|
||||||
@@ -92,5 +92,5 @@ function AuraTrigger:RemoveAura(aura)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.count = self.count - 1
|
self.count = self.count - 1
|
||||||
self:SetState(self.count >= self.requiredCount)
|
self:SetState(self.count >= self.requiredCount, nil, false)
|
||||||
end
|
end
|
||||||
|
@@ -49,5 +49,5 @@ end
|
|||||||
-- status:
|
-- status:
|
||||||
-- Must be a valid UnitAuraInfo
|
-- Must be a valid UnitAuraInfo
|
||||||
function StatusTrigger:UpdateStatus(count)
|
function StatusTrigger:UpdateStatus(count)
|
||||||
self:SetState(count >= self.requiredCount)
|
self:SetState(count >= self.requiredCount, nil, false)
|
||||||
end
|
end
|
||||||
|
@@ -48,9 +48,8 @@ end
|
|||||||
---Set the state of the trigger. Will activate the indicator if needed.
|
---Set the state of the trigger. Will activate the indicator if needed.
|
||||||
---@param data table<string,any> | nil
|
---@param data table<string,any> | nil
|
||||||
---@param state boolean
|
---@param state boolean
|
||||||
function Trigger:SetState(state, data)
|
function Trigger:SetState(state, data, doUpdate)
|
||||||
state = state ~= self.invert -- state xor inverted
|
state = state ~= self.invert -- state xor inverted
|
||||||
|
|
||||||
if self.active ~= state then
|
if self.active ~= state then
|
||||||
if state then
|
if state then
|
||||||
self.indicator:Show(data)
|
self.indicator:Show(data)
|
||||||
@@ -58,12 +57,14 @@ function Trigger:SetState(state, data)
|
|||||||
self.indicator:Hide()
|
self.indicator:Hide()
|
||||||
end
|
end
|
||||||
self.active = state
|
self.active = state
|
||||||
|
elseif doUpdate and self.active then
|
||||||
|
self.indicator:Update(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Reset the trigger to the default state. If this changes the activation of the
|
-- Reset the trigger to the default state. If this changes the activation of the
|
||||||
-- trigger then the target will be notified.
|
-- trigger then the target will be notified.
|
||||||
function Trigger:Reset()
|
function Trigger:Reset()
|
||||||
self:SetState(false)
|
self:SetState(false, nil, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user