local LWSoundTimer = BaseClass("LWSoundTimer")
local Sound = CS.GameEntry.Sound

function LWSoundTimer:__init(assetName, soundLength)
  self.timerId = 0
  self.timer = {}
  self.assetName = ""
  self:CreateTimer(assetName, soundLength)
end

function LWSoundTimer:__delete()
  self.timerId = nil
  self.timer = nil
  self.assetName = nil
end

local LoopTimerAction = function(self)
  Sound:PlayEffect(self.assetName)
end

function LWSoundTimer:CreateTimer(assetName, soundLength)
  self.assetName = assetName
  self.timer = TimerManager:GetInstance():GetTimer(soundLength, LoopTimerAction, self, false, false, false)
  self.timerId = self.timer.timer_id
end

function LWSoundTimer:Resume()
  if self.timer then
    LoopTimerAction(self)
    self.timer:Resume()
  end
end

function LWSoundTimer:Pause()
  if self.timer then
    self.timer:Pause()
  end
end

function LWSoundTimer:Stop()
  if self.timer then
    self.timer:Stop()
  end
end

return LWSoundTimer
