Move ivert logic and trigger logic into Trigger

The base Trigger class is now responsible for inverting the trigger
state and also for signaling trigger activation to the target/indicator.

In addition the following non-function changes also occured:
 - The triggers moved into their own directory
 - The trigger code has been annotated to help lua-language-server
   deduce type information
 - AuraTrigger was moved into its own file

All these changes should make future development of other triggers easier
This commit is contained in:
2023-04-04 06:40:29 +02:00
parent d85a1c3579
commit 8c4cc405aa
5 changed files with 173 additions and 158 deletions

View File

@@ -19,10 +19,13 @@ local types = omif.GetModule("types")
local StatusBar = types.StatusBar
local AuraList = types.AuraList
local SquareIndicator = types.SquareIndicator
---@class AuraTrigger
local AuraTrigger = types.AuraTrigger
types.UnitFrame = types.CreateClass("UnitFrame")
local UnitFrame = types.UnitFrame
---@class UnitFrame
local UnitFrame = types.CreateClass("UnitFrame")
types.UnitFrame = UnitFrame
local colors = {
@@ -83,19 +86,20 @@ function UnitFrame:CreateTriggers(triggers)
for _, trigger in ipairs(triggers) do
local kind = trigger.kind
if kind == "AuraTrigger" then
self.auras:AddTrigger(
AuraTrigger:new(
self:CreateIndicator(trigger.indicator),
local indicator = self:CreateIndicator(trigger.indicator)
local at = AuraTrigger:new(
trigger.spellId,
trigger.own,
trigger.requiredCount,
trigger.invert
)
)
at:SetTarget(indicator)
self.auras:AddTrigger(at)
end
end
end
function UnitFrame:CreateIndicator(indicator)
local kind = indicator.kind
if kind == "SquareIndicator" then