function OnSceneLoad(screen)
    LoadData(screen)
    DefaultOnSceneLoad('data/Scenes/19_Corridor_Main.lua', 'quest')

	RegisterQuestObjects('area_boiler')

    LinkScene('area_back', 'CursorDoorDown', 'data/Scenes/18_Theatre_Hall_Main.lua', false)
    
    LoadSound('19_Door_open', 'data/Sound/19_Corridor/Door_open.ogg');

    if HasGameState('MiniGameCompleted', '19') then
        LinkScene('area_boiler', 'CursorDoorRight', 'data/Scenes/20_Boiler_Room_Main.lua', false)
        play_field:GetObject('Mask'):SetVisible(false)
		play_field:GetObject('lantern'):SetVisible(false)
		
		if not HasGameState('DoorOpenSound', '19')
		then
		    MakeSoundEntity('19_Door_open'):Play(false);
		    AddGameState('DoorOpenSound', '19')
		end
    else
        LinkScene('area_boiler', 'CursorGlass', 'data/Scenes/19_Corridor_MG.lua', false)
		play_field:GetObject('Layer_Door'):SetVisible(false)
		play_field:GetObject('Layer_Door_Light'):SetVisible(false)

		game_state.custom_cursors['BG_Tunnel_Dark'] = 'CursorTool'
		play_field:GetLevelScreen():GetPanel():GetObject('button_l_inventory'):Hide()
		play_field:GetLevelScreen():GetPanel():GetObject('left'):Hide()
		play_field:IgnoreOnTestPoint('lantern')
    end

	game_state.ignore_on_highlight['BG_Tunnel_Dark'] = true
	
	play_field:GetObject('BG_Tunnel_Light'):SetVisible(false);
	play_field:GetObject('radialGlow'):SetVisible(false);
	play_field:GetObject('radialGlow_2'):SetVisible(false);
	
	play_field:IgnoreOnTestPoint('Layer_Door_Light')
    play_field:IgnoreOnTestPoint('Mask')
    play_field:GetObject('Mask'):SetZ(play_field:GetObject('Mask'):GetZ() + 100)
    if HasGameState('TaskComplete', '20_TurnOnLights') then
    
		play_field:GetObject('BG_Tunnel_Dark'):SetVisible(false)
		play_field:GetObject('BG_Tunnel_Light'):SetVisible(true)
		
		play_field:GetObject('radialGlow'):SetVisible(true);
	    play_field:GetObject('radialGlow_2'):SetVisible(true);
	    
	    local megolight = MegoLightEffector();
        megolight:AttachTo(play_field:GetObject('radialGlow'));
        megolight:Play();

        local megolight = MegoLightEffector();
        megolight:AttachTo(play_field:GetObject('radialGlow_2'));
        megolight:PlayAt(0.6);
	    
		LinkScene('area_makeup', 'CursorDoorLeft', 'data/Scenes/21_Make_Up_Room_Main.lua', false)
		LinkScene('area_backstage', 'CursorDoorUp', 'data/Scenes/22_Backstage_Main.lua', false)
		game_state.ignore_on_highlight['area_boiler'] = true

		if HasGameState('ToolFound', '21_scissors') and HasGameState('ToolFound', '21_lever') then
			game_state.ignore_on_highlight['area_makeup'] = true
		end
		if HasGameState('ToolFound', '24_pimpa') and
		   HasGameState('ToolFound', '24_runa') and
		   HasGameState('ToolFound', '24_chain') and
		   HasGameState('ToolFound', '22_switch')
		then
			game_state.ignore_on_highlight['area_backstage'] = true
		end
    end
    
end

function OnSceneFree(screen)
    DefaultOnSceneFree()
    FreeData(screen)
end

function OnUpdate(dt)
    DefaultOnUpdate(dt)

	if not HasGameState('MiniGameCompleted', '19') then
		play_field:GetObject('Mask'):SetXY(GetMousePos().x, GetMousePos().y)
		play_field:GetObject('lantern'):SetXY(GetMousePos().x, GetMousePos().y)
		play_field:GetObject('lantern'):SetVisible(currentCursor == 'CursorTool')
	end
end

function OnAllItemsFound()
    DefaultOnAllItemsFound()
end

function OnLose()
    DefaultOnLose()
end

function OnExit()
    DefaultOnExit()
end

function OnClose()
    DefaultOnClose()
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
end

function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

function OnObjectMouseDown(object)
    local is_wrong_click = not DefaultOnObjectMouseDown(object)
    local obj_name = object:GetName()
    local pf = play_field

    DefaultOnObjectMouseDownProcessed(is_wrong_click);
end

function OnObjectMouseUp(object)
    DefaultOnObjectMouseUp(object)
end

function OnObjectFound(object)
    DefaultOnObjectFound(object)
end

function OnToolFound(tool)
    DefaultOnToolFound(tool)
end

function OnToolApply(tool, object)
    DefaultOnToolApply(tool, object)
end

function OnObjectReachPanel(object)
    DefaultOnObjectReachPanel(object)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
end

function OnMouseMove(previous_pos, current_pos)
    DefaultOnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
    DefaultOnSetTool(tool)
end

function LevelLoaded(level)
end

function OnSceneDestroy(playfield)
    DefaultOnSceneDestroy(playfield)
end

--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData(screen)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(3,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_back',anim,206,671,100,0,70,25)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_boiler',anim,796,485,100,0,17,50)
	local anim = CreateAnimation('data/Texture/Scenes/19_Corridor/Zone_Main/Layers/BG_Tunnel_Dark.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Tunnel_Dark',anim,512,384,45,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/19_Corridor/Zone_Main/Layers/BG_Tunnel_Light.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Tunnel_Light',anim,512,384,40,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/19_Corridor/Zone_Main/Layers/Mask.PNG',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Mask',anim,512,384,10,0,3.2,3.2)
	local anim = CreateAnimation('data/Texture/Scenes/19_Corridor/Zone_Main/Layers/Layer_Door.png',0,0,124,397,1,0)
	anim:SetHotSpot(62,198)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Door',anim,798,505,50,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/19_Corridor/Zone_Main/Layers/Layer_Door_Light.png',0,0,328,543,1,0)
	anim:SetHotSpot(164,271)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Door_Light',anim,696,570,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_makeup',anim,473,445,42,0,10,20)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_backstage',anim,575,388,42,0,10,10)
	local anim = CreateAnimation('data/Texture/Scenes/18_Theatre_Hall/Zone_HO/Tools/Lantern_Window_Light.PNG',0,0,250,250,1,0)
	anim:SetHotSpot(125,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('lantern',anim,530,426,130,0,0.25,0.25)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFBB00')
	screen:CreateObject('radialGlow',anim,568,267,41,0,2.5,2.5)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFBB00')
	screen:CreateObject('radialGlow_2',anim,495,98,41,0,3,3)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
