Repository navigation
Expand file tree
/
Copy pathCore.lua
More file actions
770 lines (656 loc) · 25 KB
/
Copy pathCore.lua
File metadata and controls
770 lines (656 loc) · 25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
-- HealIQ Core.lua
-- Main addon initialization, event registration, and saved variables management
--
-- This module handles:
-- * Addon initialization and database setup
-- * Event registration and handling
-- * Session statistics tracking
-- * Error handling and logging
-- * Version upgrade management
-- * Player class/spec validation
-- Use robust global access pattern that works with new Init system
local HealIQ = _G.HealIQ
-- Ensure HealIQ is available (Init.lua should have created it)
if not HealIQ then
error("HealIQ Core.lua: Init system not loaded - check TOC loading order")
end
-- Ensure version is set for packaging validation
HealIQ.version = "0.3.0"
-- Best Practice: Prepare for LibStub integration (optional library support)
HealIQ.LibStub = _G.LibStub -- Will be nil if LibStub not available, won't break anything
-- Ace3 Integration - Modern addon framework
local LibStub = _G.LibStub
if LibStub then
-- Try to load Ace3 libraries (optional - addon works without them)
local AceAddon = LibStub("AceAddon-3.0", true)
local AceDB = LibStub("AceDB-3.0", true)
local AceConfig = LibStub("AceConfig-3.0", true)
local AceConfigDialog = LibStub("AceConfigDialog-3.0", true)
if AceAddon then
HealIQ.AceAddon = AceAddon:NewAddon("HealIQ", "AceEvent-3.0", "AceConsole-3.0")
HealIQ.ace = HealIQ.AceAddon -- Alias for easier access
end
HealIQ.AceDB = AceDB
HealIQ.AceConfig = AceConfig
HealIQ.AceConfigDialog = AceConfigDialog
end
-- Best Practice: Enhanced addon metadata for better debugging
HealIQ.addonName = HealIQ.addonName or "HealIQ"
HealIQ.buildInfo = {
tocVersion = "120007",
author = "djdefi",
category = "Healing",
license = "MIT",
website = "https://github.com/djdefi/healiq"
}
-- Default settings with profile support
local defaults = {
-- Global account settings
global = {
profiles = {},
currentProfile = "Default"
},
-- Profile-specific settings (this is the Default profile)
profile = {
enabled = true,
debug = false, -- Debug mode setting
specialization = "auto", -- auto, restoration, guardian, feral, balance
ui = {
scale = 1.0,
x = 0,
y = 0,
locked = false,
showIcon = true,
showSpellName = true,
showCooldown = true,
showQueue = true,
showTargeting = true, -- Show targeting suggestions
showTargetingIcon = true, -- Show targeting icon overlay
queueSize = 3,
queueLayout = "horizontal", -- horizontal or vertical
queueSpacing = 8,
queueScale = 0.75, -- Scale of queue icons relative to main icon
minimapX = 10,
minimapY = -10,
minimapAngle = -math.pi/4, -- Default angle for minimap positioning
showPositionBorder = false, -- Show frame positioning border
},
rules = {
-- Existing rules
wildGrowth = true,
clearcasting = true,
lifebloom = true,
swiftmend = true,
rejuvenation = true,
-- Enhanced rules
ironbark = true,
efflorescence = true,
tranquility = true,
incarnationTree = true,
naturesSwiftness = true,
barkskin = true,
flourish = true,
-- New spells from strategy review
wrath = true,
},
strategy = {
-- Healing strategy settings based on Wowhead guide
prioritizeEfflorescence = true, -- Keep Efflorescence active frequently
maintainLifebloomOnTank = true, -- Always keep Lifebloom on tank
lifebloomRefreshWindow = 4.5, -- Refresh Lifebloom in last 4.5s for bloom
preferClearcastingRegrowth = true, -- Prioritize Regrowth with Clearcasting
swiftmendWildGrowthCombo = true, -- Link Swiftmend and Wild Growth usage
rejuvenationRampThreshold = 15, -- Start ramping Rejuv when damage expected in 15s
avoidRandomRejuvenationDowntime = true, -- Don't cast random Rejuvs during downtime
useWrathForMana = true, -- Fill downtime with Wrath for mana
emergencyNaturesSwiftness = true, -- Use Nature's Swiftness for emergency heals
-- Tunable thresholds
wildGrowthMinTargets = 1, -- Minimum targets damaged to suggest Wild Growth (solo-friendly)
tranquilityMinTargets = 4, -- Minimum targets damaged to suggest Tranquility
efflorescenceMinTargets = 2, -- Minimum targets damaged to suggest Efflorescence
flourishMinHots = 2, -- Minimum expiring HoTs to suggest Flourish
recentDamageWindow = 3, -- Time window to consider "recent damage" (seconds)
lowHealthThreshold = 0.3, -- Health percentage to consider "emergency"
suggestTankRelationships = true, -- Suggest establishing tank support relationships
}
}
}
-- Initialize saved variables with intelligent defaults merging and profile support
-- This function ensures database integrity and handles corruption gracefully
-- @return void
function HealIQ:InitializeDB()
-- Ensure HealIQDB exists
if not HealIQDB then
HealIQDB = {}
end
-- Validate HealIQDB structure and handle corruption
if type(HealIQDB) ~= "table" then
HealIQDB = {}
self:Message("HealIQ database was corrupted (type: " .. type(HealIQDB) .. "), resetting to defaults", true)
end
-- Initialize profile system with AceDB if available, fallback to manual implementation
if self.AceDB then
self.db = self.AceDB:New("HealIQDB", defaults, true)
self:Print("Profile system initialized using AceDB")
else
-- Manual profile implementation
self:InitializeProfileSystem()
self:Print("Profile system initialized using fallback implementation")
end
-- Check for version upgrade and migrate settings if needed
local currentVersion = self.db and self.db.global and self.db.global.version or HealIQDB.version
if currentVersion ~= self.version then
self:OnVersionUpgrade(currentVersion, self.version)
if self.db and self.db.global then
self.db.global.version = self.version
else
HealIQDB.version = self.version
end
end
-- Restore debug state from current profile
local profileData = self:GetCurrentProfile()
if profileData and profileData.debug ~= nil then
self.debug = profileData.debug
end
self:Print("Database initialized with " .. self:CountSettings() .. " settings")
end
-- Manual profile system implementation (fallback when AceDB not available)
function HealIQ:InitializeProfileSystem()
-- Ensure global structure exists
if not HealIQDB.global then
HealIQDB.global = {
profiles = {
Default = {}
},
currentProfile = "Default"
}
end
-- Ensure profiles table exists
if not HealIQDB.global.profiles then
HealIQDB.global.profiles = {
Default = {}
}
end
-- Ensure current profile exists
local currentProfile = HealIQDB.global.currentProfile or "Default"
if not HealIQDB.global.profiles[currentProfile] then
HealIQDB.global.profiles[currentProfile] = {}
end
-- Merge defaults into current profile
local profileData = HealIQDB.global.profiles[currentProfile]
self:MergeDefaults(profileData, defaults.profile)
-- Create db interface that mimics AceDB structure
self.db = {
global = HealIQDB.global,
profile = profileData,
-- Profile management methods
GetCurrentProfile = function() return currentProfile end,
SetProfile = function(name) self:SetProfile(name) end,
GetProfiles = function() return HealIQDB.global.profiles end
}
end
-- Merge defaults into existing data
function HealIQ:MergeDefaults(target, defaultValues)
for key, value in pairs(defaultValues) do
if target[key] == nil then
if type(value) == "table" then
target[key] = {}
self:MergeDefaults(target[key], value)
else
target[key] = value
end
elseif type(value) == "table" and type(target[key]) == "table" then
self:MergeDefaults(target[key], value)
end
end
end
-- Profile Management System
function HealIQ:GetCurrentProfile()
if self.db and self.db.profile then
return self.db.profile
end
return nil
end
function HealIQ:SetProfile(profileName)
if not HealIQDB.global or not HealIQDB.global.profiles then
self:Print("Profile system not initialized")
return false
end
if not HealIQDB.global.profiles[profileName] then
-- Create new profile from defaults
HealIQDB.global.profiles[profileName] = {}
self:MergeDefaults(HealIQDB.global.profiles[profileName], defaults.profile)
self:Print("Created new profile: " .. profileName)
end
HealIQDB.global.currentProfile = profileName
-- Reinitialize db interface
if not self.AceDB then
self:InitializeProfileSystem()
else
self.db = self.AceDB:New("HealIQDB", defaults, true)
end
self:Print("Switched to profile: " .. profileName)
return true
end
function HealIQ:GetProfiles()
if HealIQDB.global and HealIQDB.global.profiles then
local profiles = {}
for name in pairs(HealIQDB.global.profiles) do
table.insert(profiles, name)
end
return profiles
end
return {"Default"}
end
function HealIQ:DeleteProfile(profileName)
if profileName == "Default" then
self:Print("Cannot delete Default profile")
return false
end
if not HealIQDB.global or not HealIQDB.global.profiles then
self:Print("Profile system not initialized")
return false
end
if not HealIQDB.global.profiles[profileName] then
self:Print("Profile not found: " .. profileName)
return false
end
-- If deleting current profile, switch to Default
if HealIQDB.global.currentProfile == profileName then
self:SetProfile("Default")
end
HealIQDB.global.profiles[profileName] = nil
self:Print("Deleted profile: " .. profileName)
return true
end
function HealIQ:ExportProfile(profileName)
profileName = profileName or HealIQDB.global.currentProfile
if not HealIQDB.global or not HealIQDB.global.profiles[profileName] then
self:Print("Profile not found: " .. profileName)
return nil
end
local profileData = HealIQDB.global.profiles[profileName]
local exportData = {
version = self.version,
profile = profileName,
data = profileData,
timestamp = time()
}
-- Convert to string representation for sharing
local exportString = self:SerializeTable(exportData)
self:Print("Profile exported: " .. profileName)
return exportString
end
function HealIQ:ImportProfile(importString, newProfileName)
local importData = self:DeserializeTable(importString)
if not importData or not importData.data then
self:Print("Invalid profile import data")
return false
end
newProfileName = newProfileName or importData.profile or "Imported"
-- Create profile
if not HealIQDB.global.profiles then
HealIQDB.global.profiles = {}
end
HealIQDB.global.profiles[newProfileName] = importData.data
self:Print("Profile imported: " .. newProfileName)
return true
end
-- Specialization Detection System
function HealIQ:DetectSpecialization()
-- Check if WoW API is available
if not GetSpecialization then
return "unknown"
end
local specIndex = GetSpecialization()
if not specIndex then
return "unknown"
end
-- Druid specializations:
-- 1 = Balance, 2 = Feral, 3 = Guardian, 4 = Restoration
local specNames = {
[1] = "balance",
[2] = "feral",
[3] = "guardian",
[4] = "restoration"
}
return specNames[specIndex] or "unknown"
end
function HealIQ:GetActiveSpecialization()
local profileData = self:GetCurrentProfile()
if not profileData then
return "restoration" -- Safe default
end
if profileData.specialization == "auto" then
return self:DetectSpecialization()
else
return profileData.specialization
end
end
function HealIQ:OnSpecializationChanged()
local newSpec = self:DetectSpecialization()
local profileData = self:GetCurrentProfile()
if profileData and profileData.specialization == "auto" then
self:Print("Specialization changed to: " .. newSpec)
-- Update rules based on specialization
if self.Engine then
self.Engine:UpdateRulesForSpecialization(newSpec)
end
-- Update UI visibility if needed
if newSpec == "restoration" then
if self.UI and profileData.enabled then
self.UI:SetEnabled(true)
end
else
-- For non-resto specs, consider hiding UI or showing different suggestions
if self.UI then
self.UI:SetEnabled(false)
end
end
end
end
-- Serialization helpers for profile import/export
function HealIQ:SerializeTable(tbl)
-- Simple table serialization for configuration data
local function serialize(obj, level)
level = level or 0
if level > 10 then return "..." end -- Prevent infinite recursion
if type(obj) == "table" then
local result = "{"
local first = true
for k, v in pairs(obj) do
if not first then result = result .. "," end
first = false
result = result .. "["
if type(k) == "string" then
result = result .. '"' .. k:gsub('"', '\\"') .. '"'
else
result = result .. tostring(k)
end
result = result .. "]=" .. serialize(v, level + 1)
end
return result .. "}"
elseif type(obj) == "string" then
return '"' .. obj:gsub('"', '\\"') .. '"'
else
return tostring(obj)
end
end
return serialize(tbl)
end
function HealIQ:DeserializeTable(str)
-- Simple deserialization (security note: only use with trusted data)
if not str or str == "" then
return nil
end
local success, result = pcall(loadstring("return " .. str))
if success and type(result) == "table" then
return result
end
return nil
end
-- Handle version upgrades
function HealIQ:OnVersionUpgrade(oldVersion, newVersion)
if oldVersion then
self:Message("HealIQ upgraded from v" .. oldVersion .. " to v" .. newVersion)
else
self:Message("HealIQ v" .. newVersion .. " - First time installation")
end
end
-- Count settings for diagnostics
function HealIQ:CountSettings()
local count = 0
local function countTable(t)
local c = 0
for k, v in pairs(t) do
c = c + 1
if type(v) == "table" then
c = c + countTable(v)
end
end
return c
end
if self.db then
count = countTable(self.db)
end
return count
end
-- Initialize session statistics
function HealIQ:InitializeSessionStats()
self.sessionStats = {
startTime = time(),
suggestions = 0,
rulesProcessed = 0,
errorsLogged = 0,
eventsHandled = 0,
}
end
-- Debug print function
function HealIQ:Print(message)
if self.debug then
print("|cFF00FF00HealIQ:|r " .. tostring(message))
end
end
function HealIQ:FormatDuration(seconds)
local hours = math.floor(seconds / 3600)
local minutes = math.floor((seconds % 3600) / 60)
local secs = seconds % 60
if hours > 0 then
return string.format("%dh %dm %ds", hours, minutes, secs)
elseif minutes > 0 then
return string.format("%dm %ds", minutes, secs)
else
return string.format("%ds", secs)
end
end
-- Enhanced error handling wrapper with comprehensive logging
-- Safely executes functions with detailed error reporting and debugging
-- @param func The function to execute safely
-- @param ... Arguments to pass to the function
-- @return success (boolean), result (any) - success status and function result
function HealIQ:SafeCall(func, ...)
local success, result = pcall(func, ...)
if not success then
local errorMsg = tostring(result)
print("|cFFFF0000HealIQ Error:|r " .. errorMsg)
self:LogError("SafeCall Error: " .. errorMsg)
-- Enhanced debugging information when debug mode is enabled
if self.debug then
print("|cFFFF0000Stack trace:|r " .. debugstack())
self:DebugLog("Stack trace: " .. debugstack(), "ERROR")
end
-- Report to WoW's error system for copyable errors
-- This ensures errors appear in the default error frame for user reporting
if self.debug then
-- Construct a complete error message with context and stack trace
local completeError = "HealIQ SafeCall Error: " .. errorMsg .. "\n" .. debugstack()
geterrorhandler()(completeError)
end
return false, result
end
return true, result
end
-- User message function
function HealIQ:Message(message, isError)
-- Ensure message is converted to string, handle any type safely
local msgStr
if type(message) == "table" then
-- If it's a table, try to get a meaningful representation
msgStr = "(table error: " .. tostring(message) .. ")"
-- Try to extract error details if available
if self.debug and message.message and type(message.message) == "string" then
msgStr = msgStr .. " - " .. message.message
end
elseif message == nil then
msgStr = "(nil message)"
else
msgStr = tostring(message)
end
local prefix = isError and "|cFFFF0000HealIQ Error:|r " or "|cFF00FF00HealIQ:|r "
print(prefix .. msgStr)
end
-- Main addon initialization
-- Register Core module with the initialization system
local function initializeCore()
HealIQ:InitializeDB()
HealIQ:Message("HealIQ " .. HealIQ.version .. " loaded")
-- Initialize session statistics
if HealIQ.Logging then
HealIQ.Logging:InitializeVariables()
end
HealIQ:InitializeSessionStats()
-- Register for specialization change events
if HealIQ.ace then
-- Use Ace3 event system if available
HealIQ.ace:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED", function()
HealIQ:OnSpecializationChanged()
end)
else
-- Fallback to direct WoW event registration
local frame = CreateFrame("Frame", "HealIQSpecFrame")
frame:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
frame:SetScript("OnEvent", function()
HealIQ:OnSpecializationChanged()
end)
end
-- Note: Performance and Validation modules register themselves
-- via the Init system in their respective files with Core as a dependency.
-- Register Tracker and Engine modules (they don't self-register)
if HealIQ.InitRegistry then
HealIQ.InitRegistry:RegisterComponent("Tracker", function()
if HealIQ.Tracker and HealIQ.Tracker.Initialize then
HealIQ.Tracker:Initialize()
HealIQ:DebugLog("Tracker module initialized")
end
end, {"Core"})
HealIQ.InitRegistry:RegisterComponent("Engine", function()
if HealIQ.Engine and HealIQ.Engine.Initialize then
HealIQ.Engine:Initialize()
HealIQ:DebugLog("Engine module initialized")
end
end, {"Core"})
end
-- UI and Config modules are initialized via ADDON_LOADED event
-- to ensure WoW UI system is fully ready
HealIQ:Message("HealIQ Core " .. HealIQ.version .. " initialized successfully")
HealIQ:DebugLog("HealIQ Core initialization completed successfully", "INFO")
end
-- Register with initialization system
if HealIQ.InitRegistry then
HealIQ.InitRegistry:RegisterComponent("Core", initializeCore, {})
else
-- Fallback if Init.lua didn't load properly
HealIQ:DebugLog("Init system not available, using fallback initialization", "WARN")
HealIQ:SafeCall(initializeCore)
end
-- Event handling for game events (not initialization events)
function HealIQ:OnEvent(event, ...)
local args = {...} -- Capture varargs for use in SafeCall
self:SafeCall(function()
if self.sessionStats then
self.sessionStats.eventsHandled = self.sessionStats.eventsHandled + 1
end
self:DebugLog("Event received: " .. event)
if event == "ADDON_LOADED" then
self:OnAddonLoaded(args[1]) -- args[1] is addonName
elseif event == "PLAYER_LOGIN" then
self:OnPlayerLogin()
elseif event == "PLAYER_ENTERING_WORLD" then
self:OnPlayerEnteringWorld()
end
end)
end
function HealIQ:OnAddonLoaded(addonName)
self:SafeCall(function()
-- Only handle our own addon loaded event
if addonName ~= "HealIQ" then
return
end
self:DebugLog("HealIQ addon loaded, initializing slash commands and UI", "INFO")
-- Now it's safe to initialize Config module (slash commands)
if self.Config and self.Config.Initialize then
self.Config:Initialize()
self:DebugLog("Config module initialized on ADDON_LOADED", "INFO")
end
-- Initialize UI after WoW UI system is ready
if self.UI and self.UI.Initialize then
self.UI:Initialize()
self:DebugLog("UI module initialized on ADDON_LOADED", "INFO")
end
end)
end
function HealIQ:OnPlayerLogin()
self:SafeCall(function()
self:Print("Player logged in")
self:DebugLog("Player logged in", "INFO")
end)
end
-- Validate player class and spec, enable/disable addon accordingly
-- Only enables for Restoration Druids to ensure relevant suggestions
-- @return void
function HealIQ:OnPlayerEnteringWorld()
self:SafeCall(function()
self:Print("Player entering world")
self:DebugLog("Player entering world", "INFO")
if not self.db then
self:DebugLog("Database not yet initialized during OnPlayerEnteringWorld", "WARN")
return
end
-- Check if player is a Restoration Druid
local _, class = UnitClass("player")
if class == "DRUID" then
local specIndex = GetSpecialization()
if specIndex == 4 then -- Restoration spec (index 4 for druids)
self:Print("Restoration Druid detected")
self:DebugLog("Restoration Druid detected - enabling addon", "INFO")
self.db.enabled = true
self:Message("HealIQ enabled for Restoration Druid")
else
self:Print("Not Restoration spec, addon disabled")
self:DebugLog("Not Restoration spec (spec: " .. (specIndex or "unknown") .. ") - disabling addon", "INFO")
self.db.enabled = false
self:Message("HealIQ disabled (not Restoration spec)")
end
else
self:Print("Not a Druid, addon disabled")
self:DebugLog("Not a Druid (class: " .. (class or "unknown") .. ") - disabling addon", "INFO")
self.db.enabled = false
self:Message("HealIQ disabled (not a Druid)")
end
end)
end
-- Create event frame for game events (not initialization events)
local function setupEventHandling()
if not CreateFrame then
HealIQ:DebugLog("CreateFrame not available, deferring event setup", "WARN")
return
end
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("ADDON_LOADED")
eventFrame:RegisterEvent("PLAYER_LOGIN")
eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
eventFrame:SetScript("OnEvent", function(self, event, ...)
HealIQ:OnEvent(event, ...)
end)
HealIQ:DebugLog("Event handling setup complete", "INFO")
end
-- Register event setup as a component
if HealIQ.InitRegistry then
HealIQ.InitRegistry:RegisterComponent("EventHandling", setupEventHandling, {"Core"})
else
HealIQ:SafeCall(setupEventHandling)
end
-- HealIQ is already globally accessible via Init.lua
-- Cleanup function for addon disable/reload
function HealIQ:Cleanup()
self:SafeCall(function()
if self.UI then
self.UI:Hide()
end
if self.Engine then
-- Stop update loop
self.Engine:StopUpdateLoop()
end
self:Print("HealIQ cleanup completed")
end)
end