require "TimedActions/ISBaseTimedAction"

---@class ISFapAction : ISBaseTimedAction
ISFapAction = ISBaseTimedAction:derive("ISFapAction")

function ISFapAction:isValid()
  return true
end

function ISFapAction:update()
    if not (self.character:getEmitter():isPlaying("VoiceMaleExercise") or self.character:getEmitter():isPlaying("VoiceFemaleExercise")) then
            local sound = self.sound[2] end
    self.character:setMetabolicTarget(Metabolics.HeavyWork);
end

function ISFapAction:start()
   if not self.character:isFemale() then
    self.sound = {self.character:playSoundLocal("EatingMushy"),self.character:playSoundLocal("VoiceMaleExercise"),"HeadSmash","VoiceMalePainFromBite"}
    self:setOverrideHandModels("Base.PaperNapkins_Ground","Base.Salami_Ground")
    self:setActionAnim("SliceFood")
   else
    self.sound = {self.character:playSoundLocal("WashClothing"),self.character:playSoundLocal("VoiceFemaleExercise"),"HeadSmash","VoiceFemalePainFromBite"}
    self:setOverrideHandModels("Base.fapcumber","Base.MacAndCheese")
    self:setActionAnim("MixingBucket")
   end
   self.character:getEmitter():setVolume(self.sound[1],.33)
   self.character:getEmitter():setVolume(self.sound[2],1.5)
end

function ISFapAction:stop()
    
    self.character:getEmitter():stopOrTriggerSound(self.sound[1])
    self.character:getEmitter():stopOrTriggerSound(self.sound[2])

    ISBaseTimedAction.stop(self)
end

function ISFapAction:perform()
    self.character:getEmitter():stopOrTriggerSound(self.sound[1])
    self.character:getEmitter():stopOrTriggerSound(self.sound[2])
    local sound = self.character:playSoundLocal(self.sound[3])
    self.character:getEmitter():setVolume(sound,.33)
    self.character:playSoundLocal(self.sound[4])
    
    ISBaseTimedAction.perform(self)
end

function ISFapAction:new(character,location,time,item)
    local o = ISBaseTimedAction.new(self, character)
    o.character = character
    o.location = location
    o.stopOnWalk = true
    o.stopOnRun = true
    o.maxTime = time
    o.item = item
  --  o.spriteFrame = 0
 --   o.caloriesModifier = 2
    if o.character:isTimedActionInstant() then o.maxTime = 1 end
    return o
end