local zone_table = nil;
--[[local]] zone_doll = nil
local zone_piano_big = nil;
local zone_letter

local Far_Far_Away = 3000.0;

function add_fibrillation_effector_fire(obj)
	local duration = 0.20

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

	eff:SetKey(_TRACK_O, 0.0, 1.0)
	eff:SetKey(_TRACK_O, duration *1.0/4.0, 0.98)
	eff:SetKey(_TRACK_O, duration *2.0/4.0, 1.0)
	eff:SetKey(_TRACK_O, duration *3.0/4.0, 0.92)
	eff:SetKey(_TRACK_O, duration *4.0/4.0, 1.0)
	eff:Play()
end

function add_fibrillation_effector_lamp(obj, delay)
	local duration = 3.0

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

    local dopacity = -0.35

	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/03_Hotel_Camin_Hall_Main.lua', 'quest')
    
    AddSpiderMan(screen);
	
	RegisterQuestObjects('area_zoom_doll', 'area_paper', 'area_table', 'area_ho', 'area_doll', 'Key', 'Notes_On_The_Piano')
    
    play_field:GetObject('area_small_dools'):SetOpacity(0);
    play_field:GetObject('area_small_dools'):SetMaxOpacity(0.001);

    zone_doll = CreateZoomZone('area_doll',
                               'CloseZoneDoll',
                               'BG_Zoom_Piano', true,
                               --'forward_hand', false,
                               'back_hand', true,
                               'hands', false,
							   'Layer_hand_shadow', false,
                               'Layer_No_Nand', true,
                               'doll_key', true,
                               'Doll_Eye_Blinking', true,
                               'area_zoom_doll', true,
                               'keys', false,
                               'Paper', false,
                               'area_paper', false,
                               'eyes_left', true,
                               'eyes_right', true,
                               'area_small_dools', true,
                               'child_drawing', true)
    zone_doll.on_open = function()
        game_state.doll03ZoneOpen = true;
        if not HasGameState('ToolApplied', '03_hand') then
            RegisterMonologObject('area_zoom_doll', 'C_03_DOLL_BROKEN')
            
            if HasGameState('ToolFound', '03_hand')
            then
                if not HasGameState(HELP_SHOWN, 'TAKE_ITEM_TIP') and InteractiveHelpBeingShown()
                then
                    play_field.mouseDownBlocked = true;
                    TimerDoString("play_field.mouseDownBlocked = false;"..
                                  "ShowTakeItemTip();", 0.5, play_field:GetTimer());
                end
            end
        end
        if HasGameState('ToolApplied', '03_hand') then
            zone_doll.SetObjectVisible('Paper', false)
            play_field:GetObject('Paper'):SetVisible(false)
            play_field:GetObject('Paper'):SetXY(0., Far_Far_Away)
        end
        if HasGameState('ToolFound', '03_paper') then
            zone_doll.SetObjectVisible('area_paper', false)
            play_field:GetObject('area_paper'):SetVisible(false)
            play_field:GetObject('area_paper'):SetXY(0., Far_Far_Away)
        end

        if (play_field.spiderManPresent)
        then
            game_state.playing_spider_main = false;
            play_field.spiderSound:StopSound();
        end
        
        RegisterMonologObject('area_small_dools', 'C_03_DOLLS_LIKE_ALIVE', true)
        RegisterMonologObject('child_drawing', 'C_03_SIMON_LIKES_TO_DRAW', true)
        --[[
        if play_field:GetObject('area_paper'):GetOpacity() > 0. then
            play_field:GetObject('area_paper'):AddParticleSystem('data/ParticleSystem/ObjectHighlight.psi',
                                                                 'ZoneHighlightParticle',
                                                                 true)
        end
        ]]
    end

    if HasGameState('ToolFound', '03_paper') then
        zone_doll.Disable();
    end

    play_field:GetObject('eyes_left'):GetAnimation():SetMode(HGEANIM_NOLOOP)
    play_field:GetObject('eyes_right'):GetAnimation():SetMode(HGEANIM_NOLOOP)
    StartAnimationWithRandomPeriod('eyes_left', 1., 4.)
    StartAnimationWithRandomPeriod('eyes_right', 1., 3.)

    play_field:GetObject('Layer_Notes'):SetVisible(false);
    --game_state.custom_cursors['area_paper'] = 'CursorActive'

    LinkScene('area_door', 'CursorDoorUp', 'data/Scenes/02_Hotel_Reception_Main.lua', false)
    LinkScene('area_ho', 'CursorGlass', 'data/Scenes/03_Hotel_Camin_Hall_HO.lua', true)

    if HasGameState('SpiderManVanished', '3') then
        RegisterTableZone()
    else
        game_state.custom_cursors['area_table'] = 'CursorActive';
    end

    local on_key_find = function()
        if zone_table then
            zone_table.SetObjectVisible('Key', false)
            zone_table.SetVisible(false)
            play_field:GetObject('Key'):ResetParticleSystem()
			game_state.ignore_on_highlight['area_table'] = true
        end
    end
    local on_load_when_key_found = function()
        if zone_table then
            zone_table.SetObjectVisible('Key', false)
            play_field:GetObject('Key'):ResetParticleSystem()
			game_state.ignore_on_highlight['area_table'] = true
        end
    end
    RegisterToolFindInfo('03_key', 'Key', on_key_find, on_load_when_key_found)

    --play_field:GetObject('forward_hand'):GetAnimation():Stop()
    play_field:GetObject('Doll_Eye_Blinking'):GetAnimation():Stop();
    play_field:GetObject('hands'):GetAnimation():Stop()
    play_field:GetObject('keys'):GetAnimation():Stop()
    play_field:GetObject('doll_key'):GetAnimation():Stop()
    play_field:GetObject('Paper'):GetAnimation():Stop()
    play_field:GetObject('Paper'):GetAnimation():SetMode(HGEANIM_NOLOOP)

    --local register_key_object = function()
        on_key_click = function()
            --if HasGameState('ToolApplied', '03_hand') then
                zone_doll.SetObjectVisible('back_hand', false)
                --zone_doll.SetObjectVisible('forward_hand', false)
                zone_doll.SetObjectVisible('hands', true)
				zone_doll.SetObjectVisible('Layer_hand_shadow', true)
                zone_doll.SetObjectVisible('keys', true)
                zone_doll.SetObjectVisible('Paper', true)

                play_field:GetObject('back_hand'):ChangeOpacity(1., 0., 0.3)
                --play_field:GetObject('forward_hand'):ChangeOpacity(1., 0., 0.3)
                --play_field:GetObject('hands'):ChangeOpacity(0., 1., 0.3)

                --play_field:GetObject('forward_hand'):GetAnimation():Play()
                play_field:GetObject('hands'):GetAnimation():Play()
                play_field:GetObject('keys'):GetAnimation():Play()
                play_field:GetObject('doll_key'):GetAnimation():Play()
                play_field:GetObject('Paper'):GetAnimation():Play()
				local blinkingEyePlayInstruction = "play_field:GetObject('Doll_Eye_Blinking'):GetAnimation():Play()";
				
				TimerDoString(blinkingEyePlayInstruction, 0.7, play_field:GetTimer());
				TimerDoString(blinkingEyePlayInstruction, 3, play_field:GetTimer());
				TimerDoString(blinkingEyePlayInstruction, 5, play_field:GetTimer());
				TimerDoString(blinkingEyePlayInstruction, 8, play_field:GetTimer());
				TimerDoString(blinkingEyePlayInstruction, 11, play_field:GetTimer());

                local action = "RegisterPaperTool()"
                local delay = GetAnimationLength(play_field:GetObject('Paper'):GetAnimation())
                TimerDoString(action, delay, play_field:GetTimer())
                
                PauseAmbientMusic(false);

                TimerDoString("OnPaperAppear()", delay + 0.6, play_field:GetTimer())

                play_field.pianoSound = MakeSoundEntity('piano');
                play_field.pianoSound:Play(false);

            --else
                --RemoveGameState('ObjectClicked', game_state.scene_path..'(doll_key)')
            --end
            end
        local on_load_when_key_clicked = function()
            zone_doll.SetObjectVisible('back_hand', false)
            --zone_doll.SetObjectVisible('forward_hand', true)
            play_field:GetObject('hands'):GetAnimation():Rewind(false)
            zone_doll.SetObjectVisible('hands', true)
			zone_doll.SetObjectVisible('Layer_hand_shadow', true)
            zone_doll.SetObjectVisible('keys', false)
            zone_doll.SetObjectVisible('doll_key', true)
            zone_doll.SetObjectVisible('Paper', true)

            RegisterPaperTool()
        end
        --RegisterActiveObject('doll_key', on_key_click, on_load_when_key_clicked)
    --end

    play_field:GetObject('Layer_hand'):SetOpacity(0.)
    local on_hand_apply = function(tool_name, object_name)
        --zone_doll.SetObjectVisible('forward_hand', true)
        --play_field:GetObject('forward_hand'):ChangeOpacity(0., 1., 0.3)
        --register_key_object()

        UnregisterActiveObject('area_zoom_doll')

        play_field:GetObject('Layer_No_Nand'):SetOpacity(0.)
        zone_doll.SetObjectVisible('Layer_No_Nand', false)
        play_field:GetObject('Layer_hand'):SetOpacity(1.)
        play_field:GetObject('Layer_Notes'):SetVisible(true);
        zone_doll.SetObjectVisible('hands', true)
		zone_doll.SetObjectVisible('Layer_hand_shadow', true)
		
		game_state.quest_objects['area_zoom_doll'] = false

        TimerDoString("on_key_click()", 0.5, play_field:GetTimer());

    end
    local on_load_when_hand_applied = function(tool_name)
        --zone_doll.SetObjectVisible('forward_hand', true)
        --if not HasGameState('ObjectClicked', game_state.scene_path..'(doll_key)') then
            --register_key_object()
        --end
        if not HasGameState('ToolFound', '03_paper')
        then
            play_field:GetObject('Layer_Notes'):SetVisible(true);
        end
        zone_doll.SetObjectVisible('Layer_No_Nand', false)
        play_field:GetObject('Layer_hand'):SetOpacity(1.)
		game_state.quest_objects['area_zoom_doll'] = false
        on_load_when_key_clicked()
    end
    RegisterToolApplyInfo('03_hand', 'area_zoom_doll', nil, nil, on_hand_apply, on_load_when_hand_applied)

    zone_doll.on_close = function()
        game_state.doll03ZoneOpen = nil;
        if HasGameState('ToolApplied', '03_hand') then
            on_load_when_hand_applied()
            if (play_field.pianoSound)
            then
                play_field.pianoSound:StopSound();
            end
            ContinueAmbientMusic(true);
        end

        if (play_field.spiderManPresent)
        then
            game_state.playing_spider_main = true;
            play_field.spiderSound:Play(true);
            play_field:GetObject('SpiderMan'):GetAnimation():SetFrame(0);
        end
        
        play_field:GetObject('area_paper'):ResetParticleSystem()
    end
    
    add_fibrillation_effector_fire(play_field:GetObject('radial_glow'))
    play_field:IgnoreOnTestPoint('radial_glow')
    play_field:IgnoreOnTestPoint('Layer_No_Nand')

    add_fibrillation_effector_lamp(play_field:GetObject('radial_glow_lamp1'), 0.)
    add_fibrillation_effector_lamp(play_field:GetObject('radial_glow_lamp2'), 0.5)
    add_fibrillation_effector_lamp(play_field:GetObject('radial_glow_lamp3'), 1.)
    add_fibrillation_effector_lamp(play_field:GetObject('radial_glow_lamp4'), 1.5)
    
	local on_ceiling_click = function()
		PlayCeilingDustAnimation()
		game_state.ignore_on_highlight['area_ceiling'] = true
	end
	local on_load_when_ceiling_clicked = function()
		game_state.ignore_on_highlight['area_ceiling'] = true
	end
    RegisterActiveObject('area_ceiling',
						 on_ceiling_click,
						 on_load_when_ceiling_clicked,
						 true,
						 'CursorGlass')
    
    play_field:GetObject('Doll_Eye_Blinking'):GetAnimation():SetMode(HGEANIM_PINGPONG);
    play_field:GetObject('Picture_fall'):GetAnimation():SetMode(HGEANIM_FWD);
    play_field:GetObject('Picture_fall'):GetAnimation():Stop();

    
    play_field:IgnoreOnTestPoint('radial_glow_lamp1')
    play_field:IgnoreOnTestPoint('radial_glow_lamp2')
    play_field:IgnoreOnTestPoint('radial_glow_lamp3')
    play_field:IgnoreOnTestPoint('radial_glow_lamp4')
    
    RegisterActiveObject('area_hidden_letter',
        function()
            MakeSoundEntity("Picture_fall_brake"):Play(false);
            play_field:GetObject('Picture_fall'):GetAnimation():Play();
            game_state.locked_objects['area_hidden_letter'] = nil;
            TimerDoString("RegisterLetterZone()", 1.5, play_field:GetTimer())
            TimerDoString("HighlightObject('area_hidden_letter')", 1.8, play_field:GetTimer())
        end, 
        function()
            play_field:GetObject('Picture_fall'):GetAnimation():Rewind(true);
            RegisterLetterZone()
        end,
        false)

	game_state.ignore_on_highlight['area_door'] = true
end

function RegisterLetterZone()
    zone_letter = CreateZoomZone('area_hidden_letter',
								 'ClozeLetterZoom',
							     'Zoom_Letter', true);
	zone_letter.on_open = function()
		game_state.ignore_on_highlight['area_hidden_letter'] = true
		AddGameState('IgnoreOnHighlight', 'area_hidden_letter')
	end
end

function StartAnimationWithRandomPeriod(name, period_min, period_max)
    play_field:GetObject(name):GetAnimation():Play()
    local action = "StartAnimationWithRandomPeriod('"..name.."', "..period_min..", "..period_max..")"
    TimerDoString(action,
                  math.random(period_min, period_max),
                  play_field:GetTimer())
end

function RegisterTableZone()
    zone_table = CreateZoomZone('area_table',
                                'CloseZoneTable',
                                'newspaper', true,
                                'Key', true)
    zone_table.on_open = function() 
        --[[
        if zone_table.IsObjectVisible('Key') then
            play_field:GetObject('Key'):AddParticleSystem('data/ParticleSystem/ObjectHighlight.psi',
                                                          'ZoneHighlightParticle',
                                                          true)
        end
        ]]
        
        if not HasGameState(HELP_SHOWN, 'OBJECT_ON_LOC_TIP') and InteractiveHelpBeingShown()
        then
            play_field.mouseDownBlocked = true;
            TimerDoString("play_field.mouseDownBlocked = false;"..
                          "ShowObjectOnLocTip();", 0.5, play_field:GetTimer());
        end
        
    end
    zone_table.on_close = function()
        play_field:GetObject('Key'):ResetParticleSystem()
    end
end

function OnPaperAppear()
    ContinueAmbientMusic(true);
end

function RegisterPaperTool()
    --play_field:GetObject('forward_hand'):GetAnimation():Stop()
    play_field:GetObject('hands'):GetAnimation():Stop()
    play_field:GetObject('keys'):GetAnimation():Stop()
    play_field:GetObject('doll_key'):GetAnimation():Stop()
    play_field:GetObject('Paper'):GetAnimation():Stop()
    play_field:GetObject('Doll_Eye_Blinking'):GetAnimation():Stop();

    zone_doll.SetObjectVisible('area_paper', true)
    if zone_doll:IsVisible() then
        play_field:GetObject('area_paper'):SetOpacity(1.)
    end

    if not HasGameState('ToolFound', '03_paper') then
        local on_paper_find = function()
			play_field:GetObject('Notes_On_The_Piano'):DestroyChildren()
            zone_doll.SetObjectVisible('Paper', false)
            zone_doll.SetObjectVisible('area_paper', false)
            play_field:GetObject('Paper'):ChangeOpacity(1., 0., 0.3)
            play_field:GetObject('area_paper'):ChangeOpacity(1., 0., 0.3)
            zone_piano_big.SetVisible(false);
            zone_doll.SetVisible(false)
            TimerDoString("zone_doll.SetVisible(false)", 1., play_field:GetTimer())
            zone_doll.Disable()
            play_field:GetObject('Layer_Notes'):SetVisible(false);
			game_state.ignore_on_highlight['area_doll'] = true
        end
        local on_load_when_paper_found = function()
            zone_doll.SetObjectVisible('Paper', false)
            zone_doll.SetObjectVisible('area_paper', false)
            zone_doll.SetObjectVisible('back_hand', true)
            --zone_doll.SetObjectVisible('forward_hand', true)
            zone_doll.SetObjectVisible('hands', true)
			zone_doll.SetObjectVisible('Layer_hand_shadow', true)
            zone_doll.SetObjectVisible('keys', false)
            zone_doll.SetObjectVisible('doll_key', true)
            zone_doll.SetObjectVisible('Paper', false)
            zone_doll.SetObjectVisible('area_paper', false)
            zone_doll.Disable() 
            
            play_field:GetObject('Layer_Notes'):SetVisible(false);
        end
        
        if (zone_piano_big == nil)
        then
            zone_piano_big = CreateZoomZone('area_paper',
                                           'CloseZonePianoBig',
                                           'BG_Notes_On_The_Piano', true,
                                           'Notes_On_The_Piano', true)
        end

        RegisterToolFindInfo('03_paper', 'Notes_On_The_Piano', on_paper_find, on_load_when_paper_found)
	else
		game_state.ignore_on_highlight['area_doll'] = true
    end

    --[[
    play_field:GetObject('area_paper'):AddParticleSystem('data/ParticleSystem/ObjectHighlight.psi',
                                                         'ZoneHighlightParticle',
                                                         true)
   ]]
end

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

function OnUpdate(dt)
    DefaultOnUpdate(dt)

	if HasGameState('ToolFound', '03_key') and
	   HasGameState('ToolFound', '03_hand') and
	   HasGameState('ToolFound', '03_paper')
	then
		game_state.ignore_on_highlight['area_door'] = false
	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()
    
    if (play_field.mouseDownBlocked and (game_state.forcedObject == nil or game_state.forcedObject ~= obj_name))
    then
        return;
    end

    if (obj_name == 'SpiderMan' or
        (not HasGameState('SpiderManVanished', '3') and obj_name == 'area_table'))
    then
        play_field:DeleteObject('SpiderMan');
        game_state.custom_cursors['SpiderMan'] = nil;
        game_state.custom_cursors['area_table'] = nil;

        local state = GetGameManager():GetCurrPlayer().m_gameState;
        state:AddState('SpiderManVanished', '3');
        play_field.spiderManPresent = false;

        PlaySpiderManFleeingAnimation(play_field);

        RegisterTableZone()
        
        if game_state.forcedObject and tutorScreen
        then
            tutorScreen:Hide();
        end
    end
    
    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

-- CLEAR_ON_SAVE_END

--------------------------------------------------------------------------------
function PlaySpiderSound()
    if game_state.playing_spider_main then
    
        local spiderSound = MakeSoundEntity('03_spider_main');
        play_field.spiderSound = spiderSound;
        spiderSound:Play(true);
        
    end
end

--------------------------------------------------------------------------------
function AddSpiderMan(scene)
    local state = GetGameManager():GetCurrPlayer().m_gameState;
    if (state:HasState('SpiderManVanished') and state:GetState('SpiderManVanished'):HasValue('3'))
    then
    else
        play_field.spiderManPresent = true;
        local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Animation/Spider_doll_sitting.png',
                                     0, 0, 113, 106, 40, 30)
        anim:SetHotSpot(55.5, 52)
        anim:SetBlendMode(2)
        anim:SetColor('0xFFFFFFFF')
        scene:CreateObject('SpiderMan',anim,819.5,552,100,0,1,1)
        
        game_state.custom_cursors['SpiderMan'] = 'CursorActive';

        game_state.playing_spider_main = true
        PlaySpiderSound()
	end
end

--------------------------------------------------------------------------------
function PlaySpiderManFleeingAnimation(scene)
    game_state.playing_spider_main = false
    
    play_field.spiderSound:StopSound();
    play_field.spiderSound:Destroy();
    play_field.spiderSound = nil;
    
    TimerDoString("MakeSoundEntity('03_spider_click'):Play(false);", 0.2, play_field:GetTimer())

    --------
    local anim = nil;
    local object = nil;
    local effector = nil;
    
    anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Animation/Spider_doll_fleeing_2.png',0,0,292,137,11,15)
    anim:SetHotSpot(146, 68.5);
    anim:SetBlendMode(2)
    anim:SetColor('0xFFFFFFFF')
    object = scene:CreateObject('SpiderManFleeing2', anim, 549, 546, 100, 0, 1, 1);
    object:SetVisible(false);
    
    effector = CreateAnimationEffector();
    effector:SetLifeTime(1.0, 1.73);
    effector:SetAnimationTime(2);
    effector:AttachTo(object);
    effector:Play();
    
    --------
    
    anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Animation/Spider_doll_fleeing_1.png',0,0,215,167,15,15)
    anim:SetHotSpot(106.5, 82.5);
    anim:SetBlendMode(2)
    anim:SetColor('0xFFFFFFFF')
    object = scene:CreateObject('SpiderManFleeing1', anim, 768.5, 513, 100, 0, 1, 1);
    
    effector = CreateAnimationEffector();
    effector:SetLifeTime(0.0, 1.0);
    effector:SetAnimationTime(1.5);
    effector:AttachTo(object);
    effector:Play();
    
    --------
    
    anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Animation/Spider_doll_fleeing_3.png',0,0,191,237,8,15)
    anim:SetHotSpot(93.5, 116.5);
    anim:SetBlendMode(2)
    anim:SetColor('0xFFFFFFFF')
    object = scene:CreateObject('SpiderManFleeing3', anim, 95.0, 651, 100, 0, 1, 1);
    
    effector = CreateAnimationEffector();
    effector:SetLifeTime(2.0, 2.53);
    effector:SetAnimationTime(3);
    effector:AttachTo(object);
    effector:Play();
    
    TimerDoString(
        "if (game_state.locker:GetNReferences() == 0) then " ..
        "ShowMonolog('03_spider_man_run_away', 'C_03_SPIDER_MAN_RUN_AWAY'); end;",
        2.5,
        play_field:GetTimer()
    )
    
    
end

function PlayCeilingDustAnimation()

    if game_state.ceilingDustAnimationPlaying_03
    then
        return;
    end
    
    game_state.ceilingDustAnimationPlaying_03 = true;
    TimerDoString("game_state.ceilingDustAnimationPlaying_03 = nil;", 4, play_field:GetTimer());

    MakeSoundEntity("Ceiling_dust"):Play(false);

    local screen = play_field;

    local composition = CreateCompositionSequence();
    local compositionDuration = 3.92;
    composition:SetDuration(compositionDuration);
    composition:AttachTo(screen);
    composition:SetZ(100);
    
    
    -- Layer Dust_1
    local element = CreateCompositionElement("data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/dust2.png");
    element:SetName("Dust_1");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(603, 137);
    
    element:SetAngle(0.12930802900964);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.64, 3.92);
    
    effector:SetKey(_TRACK_SX, 0.64, 0.21);
    effector:SetKey(_TRACK_SY, 0.64, 0.21);
    effector:SetKey(_TRACK_SX, 3.2, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 3.2, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.64, 0);
    effector:SetKey(_TRACK_O, 0.92, 0.5);
    effector:SetKey(_TRACK_O, 1.16, 0.5);
    effector:SetKey(_TRACK_O, 3.16, 0);
    
    effector:Play();
    
    
    -- Layer Dust_2
    local element = CreateCompositionElement("data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/dust2.png");
    element:SetName("Dust_2");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(659, 111);
    
    element:SetAngle(-0.17952927166646);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.72, 4);
    
    effector:SetKey(_TRACK_SX, 0.72, 0.21);
    effector:SetKey(_TRACK_SY, 0.72, 0.21);
    effector:SetKey(_TRACK_SX, 3.28, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 3.28, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.72, 0);
    effector:SetKey(_TRACK_O, 1, 0.5);
    effector:SetKey(_TRACK_O, 1.24, 0.5);
    effector:SetKey(_TRACK_O, 3.24, 0);
    
    effector:Play();
    
    
    -- Layer Dust_3
    local element = CreateCompositionElement("data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/dust2.png");
    element:SetName("Dust_3");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(630, 126);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.52, 3.8);
    
    effector:SetKey(_TRACK_SX, 0.52, 0.21);
    effector:SetKey(_TRACK_SY, 0.52, 0.21);
    effector:SetKey(_TRACK_SX, 3.08, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 3.08, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.52, 0);
    effector:SetKey(_TRACK_O, 0.8, 0.5);
    effector:SetKey(_TRACK_O, 1.04, 0.5);
    effector:SetKey(_TRACK_O, 3.04, 0);
    
    effector:Play();
    
    
    -- Layer Dust_4
    local element = CreateCompositionElement("data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/dust2.png");
    element:SetName("Dust_4");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(603, 137);
    
    element:SetAngle(0.12930802900964);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.12, 3.4);
    
    effector:SetKey(_TRACK_SX, 0.12, 0.21);
    effector:SetKey(_TRACK_SY, 0.12, 0.21);
    effector:SetKey(_TRACK_SX, 2.28, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 2.28, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.12, 0);
    effector:SetKey(_TRACK_O, 0.4, 1);
    effector:SetKey(_TRACK_O, 0.64, 1);
    effector:SetKey(_TRACK_O, 2.24, 0);
    
    effector:Play();
    
    
    -- Layer Dust_5
    local element = CreateCompositionElement("data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/dust2.png");
    element:SetName("Dust_5");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(659, 111);
    
    element:SetAngle(-0.17952927166646);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.2, 3.48);
    
    effector:SetKey(_TRACK_SX, 0.2, 0.21);
    effector:SetKey(_TRACK_SY, 0.2, 0.21);
    effector:SetKey(_TRACK_SX, 2.36, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 2.36, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.2, 0);
    effector:SetKey(_TRACK_O, 0.48, 1);
    effector:SetKey(_TRACK_O, 0.72, 1);
    effector:SetKey(_TRACK_O, 2.32, 0);
    
    effector:Play();
    
    
    -- Layer Dust_6
    local element = CreateCompositionElement("data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/dust2.png");
    element:SetName("Dust_6");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(630, 126);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 3.28);
    
    effector:SetKey(_TRACK_SX, 0, 0.21);
    effector:SetKey(_TRACK_SY, 0, 0.21);
    effector:SetKey(_TRACK_SX, 2.16, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 2.16, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 0.28, 1);
    effector:SetKey(_TRACK_O, 0.52, 1);
    effector:SetKey(_TRACK_O, 2.12, 0);
    
    effector:Play();
    
    composition:Play();
    
    ShowMonolog('C_03_HOTEL_REALLY_OLD', 'C_03_HOTEL_REALLY_OLD');

end

function LevelLoaded(level)
    ShowActiveZonesTip();
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/03_Hotel_Camin_Hall/Zone_Main/Layers/BG_Camin_Hall.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Camin_Hall',anim,512,384,40,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Newspaper/newspaper.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('newspaper',anim,512,384,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(1,2)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_table',anim,672,565,100,0,25,8)
	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_door',anim,493,415,105,0,10,18)
	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_ho',anim,878,470,100,10,25,20)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radial_glow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,49)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF8800')
	screen:CreateObject('radial_glow',anim,857,476,101,0,2,2)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radial_glow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFAA44')
	screen:CreateObject('radial_glow_lamp1',anim,3,336,100,0,2,2)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radial_glow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFAA44')
	screen:CreateObject('radial_glow_lamp2',anim,165,325,100,0,2,2)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radial_glow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFAA44')
	screen:CreateObject('radial_glow_lamp3',anim,403,241,100,0,3.5,3.5)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radial_glow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFAA44')
	screen:CreateObject('radial_glow_lamp4',anim,778,359,100,0,2,2)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Animation/Fire.png',0,0,90,90,9,8)
	anim:SetHotSpot(405,45)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Fire',anim,1214,496,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/BG_Zoom_Piano.JPG',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('BG_Zoom_Piano',anim,512,384,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/back_hand.png',0,0,148,94,1,0)
	anim:SetHotSpot(74,47)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('back_hand',anim,514,334,152,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/Hands/hands.png',0,0,177,198,34,25)
	anim:SetHotSpot(0,0)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('hands',anim,426,179,170,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/Key/Kaminny_zoo.png',0,0,84,69,7,7)
	anim:SetHotSpot(42,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('doll_key',anim,648,201,155,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/Keys/keys.png',0,0,138,35,34,25)
	anim:SetHotSpot(69,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('keys',anim,464,366,151,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/Paper/Paper.png',0,0,103,153,11,0.85)
	anim:SetHotSpot(51,77)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Paper',anim,383,195,151,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/area_zoom_doll.jpg',0,0,107,137,1,0)
	anim:SetHotSpot(53,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('area_zoom_doll',anim,567,241,151,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/area_paper.png',0,0,124,151,1,0)
	anim:SetHotSpot(62,75)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('area_paper',anim,391,198,152,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/doll.png',0,0,127,170,1,0)
	anim:SetHotSpot(63,85)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('doll',anim,121,462,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Tools/Key_Newspaper.png',0,0,207,194,1,0)
	anim:SetHotSpot(65,72)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('Key',anim,636,307,155,0,1,1)
	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_doll',anim,114,433,115,0,18,15)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/Layer_Stul.png',0,0,62,49,1,0)
	anim:SetHotSpot(31,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Stul',anim,124,540,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/Layer_No_Nand.png',0,0,115,119,1,0)
	anim:SetHotSpot(57,59)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_No_Nand',anim,592,208,169,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/Layer_hand.png',0,0,40,43,1,0)
	anim:SetHotSpot(20,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_hand',anim,101,443,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Paper/BG_Notes.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('BG_Notes_On_The_Piano',anim,512,384,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Paper/noty_list.png',0,0,425,451,1,0)
	anim:SetHotSpot(212,225)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('Notes_On_The_Piano',anim,499,367,201,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_ceiling',anim,630,169,105,0,21,7)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/eyes_left.png',0,0,25,10,3,3)
	anim:SetHotSpot(12,5)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('eyes_left',anim,833,179,151,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/eyes_right.png',0,0,20,6,3,3)
	anim:SetHotSpot(10,3)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('eyes_right',anim,861,178,151,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/Layer_Notes.png',0,0,25,28,1,0)
	anim:SetHotSpot(12,14)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Notes',anim,86,428,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/Doll_Eye_Blinking.png',0,0,18,23,3,8)
	anim:SetHotSpot(9,11)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('Doll_Eye_Blinking',anim,493,149,170,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Animation/Picture_fall.png',0,0,259,386,26,12)
	anim:SetHotSpot(130,193)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Picture_fall',anim,390,565,50,0,1.03,1.04)
	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_hidden_letter',anim,374,411,51,0,6,10)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Letter/Letter.JPG',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('Zoom_Letter',anim,512,384,150,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_small_dools',anim,832,186,151,0,12,10)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/child_drawing.png',0,0,100,174,1,0)
	anim:SetHotSpot(50,87)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('child_drawing',anim,135,316,151,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Zoom_Piano/Layers/Layer_shadow.png',0,0,41,102,1,0)
	anim:SetHotSpot(20,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_hand_shadow',anim,312,299,151,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Hotel_Camin_Hall/Zone_Main/Layers/Key.PNG',0,0,17,14,1,0)
	anim:SetHotSpot(8,7)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('small_key',anim,127,425,100,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
