forked from Bastion/Bastion
parent
82af0e2e38
commit
1786febbb2
@ -1,50 +0,0 @@ |
||||
local Tinkr, _Bastion = ... |
||||
|
||||
---@type Bastion |
||||
local Bastion = _Bastion |
||||
|
||||
-- Create a new Queue class |
||||
---@class Queue |
||||
local Queue = { |
||||
---@type table<number, { spell: number, unit: Unit }> |
||||
queued = {} |
||||
} |
||||
Queue.__index = Queue |
||||
|
||||
-- Constructor |
||||
---@return Queue |
||||
function Queue:New() |
||||
local self = setmetatable({}, Queue) |
||||
self.queued = {} |
||||
return self |
||||
end |
||||
|
||||
-- Add an spell to the queue |
||||
---@param id number |
||||
---@param unit "mouseover"|"target"|"player" |
||||
---@return boolean |
||||
function Queue:Add(id, unit) |
||||
local isUsable = IsSpellKnown(id) |
||||
|
||||
if not isUsable then |
||||
return false |
||||
end |
||||
|
||||
local _unit = nil |
||||
|
||||
if unit == 'mouseover' then |
||||
_unit = Bastion.UnitManager:Get('mouseover') |
||||
elseif unit == 'target' then |
||||
_unit = Bastion.UnitManager:Get('target') |
||||
else |
||||
_unit = Bastion.UnitManager:Get('player') |
||||
end |
||||
|
||||
if not _unit == nil and self.queued[id] == nil then |
||||
self.queued[id]['spell'] = id |
||||
self.queued[id]['unit'] = _unit |
||||
return true |
||||
end |
||||
|
||||
return false |
||||
end |
Loading…
Reference in new issue