---@type Tinkr local Tinkr, ---@class Bastion Bastion = ... -- Create a new Timer class ---@class Bastion.Timer ---@field type string ---@field cb? fun():boolean local Timer = { startTime = nil, resetAfterCombat = false, } Timer.__index = Timer -- Constructor ---@param type string ---@param cb? fun():boolean ---@return Bastion.Timer function Timer:New(type, cb) local self = setmetatable({}, Timer) self.startTime = nil self.type = type self.cb = cb return self end -- Start the timer ---@return nil function Timer:Start() self.startTime = GetTime() end -- Get the time since the timer was started ---@return number function Timer:GetTime() if not self:IsRunning() then return 0 end return GetTime() - self.startTime end -- Check if the timer is running ---@return boolean function Timer:IsRunning() return self.startTime ~= nil end -- Reset the timer ---@return nil function Timer:Reset() self.startTime = nil end function Timer:Check() if self.cb then if not self:IsRunning() and self.cb() then self:Start() elseif self:IsRunning() and not self.cb() then self:Reset() end end end Bastion.Timer = Timer