Bastion aims to serve as a highly performant, simplisitic, and expandable World of Warcraft data visualization framework.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bastion/src/ItemBook/ItemBook.lua

38 lines
899 B

---@type Tinkr, Bastion
local Tinkr, Bastion = ...
---@alias itemId integer
-- Create a new ItemBook class
---@class Bastion.ItemBook
---@field items table<itemId, Bastion.Item>
local ItemBook = {}
ItemBook.__index = ItemBook
-- Constructor
---@return Bastion.ItemBook
function ItemBook:New()
local self = setmetatable({}, ItemBook)
self.items = {}
---@param itemId itemId
---@param success boolean
Bastion.Globals.EventManager:RegisterEvent("ITEM_DATA_LOAD_RESULT", function(itemId, success)
if itemId and success and self.items[itemId] then
self.items[itemId]:Update()
end
end)
return self
end
-- Get a spell from the ItemBook
---@param id number
---@return Bastion.Item
function ItemBook:GetItem(id)
if self.items[id] == nil then
self.items[id] = Bastion.Item:New(id)
end
return self.items[id]
end
return ItemBook