|
|
|
@ -6,14 +6,58 @@ local Bastion = { |
|
|
|
|
} |
|
|
|
|
Bastion.__index = Bastion |
|
|
|
|
|
|
|
|
|
function Bastion:Require(file) |
|
|
|
|
-- If require starts with an @ then we require from the scripts/bastion/scripts folder |
|
|
|
|
if file:sub(1, 1) == '@' then |
|
|
|
|
file = file:sub(2) |
|
|
|
|
-- print('1') |
|
|
|
|
return require('scripts/bastion/scripts/' .. file, Bastion) |
|
|
|
|
elseif file:sub(1, 1) == "~" then |
|
|
|
|
file = file:sub(2) |
|
|
|
|
-- print("2") |
|
|
|
|
return require('scripts/bastion/' .. file, Bastion) |
|
|
|
|
else |
|
|
|
|
-- print("Normal req") |
|
|
|
|
return require(file, Bastion) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local function Load(dir) |
|
|
|
|
local dir = dir |
|
|
|
|
|
|
|
|
|
if dir:sub(1, 1) == '@' then |
|
|
|
|
dir = dir:sub(2) |
|
|
|
|
dir = 'scripts/bastion/scripts/' .. dir |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if dir:sub(1, 1) == '~' then |
|
|
|
|
dir = dir:sub(2) |
|
|
|
|
dir = 'scripts/bastion/' .. dir |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local files = ListFiles(dir) |
|
|
|
|
|
|
|
|
|
for i = 1, #files do |
|
|
|
|
local file = files[i] |
|
|
|
|
if file:sub(-4) == ".lua" or file:sub(-5) == '.luac' then |
|
|
|
|
return Bastion:Require(dir .. file:sub(1, -5)) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function Bastion.require(class) |
|
|
|
|
return require("scripts/bastion/src/" .. class .. "/" .. class, Bastion) |
|
|
|
|
-- return require("scripts/bastion/src/" .. class .. "/" .. class, Bastion) |
|
|
|
|
return Bastion:Require("~/src/" .. class .. "/" .. class) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Bastion.Globals = {} |
|
|
|
|
|
|
|
|
|
---@type ClassMagic |
|
|
|
|
Bastion.ClassMagic = Bastion.require("ClassMagic") |
|
|
|
|
---@type List |
|
|
|
|
Bastion.List = Bastion.require("List") |
|
|
|
|
---@type Library |
|
|
|
|
Bastion.Library = Bastion.require("Library") |
|
|
|
|
---@type NotificationsList, Notification |
|
|
|
|
Bastion.NotificationsList, Bastion.Notification = Bastion.require("NotificationsList") |
|
|
|
|
---@type Vector3 |
|
|
|
@ -41,15 +85,18 @@ Bastion.UnitManager = Bastion.require("UnitManager"):New() |
|
|
|
|
---@type ObjectManager |
|
|
|
|
Bastion.ObjectManager = Bastion.require("ObjectManager"):New() |
|
|
|
|
---@type EventManager |
|
|
|
|
Bastion.EventManager = Bastion.require("EventManager"):New() |
|
|
|
|
Bastion.EventManager = Bastion.require("EventManager") |
|
|
|
|
Bastion.Globals.EventManager = Bastion.EventManager:New() |
|
|
|
|
---@type Spell |
|
|
|
|
Bastion.Spell = Bastion.require("Spell") |
|
|
|
|
---@type SpellBook |
|
|
|
|
Bastion.SpellBook = Bastion.require("SpellBook"):New() |
|
|
|
|
Bastion.SpellBook = Bastion.require("SpellBook") |
|
|
|
|
Bastion.Globals.SpellBook = Bastion.SpellBook:New() |
|
|
|
|
---@type Item |
|
|
|
|
Bastion.Item = Bastion.require("Item") |
|
|
|
|
---@type ItemBook |
|
|
|
|
Bastion.ItemBook = Bastion.require("ItemBook"):New() |
|
|
|
|
Bastion.ItemBook = Bastion.require("ItemBook") |
|
|
|
|
Bastion.Globals.ItemBook = Bastion.ItemBook:New() |
|
|
|
|
---@type AuraTable |
|
|
|
|
Bastion.AuraTable = Bastion.require("AuraTable") |
|
|
|
|
---@type Class |
|
|
|
@ -62,11 +109,13 @@ Bastion.CombatTimer = Bastion.Timer:New('combat') |
|
|
|
|
Bastion.MythicPlusUtils = Bastion.require("MythicPlusUtils"):New() |
|
|
|
|
---@type NotificationsList |
|
|
|
|
Bastion.Notifications = Bastion.NotificationsList:New() |
|
|
|
|
|
|
|
|
|
local LIBRARIES = {} |
|
|
|
|
local MODULES = {} |
|
|
|
|
|
|
|
|
|
Bastion.Enabled = false |
|
|
|
|
|
|
|
|
|
Bastion.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras) |
|
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras) |
|
|
|
|
local u = Bastion.UnitManager[unit] |
|
|
|
|
|
|
|
|
|
if u then |
|
|
|
@ -74,10 +123,10 @@ Bastion.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras) |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
Bastion.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_SUCCEEDED", function(...) |
|
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_SUCCEEDED", function(...) |
|
|
|
|
local unit, castGUID, spellID = ... |
|
|
|
|
|
|
|
|
|
local spell = Bastion.SpellBook:GetIfRegistered(spellID) |
|
|
|
|
local spell = Bastion.Globals.SpellBook:GetIfRegistered(spellID) |
|
|
|
|
|
|
|
|
|
if unit == "player" and spell then |
|
|
|
|
spell.lastCastAt = GetTime() |
|
|
|
@ -90,7 +139,8 @@ end) |
|
|
|
|
|
|
|
|
|
local pguid = UnitGUID("player") |
|
|
|
|
local missed = {} |
|
|
|
|
Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() |
|
|
|
|
|
|
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() |
|
|
|
|
local args = {CombatLogGetCurrentEventInfo()} |
|
|
|
|
|
|
|
|
|
local subEvent = args[2] |
|
|
|
@ -134,15 +184,6 @@ Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
function Bastion:RegisterLibrary(name, payload) |
|
|
|
|
LIBRARIES[name] = payload |
|
|
|
|
-- Bastion:Print("Registered Library", name) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function Bastion:GetLibrary(name) |
|
|
|
|
return LIBRARIES[name] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Bastion.Ticker = C_Timer.NewTicker(0.1, function() |
|
|
|
|
if not Bastion.CombatTimer:IsRunning() and UnitAffectingCombat("player") then |
|
|
|
|
Bastion.CombatTimer:Start() |
|
|
|
@ -214,6 +255,7 @@ Command:Register('debug', 'Toggle debug mode on/off', function() |
|
|
|
|
Bastion:Print("Debug mode disabled") |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
Command:Register('dumpspells', 'Dump spells to a file', function() |
|
|
|
|
local i = 1 |
|
|
|
|
local rand = math.random(100000, 999999) |
|
|
|
@ -231,7 +273,7 @@ Command:Register('dumpspells', 'Dump spells to a file', function() |
|
|
|
|
if spellID then |
|
|
|
|
spellName = spellName:gsub("[%W%s]", "") |
|
|
|
|
WriteFile('bastion-' .. UnitClass('player') .. '-' .. rand .. '.lua', |
|
|
|
|
"local " .. spellName .. " = Bastion.SpellBook:GetSpell(" .. spellID .. ")", true) |
|
|
|
|
"local " .. spellName .. " = Bastion.Globals.SpellBook:GetSpell(" .. spellID .. ")\n", true) |
|
|
|
|
end |
|
|
|
|
i = i + 1 |
|
|
|
|
end |
|
|
|
@ -277,17 +319,79 @@ Command:Register('missed', 'Dump the list of immune kidney shot spells', functio |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
local function Load(dir) |
|
|
|
|
local files = ListFiles(dir) |
|
|
|
|
---@param library Library |
|
|
|
|
function Bastion:RegisterLibrary(library) |
|
|
|
|
LIBRARIES[library.name] = library |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
for i = 1, #files do |
|
|
|
|
local file = files[i] |
|
|
|
|
if file:sub(-4) == ".lua" or file:sub(-5) == '.luac' then |
|
|
|
|
require(dir .. file:sub(1, -5), Bastion) |
|
|
|
|
function Bastion:CheckLibraryDependencies() |
|
|
|
|
for k, v in pairs(LIBRARIES) do |
|
|
|
|
if v.dependencies then |
|
|
|
|
for i = 1, #v.dependencies do |
|
|
|
|
local dep = v.dependencies[i] |
|
|
|
|
if LIBRARIES[dep] then |
|
|
|
|
if LIBRARIES[dep].dependencies then |
|
|
|
|
for j = 1, #LIBRARIES[dep].dependencies do |
|
|
|
|
if LIBRARIES[dep].dependencies[j] == v.name then |
|
|
|
|
Bastion:Print("Circular dependency detected between " .. v.name .. " and " .. dep) |
|
|
|
|
return false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
else |
|
|
|
|
Bastion:Print("Library " .. v.name .. " depends on " .. dep .. " but it's not registered") |
|
|
|
|
return false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return true |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function Bastion:Import(library) |
|
|
|
|
local lib = self:GetLibrary(library) |
|
|
|
|
|
|
|
|
|
if not lib then |
|
|
|
|
error("Library " .. library .. " not found") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return lib:Resolve() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Load("scripts/bastion/scripts/Libraries/") |
|
|
|
|
Load("scripts/bastion/scripts/Modules/") |
|
|
|
|
Load("scripts/bastion/scripts/") |
|
|
|
|
function Bastion:GetLibrary(name) |
|
|
|
|
if not LIBRARIES[name] then |
|
|
|
|
error("Library " .. name .. " not found") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local library = LIBRARIES[name] |
|
|
|
|
|
|
|
|
|
-- if library.dependencies then |
|
|
|
|
-- for i = 1, #library.dependencies do |
|
|
|
|
-- local dep = library.dependencies[i] |
|
|
|
|
-- if LIBRARIES[dep] then |
|
|
|
|
-- if LIBRARIES[dep].dependencies then |
|
|
|
|
-- for j = 1, #LIBRARIES[dep].dependencies do |
|
|
|
|
-- if LIBRARIES[dep].dependencies[j] == library.name then |
|
|
|
|
-- Bastion:Print("Circular dependency detected between " .. library.name .. " and " .. dep) |
|
|
|
|
-- return false |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
-- else |
|
|
|
|
-- Bastion:Print("Library " .. v.name .. " depends on " .. dep .. " but it's not registered") |
|
|
|
|
-- return false |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
return library |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- if not Bastion:CheckLibraryDependencies() then |
|
|
|
|
-- return |
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
Load("@Libraries/") |
|
|
|
|
Load("@Modules/") |
|
|
|
|
Load("@") |
|
|
|
|