-- LocKitchen

LocKitchen = Location:new("LocKitchen")

----------------------------------------------------------------------------------------------------
function LocKitchen_UPDATE()
    return 0
end

----------------------------------------------------------------------------------------------------
function LocKitchen_INIT()
    LocKitchen:init()
end

----------------------------------------------------------------------------------------------------
LocKitchen:setSceneHandler(1,
    function(aScene, aEvent)
    
        if aEvent == "capture" then
            aScene:captureObjects({'wet_rag', 'rag', 'bucket', 'clips', 'pancakes'})
        elseif aEvent == "generic_init" then
            
            
            aScene:setWinTerms({"ho_collected", "activate_traces"})

        elseif aEvent == "start" then

            aScene:addItemMix('wet_rag', {'rag', 'bucket'})

            aScene:setHidsParams({"clips"}, {active = false})
            aScene:setHidsParams({"pancakes"}, {visible = false, active = false})
            
            aScene:setRemark('ids_remark_lockitchen_1') 
            aScene:setTask("ids_challenge_kitchen_1")

            aScene:attachHids(aScene:getHidList({except = {'wet_rag'}}))
            aScene:attachInteract("box1")
            aScene:attachInteract("cover2")

        elseif aEvent == "found_wet_rag" then
            aScene:attachInteract("traces", "wet_rag")

        elseif aEvent == "activate_box1" then
            aScene:setHidsParams({"pancakes"}, {visible = true, active = true})

        elseif aEvent == "activate_cover2" then
            aScene:setHidsParams({"clips"}, {active = true})

        elseif aEvent == "activate_traces" then
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")
        end
    end)

----------------------------------------------------------------------------------------------------
LocKitchen:setSceneHandler(2,
    function(aScene, aEvent)
        if aEvent == "capture" then
             aScene:captureObjects({'ice_kitchen', 'tray_with_water', 'bowling_ball'})
        elseif aEvent == "generic_init" then
           
            aScene:setWinTerms({'ho_collected', 'activate_crane'})
            aScene:setHidsParams({'ice_kitchen', 'tray_with_water'}, {visible = false, active = false})
            aScene:setHidsParams({'icetray', 'tray_with_water'}, {inventory = true})
            

        elseif aEvent == "start" then
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract('crane', 'icetray')
            aScene:setTask("ids_challenge_kitchen_2")
            aScene:setRemark('ids_remark_lockitchen_2') 

        elseif aEvent == "activate_crane" then
            aScene:setHidsParams({'tray_with_water'}, {visible = true, active = true})
            aScene:attachInteract('refregerator', 'tray_with_water')
            ho:click('hid_2_tray_with_water')

        elseif aEvent == "activate_refregerator" then
            aScene:setHidsParams({'ice_kitchen'}, {visible = true, active = true})
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")
            ho:click('hid_2_ice_kitchen')

        end
    end)

----------------------------------------------------------------------------------------------------
LocKitchen:setSceneHandler(3,
    function(aScene, aEvent)
        if aEvent == "capture" then
             aScene:captureObjects({'matches', 'melon'})
        elseif aEvent == "generic_init" then
            aScene:captureObjects({'matches', 'melon'})
            aScene:setWinTerms({'ho_collected', 'activate_saucepan'})
            aScene:setHidsParams({'matches'}, {inventory = true})
            

        elseif aEvent == "start" then
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract('saucepan', 'matches')
            aScene:setRemark('ids_remark_lockitchen_3')
            aScene:setTask("ids_challenge_kitchen_3")

        elseif aEvent == "activate_click_saucepan" then
            aScene:setExtraParams('saucepan', {play = true})
            aScene:setExtraParams('fire', {play = true, loop = true})
            aScene:setExtraParams('black_smoke', {play = true, loop = true})

        elseif aEvent == "activate_saucepan" then
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        end
    end)

----------------------------------------------------------------------------------------------------
LocKitchen:setSceneHandler(4,
    function (aScene, aEvent)

        -- strawberry show,activate(-> box2)
        -- oil -> shelf => sausage,chest activate(-> door2)

        if aEvent == "capture" then
             aScene:captureObjects({'strawberry'})
        elseif aEvent == "generic_init" then
            
            aScene:setWinTerms({"ho_collected", "activate_shelf"})
            aScene:setHidsParams({"sausage", "chest"}, {active = false})
            aScene:setHidsParams({"strawberry"}, {visible = false, active = false})
            aScene:setHidsParams({"oil"}, {inventory = true})
            

        elseif aEvent == "start" then
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract('box2')
            aScene:attachInteract('shelf', 'oil')
            aScene:setRemark('ids_remark_lockitchen_4')
            aScene:setTask("ids_challenge_kitchen_4")

        elseif aEvent == "activate_box2" then
            aScene:setHidsParams({"strawberry"}, {visible = true, active = true})

        elseif aEvent == "activate_shelf" then
            aScene:attachInteract('door2')
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        elseif aEvent == "activate_door2" then
            aScene:setHidsParams({"sausage", "chest"}, {active = true})

        end
    end)

----------------------------------------------------------------------------------------------------
LocKitchen:setSceneHandler(5,
    function(aScene, aEvent)
        if aEvent == "generic_init" then
            
            aScene:setHidsParams({"screwdriver"}, {inventory = true})
            aScene:setHidsParams({"gears"}, {active = false})
            aScene:setWinTerms({"ho_collected", "activate_door1"})

        elseif aEvent == "start" then
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract("door1", "screwdriver")
            aScene:setRemark('ids_remark_lockitchen_5')
            aScene:setTask("ids_challenge_lockitchen_5")

        elseif aEvent == "activate_door1" then
            aScene:setHidsParams({"gears"}, {active = true})
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")
        end
    end)

