-- adds options to the right click menu for growing body hair; only for testing purposes and active when playing in debug mode
--
--
-- by razab



local manageBody = require("ManageBody/RasBodyModManageBodyIG")
local changePenis = require("ManageBody/RasBodyModManageMovement")


-- changing the equipped penis model:
local function onChangeModel(worldobjects, player)

     local modData = player:getModData()
     local data = modData.RasBodyMod

     data.PlayerMode = "CrouchWall"
     changePenis.testStuff(player)

    print("Equip New pressed")

end

local function onDefaultModel(worldobjects, player)

     local modData = player:getModData()
     local data = modData.RasBodyMod

     data.PlayerMode = "Default"
     changePenis.testStuff(player)

     print("Equip Default pressed")
end



-- when body hair has been changed:
local function onGrowArmpits(worldobjects, player)

     local modData = player:getModData()
     local data = modData.RasBodyMod

     if data.ArmpitHair < 2 then
           data.ArmpitHair = data.ArmpitHair + 1

           manageBody.EquipSkin(player, true)
           triggerEvent("OnClothingUpdated", player)
     end
end


local function onGrowChest(worldobjects, player)

     local modData = player:getModData()
     local data = modData.RasBodyMod

     if data.ChestHair  < 2 then
          data.ChestHair = data.ChestHair + 1

          manageBody.EquipSkin(player, true)
          triggerEvent("OnClothingUpdated", player)
     end
end



local function onGrowPubic(worldobjects, player)

        local modData = player:getModData()
        local data = modData.RasBodyMod

        if player:isFemale() then
              if data.PubicHair < 5 then
                   if data.PubicHair == 0 then -- if no pubic hair
                         data.PubicHair = 1
                   elseif data.PubicHair == 1 or data.PubicHair == 2 then -- if pubic hair is on intermediate state
                         data.PubicHair = 5
                   elseif data.PubicHair == 3 or data.PubicHair == 4 then -- if strip or trimmed
                         data.PubicHair = 2
                   end 

                   manageBody.EquipSkin(player, true)
                   triggerEvent("OnClothingUpdated", player)
              end
        else
             if data.PubicHair < 4 then
                   hasChanged = true
                   if data.PubicHair == 0 then -- if no pubic hair
                        data.PubicHair = 1
                   elseif data.PubicHair == 1 or data.PubicHair == 2 then -- if pubic hair is on intermediate state
                        data.PubicHair = 4
                   elseif data.PubicHair == 3 then -- if strip 
                        data.PubicHair = 2
                   end  

                   manageBody.EquipSkin(player, true)
                   triggerEvent("OnClothingUpdated", player)        
             end
        end
end


local function onGrowLegs(worldobjects, player)

      local modData = player:getModData()
      local data = modData.RasBodyMod

      if data.LegHair < 2 then
             data.LegHair = data.LegHair + 1

             manageBody.EquipSkin(player, true)
             triggerEvent("OnClothingUpdated", player)
      end
end




-- add new options to the right click menu
local vanilla_ISWorldObjectContextMenu_createMenu = ISWorldObjectContextMenu.createMenu
function ISWorldObjectContextMenu.createMenu(player, worldobjects, x, y, test, ...)

      local context = vanilla_ISWorldObjectContextMenu_createMenu(player, worldobjects, x, y, test, ...) -- execute vanilla code
      if test == true then return true; end

      if isDebugEnabled() then
           
          local playerObj = getSpecificPlayer(player)

          if not playerObj:isFemale() then
             context:addOption("RasBodyMod_EquipNewPenis", worldobjects, onChangeModel, playerObj)
             context:addOption("RasBodyMod_EquipOldPenis", worldobjects, onDefaultModel, playerObj)
          end


          context:addOption("RasBodyMod_GrowArmpits", worldobjects, onGrowArmpits, playerObj)
          if not playerObj:isFemale() then
             context:addOption("RasBodyMod_GrowChest", worldobjects, onGrowChest, playerObj)
          end
          context:addOption("RasBodyMod_GrowPubic", worldobjects, onGrowPubic, playerObj)
          context:addOption("RasBodyMod_GrowLegs", worldobjects, onGrowLegs, playerObj)
      end

      return context
end





