Refactor AgentTracker and related modules to improve agent management and logging
This commit is contained in:
17
Heimdall.lua
17
Heimdall.lua
@@ -18,7 +18,8 @@ local function init()
|
|||||||
---@field classColors table<string, string>
|
---@field classColors table<string, string>
|
||||||
---@field messenger HeimdallMessengerData
|
---@field messenger HeimdallMessengerData
|
||||||
---@field who HeimdallWhoData
|
---@field who HeimdallWhoData
|
||||||
---@field stinkyTracker HeimdallStinkyTrackerData
|
---@field stinkyTracker StinkyTrackerData
|
||||||
|
---@field agentTracker AgentTrackerData
|
||||||
---@field networkNodes string[]
|
---@field networkNodes string[]
|
||||||
---@field network HeimdallNetworkData
|
---@field network HeimdallNetworkData
|
||||||
---@field networkMessenger HeimdallNetworkMessengerData
|
---@field networkMessenger HeimdallNetworkMessengerData
|
||||||
@@ -26,7 +27,7 @@ local function init()
|
|||||||
---@field _L fun(key: string, locale: string): string
|
---@field _L fun(key: string, locale: string): string
|
||||||
---@field _Locale Localization
|
---@field _Locale Localization
|
||||||
---@field VERSION string
|
---@field VERSION string
|
||||||
---@field dumpTable fun(table: any, depth?: number): nil
|
---@field dumpTable fun(table: any, msg?: string, depth?: number): nil
|
||||||
---@field utf8len fun(input: string): number
|
---@field utf8len fun(input: string): number
|
||||||
---@field padString fun(input: string, targetLength: number, left?: boolean): string
|
---@field padString fun(input: string, targetLength: number, left?: boolean): string
|
||||||
---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any
|
---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any
|
||||||
@@ -42,7 +43,7 @@ local function init()
|
|||||||
---@field Inviter InitTable
|
---@field Inviter InitTable
|
||||||
---@field Dueler InitTable
|
---@field Dueler InitTable
|
||||||
---@field Bully InitTable
|
---@field Bully InitTable
|
||||||
---@field AgentTracker InitTable
|
---@field AgentTracker AgentTracker
|
||||||
---@field Emoter InitTable
|
---@field Emoter InitTable
|
||||||
---@field Echoer InitTable
|
---@field Echoer InitTable
|
||||||
---@field Macroer InitTable
|
---@field Macroer InitTable
|
||||||
@@ -279,16 +280,12 @@ local function init()
|
|||||||
---@field ticker Timer?
|
---@field ticker Timer?
|
||||||
|
|
||||||
---@class HeimdallWhoData
|
---@class HeimdallWhoData
|
||||||
---@field updateTicker number?
|
---@field updateTicker Timer?
|
||||||
---@field whoTicker number?
|
---@field whoTicker Timer?
|
||||||
---@field ignored table<string, boolean>
|
---@field ignored table<string, boolean>
|
||||||
|
|
||||||
---@class HeimdallStinkyTrackerData
|
|
||||||
---@field stinkies ReactiveValue<table<string, Stinky>>
|
|
||||||
---@field ignored ReactiveValue<table<string, number>>
|
|
||||||
|
|
||||||
---@class HeimdallNetworkData
|
---@class HeimdallNetworkData
|
||||||
---@field ticker number?
|
---@field ticker Timer?
|
||||||
|
|
||||||
---@class HeimdallStinkyCacheData
|
---@class HeimdallStinkyCacheData
|
||||||
---@field stinkies table<string, {value: number, timestamp: number}>
|
---@field stinkies table<string, {value: number, timestamp: number}>
|
||||||
|
|||||||
@@ -2,118 +2,136 @@ local _, shared = ...
|
|||||||
---@cast shared HeimdallShared
|
---@cast shared HeimdallShared
|
||||||
local ModuleName = "AgentTracker"
|
local ModuleName = "AgentTracker"
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@class AgentTracker
|
||||||
shared.AgentTracker = {}
|
---@field Init fun(): nil
|
||||||
function shared.AgentTracker.Init()
|
---@field Track fun(name: string): boolean
|
||||||
--/run Heimdall_Data.config.agents["Cyheuraeth"]=date("%Y-%m-%dT%H:%M:%S")
|
---@field IsAgent fun(name: string): boolean
|
||||||
---@type table<string, boolean>
|
---@field OnChange fun(callback: fun(name: string)): nil
|
||||||
local channelRosterFrame = CreateFrame("Frame")
|
---@field ForEach fun(callback: fun(name: string)): nil
|
||||||
channelRosterFrame:RegisterEvent("CHANNEL_ROSTER_UPDATE")
|
|
||||||
channelRosterFrame:SetScript("OnEvent", function(self, event, index)
|
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
|
||||||
print(string.format("[%s] Channel roster update received", ModuleName))
|
|
||||||
end
|
|
||||||
if not Heimdall_Data.config.agentTracker.enabled then
|
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
|
||||||
print(string.format("[%s] Module disabled, ignoring roster update", ModuleName))
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local name = GetChannelDisplayInfo(index)
|
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
|
||||||
print(string.format("[%s] Processing channel update: %s (index: %d)", ModuleName, name or "nil", index))
|
|
||||||
end
|
|
||||||
if name ~= Heimdall_Data.config.agentTracker.masterChannel then
|
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
|
||||||
print(string.format("[%s] Ignoring non-master channel: %s", ModuleName, name or "nil"))
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local count = select(5, GetChannelDisplayInfo(index))
|
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
|
||||||
print(string.format("[%s] Processing %d members in channel", ModuleName, count))
|
|
||||||
end
|
|
||||||
|
|
||||||
local newAgents = 0
|
---@class AgentTrackerData
|
||||||
for i = 1, count do
|
---@field agents ReactiveValue<table<string, string>>
|
||||||
name = GetChannelRosterInfo(index, i)
|
|
||||||
if name then
|
shared.agentTracker.agents = ReactiveValue(Heimdall_Data.config.agents)
|
||||||
local isNewAgent = not Heimdall_Data.config.agents[name]
|
|
||||||
Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S")
|
---@class AgentTracker
|
||||||
if isNewAgent then newAgents = newAgents + 1 end
|
shared.AgentTracker = {
|
||||||
|
Track = function(name)
|
||||||
|
if not name then return false end
|
||||||
|
local exists = shared.AgentTracker.IsAgent(name)
|
||||||
|
if exists then return false end
|
||||||
|
shared.agentTracker.agents[name] = date("%Y-%m-%dT%H:%M:%S")
|
||||||
|
-- Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S")
|
||||||
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
|
print(string.format("[%s] Tracking new agent: %s", ModuleName, name))
|
||||||
|
shared.dumpTable(shared.agentTracker.agents)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
IsAgent = function(name)
|
||||||
|
if not name then return false end
|
||||||
|
return shared.agentTracker.agents[name] ~= nil
|
||||||
|
end,
|
||||||
|
OnChange = function(callback) shared.agentTracker.agents:onChange(callback) end,
|
||||||
|
ForEach = function(callback)
|
||||||
|
---@type table<string, string>
|
||||||
|
local agents = shared.agentTracker.agents:get()
|
||||||
|
for name, _ in pairs(agents) do
|
||||||
|
callback(name)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
Init = function()
|
||||||
|
--/run Heimdall_Data.config.agents["Cyheuraeth"]=date("%Y-%m-%dT%H:%M:%S")
|
||||||
|
---@type table<string, boolean>
|
||||||
|
local channelRosterFrame = CreateFrame("Frame")
|
||||||
|
channelRosterFrame:RegisterEvent("CHANNEL_ROSTER_UPDATE")
|
||||||
|
channelRosterFrame:SetScript("OnEvent", function(self, event, index)
|
||||||
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
|
print(string.format("[%s] Channel roster update received", ModuleName))
|
||||||
|
end
|
||||||
|
if not Heimdall_Data.config.agentTracker.enabled then
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
print(
|
print(string.format("[%s] Module disabled, ignoring roster update", ModuleName))
|
||||||
string.format(
|
end
|
||||||
"[%s] %s agent: %s",
|
return
|
||||||
ModuleName,
|
end
|
||||||
isNewAgent and "Added new" or "Updated existing",
|
local name = GetChannelDisplayInfo(index)
|
||||||
name
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
)
|
print(string.format("[%s] Processing channel update: %s (index: %d)", ModuleName, name or "nil", index))
|
||||||
)
|
end
|
||||||
|
if name ~= Heimdall_Data.config.agentTracker.masterChannel then
|
||||||
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
|
print(string.format("[%s] Ignoring non-master channel: %s", ModuleName, name or "nil"))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local count = select(5, GetChannelDisplayInfo(index))
|
||||||
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
|
print(string.format("[%s] Processing %d members in channel", ModuleName, count))
|
||||||
|
end
|
||||||
|
|
||||||
|
local newAgents = 0
|
||||||
|
for i = 1, count do
|
||||||
|
name = GetChannelRosterInfo(index, i)
|
||||||
|
shared.AgentTracker.Track(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
|
print(string.format("[%s] Roster update complete - Added %d new agents", ModuleName, newAgents))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local agentTrackerChannelSniffer = CreateFrame("Frame")
|
||||||
|
agentTrackerChannelSniffer:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||||
|
agentTrackerChannelSniffer:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||||
|
-- if Heimdall_Data.config.agentTracker.debug then
|
||||||
|
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
|
||||||
|
-- end
|
||||||
|
if not Heimdall_Data.config.agentTracker.enabled then
|
||||||
|
-- if Heimdall_Data.config.agentTracker.debug then
|
||||||
|
-- print(string.format("[%s] Module disabled, ignoring channel message", ModuleName))
|
||||||
|
-- end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local channelId = select(6, ...)
|
||||||
|
local _, channelname = GetChannelName(channelId)
|
||||||
|
local ok = false
|
||||||
|
for _, channel in pairs(Heimdall_Data.config.agentTracker.channels) do
|
||||||
|
if channel == channelname then
|
||||||
|
ok = true
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
if not ok then
|
||||||
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
print(string.format("[%s] Channel name does not match any of the channels", ModuleName))
|
||||||
print(string.format("[%s] Roster update complete - Added %d new agents", ModuleName, newAgents))
|
end
|
||||||
end
|
return
|
||||||
end)
|
|
||||||
|
|
||||||
local agentTrackerChannelSniffer = CreateFrame("Frame")
|
|
||||||
agentTrackerChannelSniffer:RegisterEvent("CHAT_MSG_CHANNEL")
|
|
||||||
agentTrackerChannelSniffer:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
|
||||||
-- if Heimdall_Data.config.agentTracker.debug then
|
|
||||||
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
|
|
||||||
-- end
|
|
||||||
if not Heimdall_Data.config.agentTracker.enabled then
|
|
||||||
-- if Heimdall_Data.config.agentTracker.debug then
|
|
||||||
-- print(string.format("[%s] Module disabled, ignoring channel message", ModuleName))
|
|
||||||
-- end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local channelId = select(6, ...)
|
|
||||||
local _, channelname = GetChannelName(channelId)
|
|
||||||
local ok = false
|
|
||||||
for _, channel in pairs(Heimdall_Data.config.agentTracker.channels) do
|
|
||||||
if channel == channelname then
|
|
||||||
ok = true
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if not ok then
|
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
print(string.format("[%s] Channel name does not match any of the channels", ModuleName))
|
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
|
||||||
end
|
end
|
||||||
return
|
|
||||||
end
|
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
|
||||||
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
|
|
||||||
shared.dumpTable(Heimdall_Data.config.agentTracker)
|
|
||||||
end
|
|
||||||
|
|
||||||
sender = string.match(sender, "^[^-]+")
|
sender = string.match(sender, "^[^-]+")
|
||||||
local isNewAgent = not Heimdall_Data.config.agents[sender]
|
local new = shared.AgentTracker.Track(sender)
|
||||||
Heimdall_Data.config.agents[sender] = date("%Y-%m-%dT%H:%M:%S")
|
|
||||||
|
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
print(
|
print(
|
||||||
string.format(
|
string.format(
|
||||||
"[%s] %s agent from message: %s",
|
"[%s] %s agent from message: %s",
|
||||||
ModuleName,
|
ModuleName,
|
||||||
isNewAgent and "Added new" or "Updated existing",
|
new and "Added new" or "Updated existing",
|
||||||
sender
|
sender
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
end
|
||||||
end
|
end)
|
||||||
end)
|
|
||||||
|
|
||||||
if Heimdall_Data.config.agentTracker.debug then
|
if Heimdall_Data.config.agentTracker.debug then
|
||||||
local count = 0
|
print(string.format("[%s] Module initialized", ModuleName))
|
||||||
for _ in pairs(Heimdall_Data.config.agents) do
|
shared.dumpTable(shared.agentTracker.agents:get(), "Agents")
|
||||||
count = count + 1
|
|
||||||
end
|
end
|
||||||
print(string.format("[%s] Module initialized - Tracking %d agents", ModuleName, count))
|
print("[Heimdall] AgentTracker loaded")
|
||||||
end
|
end,
|
||||||
print("[Heimdall] AgentTracker loaded")
|
}
|
||||||
end
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function shared.Dueler.Init()
|
|||||||
print(string.format("[%s] Checking if sender '%s' is in agents list", ModuleName, sender))
|
print(string.format("[%s] Checking if sender '%s' is in agents list", ModuleName, sender))
|
||||||
end
|
end
|
||||||
|
|
||||||
local allow = Heimdall_Data.config.agents[sender]
|
local allow = shared.AgentTracker.IsAgent(sender)
|
||||||
if allow then
|
if allow then
|
||||||
if Heimdall_Data.config.dueler.debug then
|
if Heimdall_Data.config.dueler.debug then
|
||||||
print(string.format("[%s] Accepting duel from trusted agent: %s", ModuleName, sender))
|
print(string.format("[%s] Accepting duel from trusted agent: %s", ModuleName, sender))
|
||||||
|
|||||||
@@ -35,29 +35,25 @@ function shared.Inviter.Init()
|
|||||||
|
|
||||||
if Heimdall_Data.config.inviter.agentsAssist then
|
if Heimdall_Data.config.inviter.agentsAssist then
|
||||||
if Heimdall_Data.config.inviter.debug then
|
if Heimdall_Data.config.inviter.debug then
|
||||||
local agentCount = 0
|
print(string.format("[%s] Processing agents for assistant promotion", ModuleName))
|
||||||
for _ in pairs(Heimdall_Data.config.agents) do
|
|
||||||
agentCount = agentCount + 1
|
|
||||||
end
|
|
||||||
print(string.format("[%s] Processing %d agents for assistant promotion", ModuleName, agentCount))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, _ in pairs(Heimdall_Data.config.agents) do
|
shared.AgentTracker.ForEach(function(agent)
|
||||||
if UnitInParty(name) and not UnitIsGroupLeader(name) and not UnitIsRaidOfficer(name) then
|
if UnitInParty(agent) and not UnitIsGroupLeader(agent) and not UnitIsRaidOfficer(agent) then
|
||||||
if Heimdall_Data.config.inviter.debug then
|
if Heimdall_Data.config.inviter.debug then
|
||||||
print(string.format("[%s] Promoting agent to assistant: %s", ModuleName, name))
|
print(string.format("[%s] Promoting agent to assistant: %s", ModuleName, agent))
|
||||||
end
|
end
|
||||||
PromoteToAssistant(name, true)
|
PromoteToAssistant(agent, true)
|
||||||
elseif Heimdall_Data.config.inviter.debug then
|
elseif Heimdall_Data.config.inviter.debug then
|
||||||
if not UnitInParty(name) then
|
if not UnitInParty(agent) then
|
||||||
print(string.format("[%s] Agent not in party: %s", ModuleName, name))
|
print(string.format("[%s] Agent not in party: %s", ModuleName, agent))
|
||||||
elseif UnitIsGroupLeader(name) then
|
elseif UnitIsGroupLeader(agent) then
|
||||||
print(string.format("[%s] Agent is already leader: %s", ModuleName, name))
|
print(string.format("[%s] Agent is already leader: %s", ModuleName, agent))
|
||||||
elseif UnitIsRaidOfficer(name) then
|
elseif UnitIsRaidOfficer(agent) then
|
||||||
print(string.format("[%s] Agent is already assistant: %s", ModuleName, name))
|
print(string.format("[%s] Agent is already assistant: %s", ModuleName, agent))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Heimdall_Data.config.inviter.debug then
|
if Heimdall_Data.config.inviter.debug then
|
||||||
|
|||||||
@@ -5,12 +5,6 @@ local ModuleName = "Macroer"
|
|||||||
---@diagnostic disable-next-line: missing-fields
|
---@diagnostic disable-next-line: missing-fields
|
||||||
shared.Macroer = {}
|
shared.Macroer = {}
|
||||||
function shared.Macroer.Init()
|
function shared.Macroer.Init()
|
||||||
---@class stinky
|
|
||||||
---@field name string
|
|
||||||
---@field class string
|
|
||||||
---@field seenAt number
|
|
||||||
---@field hostile boolean
|
|
||||||
|
|
||||||
local function FindOrCreateMacro(macroName)
|
local function FindOrCreateMacro(macroName)
|
||||||
if Heimdall_Data.config.macroer.debug then
|
if Heimdall_Data.config.macroer.debug then
|
||||||
print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName))
|
print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName))
|
||||||
@@ -27,7 +21,7 @@ function shared.Macroer.Init()
|
|||||||
return idx
|
return idx
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param stinkies table<string, stinky>
|
---@param stinkies table<string, Stinky>
|
||||||
local function FixMacro(stinkies)
|
local function FixMacro(stinkies)
|
||||||
if Heimdall_Data.config.macroer.debug then
|
if Heimdall_Data.config.macroer.debug then
|
||||||
print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies))
|
print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies))
|
||||||
@@ -53,7 +47,7 @@ function shared.Macroer.Init()
|
|||||||
|
|
||||||
local sortedStinkies = {}
|
local sortedStinkies = {}
|
||||||
for _, stinky in pairs(stinkies) do
|
for _, stinky in pairs(stinkies) do
|
||||||
if not Heimdall_Data.config.agents[stinky.name] then sortedStinkies[#sortedStinkies + 1] = stinky end
|
if not shared.AgentTracker.IsAgent(stinky.name) then sortedStinkies[#sortedStinkies + 1] = stinky end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Heimdall_Data.config.macroer.debug then
|
if Heimdall_Data.config.macroer.debug then
|
||||||
@@ -89,12 +83,12 @@ function shared.Macroer.Init()
|
|||||||
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
|
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
|
||||||
end
|
end
|
||||||
|
|
||||||
shared.stinkyTracker.stinkies:onChange(function(value)
|
shared.StinkyTracker.OnChange(function(stinkies)
|
||||||
if Heimdall_Data.config.macroer.debug then
|
if Heimdall_Data.config.macroer.debug then
|
||||||
print(string.format("[%s] Stinkies changed, updating macro", ModuleName))
|
print(string.format("[%s] Stinkies changed, updating macro", ModuleName))
|
||||||
shared.dumpTable(value)
|
shared.dumpTable(stinkies)
|
||||||
end
|
end
|
||||||
FixMacro(value)
|
FixMacro(stinkies)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ function shared.Spotter.Init()
|
|||||||
print(string.format("[%s] Checking notification criteria for %s (%s)", ModuleName, name, faction))
|
print(string.format("[%s] Checking notification criteria for %s (%s)", ModuleName, name, faction))
|
||||||
end
|
end
|
||||||
|
|
||||||
if Heimdall_Data.config.agents[name] then
|
if shared.AgentTracker.IsAgent(name) then
|
||||||
if Heimdall_Data.config.spotter.debug then
|
if Heimdall_Data.config.spotter.debug then
|
||||||
print(string.format("[%s] Skipping agent: %s", ModuleName, name))
|
print(string.format("[%s] Skipping agent: %s", ModuleName, name))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,13 +2,16 @@ local _, shared = ...
|
|||||||
---@cast shared HeimdallShared
|
---@cast shared HeimdallShared
|
||||||
local ModuleName = "StinkyTracker"
|
local ModuleName = "StinkyTracker"
|
||||||
|
|
||||||
|
|
||||||
---@class Stinky
|
---@class Stinky
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field class string
|
---@field class string
|
||||||
---@field seenAt number
|
---@field seenAt number
|
||||||
---@field hostile boolean
|
---@field hostile boolean
|
||||||
|
|
||||||
|
---@class StinkyTrackerData
|
||||||
|
---@field stinkies ReactiveValue<table<string, Stinky>>
|
||||||
|
---@field ignored ReactiveValue<table<string, number>>
|
||||||
|
|
||||||
---@class StinkyTracker
|
---@class StinkyTracker
|
||||||
shared.StinkyTracker = {
|
shared.StinkyTracker = {
|
||||||
---@param stinky Stinky
|
---@param stinky Stinky
|
||||||
@@ -68,6 +71,20 @@ shared.StinkyTracker = {
|
|||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
---@param callback fun(stinkies: table<string, Stinky>)
|
||||||
|
---@return nil
|
||||||
|
OnChange = function(callback) shared.stinkyTracker.stinkies:onChange(callback) end,
|
||||||
|
|
||||||
|
---@param callback fun(name: string, stinky: Stinky)
|
||||||
|
---@return nil
|
||||||
|
ForEach = function(callback)
|
||||||
|
---@type table<string, Stinky>
|
||||||
|
local stinkies = shared.stinkyTracker.stinkies:get()
|
||||||
|
for name, stinky in pairs(stinkies) do
|
||||||
|
callback(name, stinky)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
Init = function()
|
Init = function()
|
||||||
shared.stinkyTracker = {
|
shared.stinkyTracker = {
|
||||||
stinkies = ReactiveValue.new({}),
|
stinkies = ReactiveValue.new({}),
|
||||||
@@ -273,7 +290,7 @@ shared.StinkyTracker = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
for name, stinky in pairs(shared.stinkyTracker.stinkies) do
|
for name, stinky in pairs(shared.stinkyTracker.stinkies) do
|
||||||
if Heimdall_Data.config.agents[name] then
|
if shared.AgentTracker.IsAgent(name) then
|
||||||
shared.stinkyTracker.stinkies[name] = nil
|
shared.stinkyTracker.stinkies[name] = nil
|
||||||
if Heimdall_Data.config.stinkyTracker.debug then
|
if Heimdall_Data.config.stinkyTracker.debug then
|
||||||
print(string.format("[%s] Removed agent from stinkies: %s", ModuleName, name))
|
print(string.format("[%s] Removed agent from stinkies: %s", ModuleName, name))
|
||||||
|
|||||||
Reference in New Issue
Block a user