function add_fibrillation_effector_light(obj)
    local delay = 0.3
    local duration = 5.0

    eff= CreateAnimationEffector()
    eff:AttachTo(obj)
    eff:SetMode(_ANIM_LOOP)

    local dopacity = -0.50

    eff:SetKey(_TRACK_O, 0.0 + delay, 1.0 + dopacity)
    eff:SetKey(_TRACK_O, duration * 1.0/4.0 + delay, 0.75 + dopacity)
    eff:SetKey(_TRACK_O, duration * 2.0/4.0 + delay, 1.0 + dopacity)
    eff:SetKey(_TRACK_O, duration * 3.0/4.0 + delay, 0.59 + dopacity)
    eff:SetKey(_TRACK_O, duration * 4.0/4.0 + delay, 1.0 + dopacity)
    eff:Play()
end

function OnSceneLoad(screen)
    LoadData(screen)
    DefaultOnSceneLoad('data/Scenes/11_Museum_Hall_2_Main.lua', 'quest')
	
	RegisterQuestObjects('Layer_cube', 'Layer_Key_in_Hole')

    LinkScene('area_back', 'CursorDoorUp', 'data/Scenes/10_Museum_Hall_1_Main.lua', false)

    local show_deny_comics = function(obj_name)
        if HasGameState('ToolFound', '10_ring') then
            ShowMonolog('11_HaveRing', 'C_11_HAVE_RING')
        else
            ShowMonolog('11_NoRing', 'C_11_NO_RING')
        end
    end
    RegisterActiveObject('Layer_cube', show_deny_comics, nil, true)

	if not HasGameState('ToolFound', '11_key') then
		add_fibrillation_effector_light(play_field:GetObject('Layer_Light'))
	end

    play_field:GetObject('Layer_hole'):SetOpacity(0.)
    play_field:GetObject('Layer_Key_in_Hole'):SetOpacity(0.)
    local on_ring_apply = function(tool_name, object_name)
        play_field:GetObject('Layer_cube'):ChangeOpacity(1., 0., 0.3)
        play_field:GetObject('Layer_hole'):ChangeOpacity(1., 0., 0.3)
        play_field:GetObject('Layer_Key_in_Hole'):ChangeOpacity(0., 1., 0.3)
        --play_field:GetObject('Layer_Light'):ChangeOpacity(0., 1., 0.3)
        PlaySound("CuttingGlass");
    end
    local on_load_when_ring_applied = function(tool_name)
        play_field:GetObject('Layer_cube'):SetOpacity(0.)
        play_field:GetObject('Layer_hole'):SetOpacity(1.)
        play_field:GetObject('Layer_Key_in_Hole'):SetOpacity(1.)
        play_field:GetObject('Layer_Light'):SetOpacity(1.)
    end
    RegisterToolApplyInfo('10_ring', 'Layer_cube', nil, nil, on_ring_apply, on_load_when_ring_applied)

	game_state.ignore_on_highlight['area_back'] = true
    on_key_find = function()
		play_field:GetObject('Layer_Light'):DestroyChildren()
        play_field:GetObject('Layer_Light'):ChangeOpacity(1., 0., 0.2)
		game_state.ignore_on_highlight['area_back'] = false
    end
    on_load_when_key_found = function()
        play_field:GetObject('Layer_Key_in_Hole'):SetOpacity(0.)
        play_field:GetObject('Layer_Light'):SetOpacity(0.)
		game_state.ignore_on_highlight['area_back'] = false
    end
    RegisterToolFindInfo('11_key', 'Layer_Key_in_Hole', on_key_find, on_load_when_key_found)

    play_field:IgnoreOnTestPoint('Layer_Light')
    
    RegisterActiveObject('area_yellow_puppet',
        function()
			ShowMonolog('11_yellow_puppet', SelectRandom('C_11_YELLOW_PUPPET_1', 'C_11_YELLOW_PUPPET_2'))
			game_state.ignore_on_highlight['area_yellow_puppet'] = true
		end,
        function()
			game_state.ignore_on_highlight['area_yellow_puppet'] = true
		end,
		true,
		'CursorGlass')
    RegisterMonologObject('area_gm_puppet', 'C_11_GM_PUPPET', true)        
    RegisterMonologObject('area_doll_boot', 'C_11_DOLL_STRING_BROKEN', true)

	zone_board = CreateZoomZone('area_board',
							    'CloseZoneBoard',
							    'BG_Signboard', true)
	zone_board.on_open = function()
		game_state.ignore_on_highlight['area_board'] = true
		AddGameState('IgnoreOnHighlight', 'area_board')
	end

    LoadSound("CuttingGlass", "data/Sound/11_Museum_Hall_2/Cutting_glass.ogg")
end

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

function OnUpdate(dt)
    DefaultOnUpdate(dt)
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/11_Museum_Hall_2/Zone_Main/Layers/Layer_Light.png',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Light',anim,492,387,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/11_Museum_Hall_2/Zone_Main/Layers/Layer_kukla.png',0,0,695,768,1,0)
	anim:SetHotSpot(347,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_kukla',anim,676,384,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/11_Museum_Hall_2/Zone_Main/Layers/BG_Museum_Hall_2.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Museum_Hall_2',anim,512,384,40,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_back',anim,825,414,100,0,18,18)
	local anim = CreateAnimation('data/Texture/Scenes/11_Museum_Hall_2/Zone_Main/Layers/Layer_hole.png',0,0,259,295,1,0)
	anim:SetHotSpot(129,147)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_hole',anim,433,236,60,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/11_Museum_Hall_2/Zone_Main/Layers/Layer_Key_in_Hole.png',0,0,259,295,1,0)
	anim:SetHotSpot(76,136)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Key_in_Hole',anim,380,225,70,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/11_Museum_Hall_2/Zone_Main/Layers/Layer_cube.png',0,0,259,295,1,0)
	anim:SetHotSpot(76,136)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_cube',anim,380,225,80,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_yellow_puppet',anim,142,286,100,0,10,30)
	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_gm_puppet',anim,946,233,100,0,12,16)
	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_doll_boot',anim,730,693,100,0,15,8)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(5,3)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_board',anim,700,301,100,355,10,10)
	local anim = CreateAnimation('data/Texture/Scenes/11_Museum_Hall_2/Zone_Main/Zoom_Signboard/BG_Signboard.JPG',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('BG_Signboard',anim,512,384,150,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
