-- LocValetParking

LocValetParking = Location:new("LocValetParking")

----------------------------------------------------------------------------------------------------
function LocValetParking_UPDATE()
	return 0
end

----------------------------------------------------------------------------------------------------
function LocValetParking_INIT()
    LocValetParking:init()
end

----------------------------------------------------------------------------------------------------
LocValetParking:setSceneHandler(1,
    function(aScene, aEvent)
        if aEvent == "capture" then
             aScene:captureObjects({'flashlight'})
        elseif aEvent == "generic_init" then
            
            aScene:setHidsParams({"green_rag"}, {inventory = true})
            aScene:setWinTerms({"ho_collected", "activate_window"})
            aScene:setHidsParams({"flashlight"}, {active = false})
            aScene:setInteractParams("window", {visible = false})
            aScene:activateCloseUp('LocValetParkingCloseUp', false)

        elseif aEvent == "start" then
            aScene:setExtraParams("lasers", {play = true, loop = true})
            aScene:setInteractParams("window", {visible = true})
            aScene:setExtraParams("door", {visible = false})
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract("window", "green_rag")
            aScene:setTask("ids_challenge_locvaletparking_1")
            aScene:setRemark('ids_remark_locvaletparking_1')

        elseif aEvent == "activate_window" then
            aScene:setHidsParams({"flashlight"}, {active = true})
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        end
    end)

----------------------------------------------------------------------------------------------------
LocValetParking:setSceneHandler(2,
    function(aScene, aEvent)
        if aEvent == "capture" then
            aScene:captureObjects({'lighter'})
        elseif aEvent == "generic_init" then
            
            aScene:setWinTerms({"ho_collected", "activate_firealarm"})
            aScene:setHidsParams({"lighter"}, {inventory = true})

        elseif aEvent == "start" then
            aScene:attachHids(aScene:getHidList({except = {'antenna'}}))
            aScene:attachHids({'antenna'})
            aScene:attachInteract("firealarm", "lighter")
            aScene:setTask("ids_challenge_locvaletparking_2")
            aScene:setRemark('ids_remark_locvaletparking_2') 

        elseif aEvent == "activate_firealarm" then
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")
            aScene.mDisplay:link_effect("FireAlarm02", "fireAlarm1")
            aScene.mDisplay:link_effect("FireAlarm02", "fireAlarm2")
            aScene.mDisplay:link_effect("FireAlarm02", "fireAlarm3")
            
        end
    end)

----------------------------------------------------------------------------------------------------
LocValetParking:setSceneHandler(3,
    function(aScene, aEvent)
        if aEvent == "capture" then
            aScene:captureObjects({'mop'})
        elseif aEvent == "generic_init" then

            
            aScene:setWinTerms({"ho_collected", "activate_lever"})
            aScene:setHidsParams({"mop"}, {inventory = true})

        elseif aEvent == "start" then
            aScene:setExtraParams("lasers", {play = true, loop = true})
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract("door")
            aScene:attachInteract("lever", "mop")
            aScene:setHidsParams({'accumulator', 'graffiti', 'screwdriver', 'oil_can'}, {active = false})
            aScene:setTask("ids_challenge_locvaletparking_3")
            aScene:activateCloseUp('LocValetParkingCloseUp', false)
            aScene:setRemark('ids_remark_locvaletparking_3') 

        elseif aEvent == "activate_lever" then
            aScene:setExtraParams("lasers", {visible = false})
            aScene:setHidsParams({'accumulator', 'graffiti', 'screwdriver', 'oil_can'}, {active = true})
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        elseif aEvent == "activate_door" then
            aScene:setInteractParams("door",{active = false})
            aScene:activateCloseUp('LocValetParkingCloseUp', true)

        end
    end)

----------------------------------------------------------------------------------------------------
LocValetParking:setSceneHandler(4,
    function (aScene, aEvent)
    
        -- plan visible,active,click (camera_parking -> screen)
    
        if aEvent == "capture" then
            aScene:captureObjects({'camera_parking', 'plan'})
        elseif aEvent == "generic_init" then
            
            aScene:setWinTerms({"ho_collected", "activate_screen"})
            aScene:setHidsParams({"camera_parking"}, {inventory = true})
            aScene:setHidsParams({"plan"}, {active = false, visible = false})

        elseif aEvent == "start" then
        
            aScene:setRemark('ids_remark_locvaletparking_4')
            aScene:setTask("ids_challenge_locvaletparking_4")
            aScene:attachHids(aScene:getHidList())
            aScene:attachInteract("screen", "camera_parking")
            aScene:setExtraParams("lasers", {visible = false})

        elseif aEvent == "activate_screen" then
            aScene:setHidsParams({"plan"}, {active = true, visible = true})
            ho:click('hid_4_plan')
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        end
    end)

----------------------------------------------------------------------------------------------------
LocValetParking:setSceneHandler(5,
    function(aScene, aEvent)

        -- charged_radio visible,active,click(charger_radio(car_charger + radio) -> car_panel)

        if aEvent == "capture" then
            aScene:captureObjects({'charged_radio', 'car_charger', 'car_number'})
        elseif aEvent == "generic_init" then
            
            aScene:setWinTerms({"ho_collected", "activate_car_panel"})
            aScene:setHidsParams({"charged_radio"}, {active = false, visible = false})

        elseif aEvent == "start" then
            aScene:attachHids(aScene:getHidList({except = {'charger_radio'}}))
            aScene:setExtraParams("lasers", {visible = false})
            aScene:addItemMix('charger_radio', {'car_charger', 'radio'})
            aScene:setRemark('ids_remark_locvaletparking_5')
            aScene:setTask("ids_challenge_locvaletparking_5")

        elseif aEvent == "found_charger_radio" then
            aScene:attachInteract("car_panel", "charger_radio")

        elseif aEvent == "activate_car_panel" then
            aScene:setHidsParams({"charged_radio"}, {active = true, visible = true})
            ho:click('hid_5_charged_radio')
            aScene:onChallengeComplete()
            aScene:setTask("ids_collect_ho")

        end
    end)