forked from wow/OmicronFrames
Add a new trigger type statustrigger
StatusTrigger will trigger if a status activates (or reaches a certain activation # of auras). This is an abstraction provided by AuraList which keeps track of which auras belong to which statuses. Added type annotations to all touched files
This commit is contained in:
1 parent
e55f139fca
commit
d66989297c
4 files changed
+116
-28
No files matched your search
@@ -0,0 +1,53 @@
|
||||
-- Copyright 2023 <omicron.me@protonmail.com>
|
||||
--
|
||||
-- This file is part of Omicron Frames
|
||||
--
|
||||
-- Omicron Frames is free software: you can redistribute it and/or modify it
|
||||
-- under the terms of the GNU General Public License as published by the Free
|
||||
-- Software Foundation, either version 3 of the License, or (at your option)
|
||||
-- any later version.
|
||||
--
|
||||
-- Omicron Frames is distributed in the hope that it will be useful, but
|
||||
-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
-- more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License along with
|
||||
-- Omicron Frames. If not, see <https://www.gnu.org/licenses/>.
|
||||
local omi = select(2, ...)
|
||||
local types = omi.GetModule("types")
|
||||
---@class Trigger
|
||||
local Trigger = types.Trigger
|
||||
|
||||
---StatusTrigger is a trigger that can be attached to AuraList as datasource
|
||||
---@class StatusTrigger: Trigger
|
||||
---@field status string
|
||||
local StatusTrigger = types.CreateClass("StatusTrigger", Trigger)
|
||||
types.StatusTrigger = StatusTrigger
|
||||
|
||||
---@return StatusTrigger
|
||||
function StatusTrigger.new(cls, ...)
|
||||
--- I really dislike duplicating this everywhere but it makes
|
||||
--lua-language-server able to deduce the type of Object:new calls and that
|
||||
--is honestly worth it
|
||||
return types.Object.new(cls, ...)
|
||||
end
|
||||
|
||||
--- Initialize a new AuraTrigger object
|
||||
---@param status string The kind of status to trigger on
|
||||
---@param requiredCount number | nil
|
||||
---@param invert boolean | nil
|
||||
function StatusTrigger:Init(status, requiredCount, invert)
|
||||
Trigger.Init(self, invert)
|
||||
self.status = status
|
||||
self.requiredCount = requiredCount or 1
|
||||
self.invert = invert or false
|
||||
self.active = invert
|
||||
end
|
||||
|
||||
--- Inform the trigger about a changed status
|
||||
-- status:
|
||||
-- Must be a valid UnitAuraInfo
|
||||
function StatusTrigger:UpdateStatus(count)
|
||||
self:SetState(count >= self.requiredCount)
|
||||
end
|
||||
Reference in new issue
Block a user