|
|
|
@ -4,6 +4,7 @@ local Tinkr = ... |
|
|
|
|
---@class Bastion |
|
|
|
|
local Bastion = { |
|
|
|
|
DebugMode = false, |
|
|
|
|
Globals = {}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
local TinkrScriptsBase = "scripts" |
|
|
|
@ -59,7 +60,7 @@ end |
|
|
|
|
--- 0 = Failed, 1 = Success, 2 = Already Loaded |
|
|
|
|
---@param filePath string | { filePath: string, reloadable: boolean } |
|
|
|
|
---@param ... any |
|
|
|
|
---@return 0|1|2, ... |
|
|
|
|
---@return 0|1|2, table |
|
|
|
|
function Bastion:Require(filePath, ...) |
|
|
|
|
local loadedFile = { |
|
|
|
|
originalPath = type(filePath) == "table" and filePath.filePath or tostring(filePath), |
|
|
|
@ -70,19 +71,12 @@ function Bastion:Require(filePath, ...) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
local filePathModifier = loadedFile.originalPath:sub(1, 1) |
|
|
|
|
|
|
|
|
|
if filePathModifier == "@" then |
|
|
|
|
-- If require starts with an @ then we require from the scripts/bastion/scripts folder |
|
|
|
|
loadedFile.newPath = string.format("%s%s", BastionScriptsBase, loadedFile.originalPath:sub(2)) |
|
|
|
|
loadedFile.loadedPath = loadedFile.newPath |
|
|
|
|
elseif filePathModifier == "~" then |
|
|
|
|
-- If file path starts with a ~ then we require from the scripts/bastion folder |
|
|
|
|
loadedFile.newPath = string.format("%s%s", BastionBase, loadedFile.originalPath:sub(2)) |
|
|
|
|
local base = filePathModifier == "@" and BastionScriptsBase or filePathModifier == "~" and BastionBase |
|
|
|
|
if base then |
|
|
|
|
loadedFile.newPath = string.format("%s%s", base, loadedFile.originalPath:sub(2)) |
|
|
|
|
loadedFile.loadedPath = loadedFile.newPath |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
loadedFile.loadedPath = loadedFile.newPath |
|
|
|
|
|
|
|
|
|
local found = false |
|
|
|
|
-- Check if file path has a .lua or .luac extension. If not, try to add one and check if the file exists |
|
|
|
|
loadedFile.loadedPath, found = CheckFileExtensions(loadedFile.newPath, { "lua", "luac" }) |
|
|
|
@ -152,57 +146,46 @@ local function LoadThird() |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
---@generic V : string |
|
|
|
|
---@param class `V` |
|
|
|
|
---@return V ... |
|
|
|
|
function Bastion.require(class) |
|
|
|
|
---@cast class string |
|
|
|
|
local newClass = class:gsub("Bastion%.", "") |
|
|
|
|
-- return require("scripts/bastion/src/" .. class .. "/" .. class, Bastion) |
|
|
|
|
local success, result = Bastion:Require("~/src/" .. newClass .. "/" .. newClass) |
|
|
|
|
if success == 0 then |
|
|
|
|
Log("Bastion.require - Failed to load " .. class .. ": " .. result) |
|
|
|
|
end |
|
|
|
|
return SafeUnpack(result) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Bastion.Globals = {} |
|
|
|
|
|
|
|
|
|
Bastion.ClassMagic = Bastion.require("Bastion.ClassMagic") |
|
|
|
|
Bastion.List = Bastion.require("Bastion.List") |
|
|
|
|
Bastion.Library = Bastion.require("Bastion.Library") |
|
|
|
|
Bastion.Notification = Bastion.require("Bastion.Notification") |
|
|
|
|
Bastion.NotificationList = Bastion.require("Bastion.NotificationList") |
|
|
|
|
Bastion.Vector3 = Bastion.require("Bastion.Vector3") |
|
|
|
|
Bastion.Sequencer = Bastion.require("Bastion.Sequencer") |
|
|
|
|
Bastion.Command = Bastion.require("Bastion.Command") |
|
|
|
|
Bastion.Cache = Bastion.require("Bastion.Cache") |
|
|
|
|
Bastion.Cacheable = Bastion.require("Bastion.Cacheable") |
|
|
|
|
Bastion.Refreshable = Bastion.require("Bastion.Refreshable") |
|
|
|
|
Bastion.Unit = Bastion.require("Bastion.Unit") |
|
|
|
|
Bastion.Aura = Bastion.require("Bastion.Aura") |
|
|
|
|
Bastion.APLTrait = Bastion.require("Bastion.APLTrait") |
|
|
|
|
Bastion.APLActor = Bastion.require("Bastion.APLActor") |
|
|
|
|
Bastion.APL = Bastion.require("Bastion.APL") |
|
|
|
|
Bastion.Module = Bastion.require("Bastion.Module") |
|
|
|
|
Bastion.UnitManager = Bastion.require("Bastion.UnitManager"):New() |
|
|
|
|
Bastion.ObjectManager = Bastion.require("Bastion.ObjectManager"):New() |
|
|
|
|
Bastion.EventManager = Bastion.require("Bastion.EventManager") |
|
|
|
|
Bastion.Globals.EventManager = Bastion.EventManager:New() |
|
|
|
|
Bastion.Spell = Bastion.require("Bastion.Spell") |
|
|
|
|
Bastion.SpellBook = Bastion.require("Bastion.SpellBook") |
|
|
|
|
Bastion.Globals.SpellBook = Bastion.SpellBook:New() |
|
|
|
|
Bastion.Item = Bastion.require("Bastion.Item") |
|
|
|
|
Bastion.ItemBook = Bastion.require("Bastion.ItemBook") |
|
|
|
|
Bastion.Globals.ItemBook = Bastion.ItemBook:New() |
|
|
|
|
Bastion.AuraTable = Bastion.require("Bastion.AuraTable") |
|
|
|
|
Bastion.Class = Bastion.require("Bastion.Class") |
|
|
|
|
Bastion.Timer = Bastion.require("Bastion.Timer") |
|
|
|
|
Bastion.CombatTimer = Bastion.Timer:New("combat") |
|
|
|
|
Bastion.MythicPlusUtils = Bastion.require("Bastion.MythicPlusUtils"):New() |
|
|
|
|
Bastion.Notifications = Bastion.NotificationList:New() |
|
|
|
|
Bastion.Config = Bastion.require("Bastion.Config") |
|
|
|
|
Bastion.TimeToDie = Bastion.require("Bastion.TimeToDie") |
|
|
|
|
local bastionFiles = { |
|
|
|
|
"~/src/ClassMagic/ClassMagic", |
|
|
|
|
"~/src/List/List", |
|
|
|
|
"~/src/Util/Util", |
|
|
|
|
"~/src/Library/Library", |
|
|
|
|
"~/src/Notification/Notification", |
|
|
|
|
"~/src/NotificationList/NotificationList", |
|
|
|
|
"~/src/Vector3/Vector3", |
|
|
|
|
"~/src/Sequencer/Sequencer", |
|
|
|
|
"~/src/Command/Command", |
|
|
|
|
"~/src/Cache/Cache", |
|
|
|
|
"~/src/Cacheable/Cacheable", |
|
|
|
|
"~/src/Refreshable/Refreshable", |
|
|
|
|
"~/src/Unit/Unit", |
|
|
|
|
"~/src/Aura/Aura", |
|
|
|
|
"~/src/APLTrait/APLTrait", |
|
|
|
|
"~/src/APLActor/APLActor", |
|
|
|
|
"~/src/APL/APL", |
|
|
|
|
"~/src/Module/Module", |
|
|
|
|
"~/src/UnitManager/UnitManager", |
|
|
|
|
"~/src/ObjectManager/ObjectManager", |
|
|
|
|
"~/src/EventManager/EventManager", |
|
|
|
|
"~/src/Spell/Spell", |
|
|
|
|
"~/src/SpellBook/SpellBook", |
|
|
|
|
"~/src/Item/Item", |
|
|
|
|
"~/src/ItemBook/ItemBook", |
|
|
|
|
"~/src/AuraTable/AuraTable", |
|
|
|
|
"~/src/Class/Class", |
|
|
|
|
"~/src/Timer/Timer", |
|
|
|
|
"~/src/MythicPlusUtils/MythicPlusUtils", |
|
|
|
|
"~/src/Config/Config", |
|
|
|
|
"~/src/TimeToDie/TimeToDie", |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for i = 1, #bastionFiles do |
|
|
|
|
Bastion:Require(bastionFiles[i]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Bastion.Globals.CombatTimer = Bastion.Timer:New("combat") |
|
|
|
|
Bastion.Globals.Notifications = Bastion.NotificationList:New() |
|
|
|
|
|
|
|
|
|
---@param unitTarget UnitId |
|
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("UNIT_HEALTH", function(unitTarget) |
|
|
|
@ -210,27 +193,6 @@ Bastion.Globals.EventManager:RegisterWoWEvent("UNIT_HEALTH", function(unitTarget |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@enum (key) CompareThisTable |
|
|
|
|
local compareThisTable = { |
|
|
|
|
[">"] = function(A, B) return A > B end, |
|
|
|
|
["<"] = function(A, B) return A < B end, |
|
|
|
|
[">="] = function(A, B) return A >= B end, |
|
|
|
|
["<="] = function(A, B) return A <= B end, |
|
|
|
|
["=="] = function(A, B) return A == B end, |
|
|
|
|
["min"] = function(A, B) return A < B end, |
|
|
|
|
["max"] = function(A, B) return A > B end, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Bastion.Utils = { |
|
|
|
|
---@generic A |
|
|
|
|
---@param operator CompareThisTable |
|
|
|
|
---@param a A |
|
|
|
|
---@param b A |
|
|
|
|
CompareThis = function(operator, a, b) |
|
|
|
|
return compareThisTable[operator](a, b) |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
---@type table<string, Bastion.Library> |
|
|
|
|
local LIBRARIES = {} |
|
|
|
|
|
|
|
|
@ -290,17 +252,6 @@ Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", fun |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- if sourceGUID == pguid then |
|
|
|
|
-- local args = { CombatLogGetCurrentEventInfo() } |
|
|
|
|
|
|
|
|
|
-- for i = 1, #args do |
|
|
|
|
-- Log(tostring(args[i])) |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
--Bastion.UnitManager:SetCombatTime(sourceGUID) |
|
|
|
|
--Bastion.UnitManager:SetCombatTime(destGUID) |
|
|
|
|
|
|
|
|
|
local u = Bastion.UnitManager[sourceGUID] |
|
|
|
|
local u2 = Bastion.UnitManager[destGUID] |
|
|
|
|
|
|
|
|
@ -339,10 +290,10 @@ Bastion.Ticker = C_Timer.NewTicker(0.1, function() |
|
|
|
|
Bastion.Now = GetTime() |
|
|
|
|
Bastion.Tick = GetGameTick() |
|
|
|
|
|
|
|
|
|
if not Bastion.CombatTimer:IsRunning() and UnitAffectingCombat("player") then |
|
|
|
|
Bastion.CombatTimer:Start() |
|
|
|
|
elseif Bastion.CombatTimer:IsRunning() and not UnitAffectingCombat("player") then |
|
|
|
|
Bastion.CombatTimer:Reset() |
|
|
|
|
if not Bastion.Globals.CombatTimer:IsRunning() and UnitAffectingCombat("player") then |
|
|
|
|
Bastion.Globals.CombatTimer:Start() |
|
|
|
|
elseif Bastion.Globals.CombatTimer:IsRunning() and not UnitAffectingCombat("player") then |
|
|
|
|
Bastion.Globals.CombatTimer:Reset() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if Bastion.Enabled then |
|
|
|
|