dofile('data/Scripts/Scenes/Common.lua');
dofile('data/Scripts/Scenes/Animations/16_TempleHall_Animations.lua');

------------------------------------------------------------------------------
--
function OnSceneLoad(restoringFromSave)
	InitGameState();

	play_field = playField;
    LoadData();
	play_field = nil;

    RootZoomZone = CreateZoomZone('RootZoomZone', nil, 
                                   nil, 0.0, 
                                   nil, 0.0,
							{'RootBackground',
							 'actZoneGates',

							 'ape',
							 'beads',
							 'box',
							 'chandelier',
							 'chest',
							 'coin',
							 'column',
							 'crystal',
							 'cup',
							 'dino',
							 'egg',
							 'feather',
							 'flowers',
							 'frog',
							 'gem',
							 'gorgon',
							 'harp',
							 'key',
							 'mask',
							 'owl',
							 'papyrus',
							 'peacock',
							 'pot',
							 'raven',
							 'ruby',
							 'rug',
							 'shield',
							 'spider',
							 'statue',
							 'sun',
							 'sword',
							 'tassel',
							 'terrestrialGlobe',
							 'tip',
							 'vase',
							 'wing',

							 'chandelierLayer',
							 'chandelierChain',
							 'roundCarpet',
							 'LayerOverApe',
							 'LayerOverChest',
							 'LayerOverColumn',
							 'LayerOverDino',
							 'LayerOverEgg',
							 'LayerOverFlowers',
							 'LayerOverOwl',
							 'layerOverPeacock',
							 'LayerOverRug',
							 'LayerOverTerrestrialGlobe',

							 'LayerOverCupWithFlame1',
							 'LayerOverCupWithFlame2',
							 'LayerOverCupWithFlame3',
							 'LayerOverCupWithFlame4',

							 'Crystal',
							 'DoorFragment',
							 'FuelCan',
							 'Lever',
							 'Pinion',
							 'Zippo',
							 'Crystal_onPlace',
							 'Lever_onPlace',

							 'actZoneCrystal',
							 'actZoneLever',
							 'actZoneCup1',
							 'actZoneCup2',
							 'actZoneCup3',
							 'actZoneCup4'},

							{'Crystal_onPlace',
							 'Lever_onPlace'},

							{'chandelierReflection'});

    GatesZoomZone = CreateZoomZone('GatesZoomZone', RootZoomZone, 
                                   'actZoneGates', 0.0, 
                                   nil, 0.0,
							{'ZoomGatesBackground',
							 'mechanismRight',
							 'mechanismRightAnimation',
							 'mechanismLeftAnimation',
							 'LayerOverX',
							 'DoorFragment_onPlace',

							 'actZonePinion',
							 'actZoneDoorFragment'},

							{'mechanismRightAnimation',
							 'DoorFragment_onPlace'});

if (restoringFromSave == false) then
    AddRandomTasks(true, MISC_TASK_COUNT_24,
		CreateTask('ape'),
		CreateTask('beads'),
		CreateTask('box'),
		CreateTask('chandelier'),
		CreateTask('chest'),
		CreateTask('coin'),
		CreateTask('column'),
		CreateTask('crystal'),
		CreateTask('cup'),
--		CreateTask('dino'),
		CreateTask('egg'),
		CreateTask('feather'),
		CreateTask('flowers'),
--		CreateTask('frog'),
		CreateTask('gem'),
		CreateTask('gorgon'),
		CreateTask('harp'),
		CreateTask('key'),
		CreateTask('mask'),
		CreateTask('owl'),
		CreateTask('papyrus'),
		CreateTask('peacock'),
		CreateTask('pot'),
		CreateTask('raven'),
		CreateTask('ruby'),
		CreateTask('rug'),
		CreateTask('shield'),
		CreateTask('spider'),
--		CreateTask('statue'),
		CreateTask('sun'),
		CreateTask('sword'),
		CreateTask('tassel'),
		CreateTask('terrestrialGlobe'),
		CreateTask('tip'),
		CreateTask('vase'),
		CreateTask('wing')
	);

    playField:GetLevelScreen():AddTaskSafe(CreateTask('Crystal'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('DoorFragment'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Pinion'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('FuelCan'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Zippo'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Lever'));
end

	CreateToolMap(	{'Crystal',			'actZoneCrystal'},
					{'DoorFragment',	'actZoneDoorFragment'},
					{'Pinion',			'actZonePinion'},
					{'FuelCan',   		'actZoneCup4'},
					{'Zippo',  			'actZoneCup4'},
					{'Lever',			'actZoneLever'});

	SetIconForGameObject(playField:GetObject('ape'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/ape_icon.png');
	SetIconForGameObject(playField:GetObject('beads'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/beads_icon.png');
	SetIconForGameObject(playField:GetObject('box'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/box_icon.png');
	SetIconForGameObject(playField:GetObject('chandelier'),	'data/Texture/Scenes/16_TempleHall/Items/Misc/chandelier_icon.png');
	SetIconForGameObject(playField:GetObject('chest'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/chest_icon.png');
	SetIconForGameObject(playField:GetObject('coin'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/coin_icon.png');
	SetIconForGameObject(playField:GetObject('column'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/column_icon.png');
	SetIconForGameObject(playField:GetObject('crystal'),	'data/Texture/Scenes/16_TempleHall/Items/Misc/crystal_icon.png');
	SetIconForGameObject(playField:GetObject('cup'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/cup_icon.png');
	SetIconForGameObject(playField:GetObject('dino'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/dino_icon.png');
	SetIconForGameObject(playField:GetObject('egg'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/egg_icon.png');
	SetIconForGameObject(playField:GetObject('feather'),	'data/Texture/Scenes/16_TempleHall/Items/Misc/feather_icon.png');
	SetIconForGameObject(playField:GetObject('flowers'),	'data/Texture/Scenes/16_TempleHall/Items/Misc/flowers_icon.png');
	SetIconForGameObject(playField:GetObject('frog'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/frog_icon.png');
	SetIconForGameObject(playField:GetObject('gem'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/gem_icon.png');
	SetIconForGameObject(playField:GetObject('gorgon'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/gorgon_icon.png');
	SetIconForGameObject(playField:GetObject('harp'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/harp_icon.png');
	SetIconForGameObject(playField:GetObject('key'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/key_icon.png');
	SetIconForGameObject(playField:GetObject('mask'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/mask_icon.png');
	SetIconForGameObject(playField:GetObject('owl'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/owl_icon.png');
	SetIconForGameObject(playField:GetObject('papyrus'),	'data/Texture/Scenes/16_TempleHall/Items/Misc/papyrus_icon.png');
	SetIconForGameObject(playField:GetObject('peacock'),	'data/Texture/Scenes/16_TempleHall/Items/Misc/peacock_icon.png');
	SetIconForGameObject(playField:GetObject('pot'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/pot_icon.png');
	SetIconForGameObject(playField:GetObject('raven'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/raven_icon.png');
	SetIconForGameObject(playField:GetObject('ruby'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/ruby_icon.png');
	SetIconForGameObject(playField:GetObject('rug'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/rug_icon.png');
	SetIconForGameObject(playField:GetObject('shield'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/shield_icon.png');
	SetIconForGameObject(playField:GetObject('spider'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/spider_icon.png');
	SetIconForGameObject(playField:GetObject('statue'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/statue_icon.png');
	SetIconForGameObject(playField:GetObject('sun'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/sun_icon.png');
	SetIconForGameObject(playField:GetObject('sword'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/sword_icon.png');
	SetIconForGameObject(playField:GetObject('tassel'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/tassel_icon.png');
	SetIconForGameObject(playField:GetObject('terrestrialGlobe'),'data/Texture/Scenes/16_TempleHall/Items/Misc/terrestrialGlobe_icon.png');
	SetIconForGameObject(playField:GetObject('tip'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/tip_icon.png');
	SetIconForGameObject(playField:GetObject('vase'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/vase_icon.png');
	SetIconForGameObject(playField:GetObject('wing'),		'data/Texture/Scenes/16_TempleHall/Items/Misc/wing_icon.png');

	SetIconForGameObject(playField:GetObject('Crystal'),	'data/Texture/Scenes/16_TempleHall/Items/Crystal_icon.png');
	SetIconForGameObject(playField:GetObject('DoorFragment'),'data/Texture/Scenes/16_TempleHall/Items/DoorFragment_icon.png');
	SetIconForGameObject(playField:GetObject('Pinion'),		'data/Texture/Scenes/16_TempleHall/Items/Pinion_icon.png');
	SetIconForGameObject(playField:GetObject('FuelCan'),	'data/Texture/Scenes/16_TempleHall/Items/FuelCan_icon.png');
	SetIconForGameObject(playField:GetObject('Zippo'),		'data/Texture/Scenes/16_TempleHall/Items/Zippo_icon.png');
	SetIconForGameObject(playField:GetObject('Lever'),		'data/Texture/Scenes/16_TempleHall/Items/Lever_icon.png');

if (restoringFromSave == false) then
	gameState.crystalOnPlace = false;
	gameState.doorFragmentOnPlace = false;
	gameState.pinionOnPlace = false;
	gameState.fuelPoured = false;
	gameState.zippoUsed = false;
	gameState.leverOnPlace = false;

	gameState.leverTurned = false;
	gameState.chandelierIsMoving = false;
	gameState.gatesMechanismIsActive = false;

	gameState.allToolsApplied = false;
	gameState.levelCompleted = false;
end

	AssignActiveZonesGlow({function() return gameState.crystalOnPlace; end,		'actZoneCrystal',		'Crystal_ghost'},
						  {function() return gameState.doorFragmentOnPlace; end,'actZoneDoorFragment',	'DoorFragment_ghost'},
					      {function() return gameState.pinionOnPlace; end,		'actZonePinion',		'Pinion_ghost'},
						  {function() return gameState.leverOnPlace; end,		'actZoneLever',			'Lever_ghost'},
						  {function() return gameState.fuelPoured; end,			'actZoneCup1',			'FuelCan_ghost1'},
						  {function() return gameState.zippoUsed or
											not gameState.fuelPoured; end,		'actZoneCup1',			'Zippo_ghost1'},
						  {function() return gameState.fuelPoured; end,			'actZoneCup2',			'FuelCan_ghost2'},
						  {function() return gameState.zippoUsed or
											not gameState.fuelPoured; end,		'actZoneCup2',			'Zippo_ghost2'},
						  {function() return gameState.fuelPoured; end,			'actZoneCup3',			'FuelCan_ghost3'},
						  {function() return gameState.zippoUsed or
											not gameState.fuelPoured; end,		'actZoneCup3',			'Zippo_ghost3'},
						  {function() return gameState.fuelPoured; end,			'actZoneCup4',			'FuelCan_ghost4'},
						  {function() return gameState.zippoUsed or
											not gameState.fuelPoured; end,		'actZoneCup4',			'Zippo_ghost4'});


    ApplyLevelDump(restoringFromSave);
	SetZoneVisible(RootZoomZone, true, false);

	auxSceneInit(restoringFromSave);
	auxProcessToolObjectStateAnCursorType();
end

------------------------------------------------------------------------------
--
function OnSceneFree()
    FreeData()

	StopSound('L16S10');
	StopSound('L16S11');
	StopSound('L16S12');
end

--// Local auxiliary functions - - - - - - - - - - - - - - - - - - - - - - - -
function auxSceneInit(restoringFromSave)
    local initialActions = function()
		ShowLevelIntro(16);
    end
	local regularActions = function()
		if (gameState.fuelPoured == true and gameState.zippoUsed == true) then
			PlaySound('L16S12', true);
		else
			StopSound('L16S12');
		end

		gameState.customCursors['actZoneGates'] = {'CursorZoom'};

		auxStopAnimation('mechanismLeftAnimation', HGEANIM_FWD + HGEANIM_NOLOOP);
		auxStopAnimation('mechanismRightAnimation',HGEANIM_FWD + HGEANIM_NOLOOP);

		playField:IgnoreOnTestPoint('LayerOverX');

		playField:IgnoreOnTestPoint('chandelierLayer');
		playField:IgnoreOnTestPoint('chandelierChain');
		playField:IgnoreOnTestPoint('columnCrystalsGlow1');
		playField:IgnoreOnTestPoint('columnCrystalsGlow2');
		playField:IgnoreOnTestPoint('columnCrystalsGlow3');
		playField:IgnoreOnTestPoint('columnCrystalsGlow4');
		playField:IgnoreOnTestPoint('stainedGlassWindowGlow');
		playField:IgnoreOnTestPoint('gobletFlame1');
		playField:IgnoreOnTestPoint('gobletFlame2');
		playField:IgnoreOnTestPoint('gobletFlame3');
		playField:IgnoreOnTestPoint('gobletFlame4');
		playField:IgnoreOnTestPoint('gobletFlame1Glow');
		playField:IgnoreOnTestPoint('gobletFlame2Glow');
		playField:IgnoreOnTestPoint('gobletFlame3Glow');
		playField:IgnoreOnTestPoint('gobletFlame4Glow');
		auxSetFibrillationEffector(playField:GetObject('stainedGlassWindowGlow'), 0.75, 8.0);
		auxSetFibrillationEffector(playField:GetObject('gobletFlame1Glow'), 0.14);
		auxSetFibrillationEffector(playField:GetObject('gobletFlame2Glow'), 0.15);
		auxSetFibrillationEffector(playField:GetObject('gobletFlame3Glow'), 0.12);
		auxSetFibrillationEffector(playField:GetObject('gobletFlame4Glow'), 0.17);

--		auxAttachInPlace(playField:GetObject('gobletFlame1Glow'), playField:GetObject('gobletFlame1'));
--		auxAttachInPlace(playField:GetObject('gobletFlame2Glow'), playField:GetObject('gobletFlame2'));
--		auxAttachInPlace(playField:GetObject('gobletFlame3Glow'), playField:GetObject('gobletFlame3'));
--		auxAttachInPlace(playField:GetObject('gobletFlame4Glow'), playField:GetObject('gobletFlame4'));

		auxAttachInPlace(playField:GetObject('chandelierChain'), playField:GetObject('chandelierLayer'), false);
		auxAttachInPlace(playField:GetObject('Crystal_onPlace'), playField:GetObject('chandelierLayer'), false);

		gameState.chandelierInitPosY = playField:GetObject('chandelierLayer'):GetY();
		gameState.chandelierReflectionInitPosY = playField:GetObject('chandelierReflection'):GetY();
		gameState.leverTurnAngle = -30.0 /180.0*M_PI;
		gameState.chandelierShift = -400.0;

		playField:GetObject('frog'):SetVisible(false);

		auxCreateTempleHallAnimations(playField:GetObject('RootBackground'));
		auxPlayTempleHallAnimation('EnvTop');
		auxPlayTempleHallAnimation('Frog');
		auxPlayTempleHallAnimation('Bird1');
		auxPlayTempleHallAnimation('Bird2');
		auxPlayTempleHallAnimation('Bird3');
		auxPlayTempleHallAnimation('CrystalGlows');

		gameState.nextAnimationDelay = 0;

		gameState.chandelierIsMoving = false;
	end

    if (restoringFromSave == false) then
        initialActions();
	else
    end	
    regularActions();

	if (gameState.levelCompleted == true) then
		gameState.levelCompleted = false;
		auxTestLevelCompleteCondition();
	end
end


function auxProcessToolObjectStateAnCursorType()
    assert(	gameState.crystalOnPlace ~= nil and
			gameState.doorFragmentOnPlace ~= nil and
			gameState.pinionOnPlace ~= nil and
			gameState.fuelPoured ~= nil and
			gameState.zippoUsed ~= nil and
			gameState.leverOnPlace ~= nil and

			gameState.leverTurned ~= nil and
			gameState.chandelierIsMoving ~= nil and
			gameState.gatesMechanismIsActive ~= nil);

	if (gameState.crystalOnPlace == true) then
		RootZoomZone.UnhideObject('Crystal_onPlace');
		gameState.customCursors['actZoneCrystal'] = nil;
	else
		RootZoomZone.HideObject('Crystal_onPlace');
		gameState.customCursors['actZoneCrystal'] = {'CursorArms'};
	end

	if (gameState.doorFragmentOnPlace == true) then
		GatesZoomZone.UnhideObject('DoorFragment_onPlace');
		gameState.customCursors['actZoneDoorFragment'] = nil;
	else
		GatesZoomZone.HideObject('DoorFragment_onPlace');
		gameState.customCursors['actZoneDoorFragment'] = {'CursorArms'};
	end

	if (gameState.pinionOnPlace == true) then
		GatesZoomZone.UnhideObject('mechanismRightAnimation');
		gameState.customCursors['actZonePinion'] = nil;
		auxUpdateGatesMechanismState(gameState.doorFragmentOnPlace);
	else
		GatesZoomZone.HideObject('mechanismRightAnimation');
		gameState.customCursors['actZonePinion'] = {'CursorArms'};
	end

	if (gameState.fuelPoured == true and gameState.zippoUsed == true) then
		gameState.customCursors['actZoneCup1'] = nil;
		gameState.customCursors['actZoneCup2'] = nil;
		gameState.customCursors['actZoneCup3'] = nil;
		gameState.customCursors['actZoneCup4'] = nil;
		playField:GetObject('gobletFlame1'):SetVisible(true);
		playField:GetObject('gobletFlame2'):SetVisible(true);
		playField:GetObject('gobletFlame3'):SetVisible(true);
		playField:GetObject('gobletFlame4'):SetVisible(true);
		playField:GetObject('gobletFlame1Glow'):SetVisible(true);
		playField:GetObject('gobletFlame2Glow'):SetVisible(true);
		playField:GetObject('gobletFlame3Glow'):SetVisible(true);
		playField:GetObject('gobletFlame4Glow'):SetVisible(true);
	else
		gameState.customCursors['actZoneCup1'] = {'CursorArms'};
		gameState.customCursors['actZoneCup2'] = {'CursorArms'};
		gameState.customCursors['actZoneCup3'] = {'CursorArms'};
		gameState.customCursors['actZoneCup4'] = {'CursorArms'};
		playField:GetObject('gobletFlame1'):SetVisible(false);
		playField:GetObject('gobletFlame2'):SetVisible(false);
		playField:GetObject('gobletFlame3'):SetVisible(false);
		playField:GetObject('gobletFlame4'):SetVisible(false);
		playField:GetObject('gobletFlame1Glow'):SetVisible(false);
		playField:GetObject('gobletFlame2Glow'):SetVisible(false);
		playField:GetObject('gobletFlame3Glow'):SetVisible(false);
		playField:GetObject('gobletFlame4Glow'):SetVisible(false);
	end

	if (gameState.leverOnPlace == true) then
		RootZoomZone.UnhideObject('Lever_onPlace');
		if (gameState.chandelierIsMoving == false) then
			gameState.customCursors['actZoneLever'] = (gameState.leverTurned == true and nil or {'CursorArms'});
			auxUpdateLeverState(gameState.leverTurned);
		else
			gameState.customCursors['actZoneLever'] = nil;
		end
	else
		RootZoomZone.HideObject('Lever_onPlace');
		gameState.customCursors['actZoneLever'] = {'CursorArms'};
	end

	-- zoom-zones blocking
	if (gameState.pinionOnPlace == true and gameState.doorFragmentOnPlace == true) then
		gameState.customCursors['actZoneGates'] = nil;
		gameState.lockedObjects['actZoneGates'] = true;
	else
		gameState.customCursors['actZoneGates'] = {'CursorZoom'};
		gameState.lockedObjects['actZoneGates'] = nil;
	end
end

--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxOpenGatesMechanism()
	local anim1 = playField:GetObject('mechanismRightAnimation'):GetAnimation();
	local anim2 = playField:GetObject('mechanismLeftAnimation'):GetAnimation();
	local duration = auxGetAnimationDuration(anim1);

	gameState.gatesMechanismIsActive = true;
	TimerDoString('SetGameStateParameter(\'gatesMechanismIsActive\', false);', duration, playField:GetTimer());

	anim1:Stop();
	anim2:Stop();
	anim1:Play();
	anim2:Play();
end
function auxUpdateGatesMechanismState(unlocked)
	if (gameState.gatesMechanismIsActive == false) then
		local anim1 = playField:GetObject('mechanismRightAnimation'):GetAnimation();
		local anim2 = playField:GetObject('mechanismLeftAnimation'):GetAnimation();
		anim1:Stop();
		anim1:SetFrame(unlocked == true and anim1:GetFrames() - 1 or 0);
		anim2:Stop();
		anim2:SetFrame(unlocked == true and anim2:GetFrames() - 1 or 0);
	end
end

function auxTurnLever()
	local duration = 2.0;

	gameState.chandelierIsMoving = true;
	TimerDoString('SetGameStateParameter(\'chandelierIsMoving\', false);', duration, playField:GetTimer());

	local objChandelier = playField:GetObject('chandelierLayer');
	local objChandelierReflection = playField:GetObject('chandelierReflection');
	local objLever = playField:GetObject('Lever_onPlace');

	objChandelier:SetY(gameState.chandelierInitPosY);
	objChandelierReflection:SetY(gameState.chandelierReflectionInitPosY);
	objLever:SetAngle(0.0);

	objChandelier:Move(0.0, gameState.chandelierShift, duration);
	objChandelierReflection:Move(0.0, -gameState.chandelierShift, duration);
	objLever:Rotate(gameState.leverTurnAngle, 0.15 * duration);
end
function auxUpdateLeverState(turned)
	if (gameState.chandelierIsMoving == false) then
		local objChandelier = playField:GetObject('chandelierLayer');
		local objChandelierReflection = playField:GetObject('chandelierReflection');
		local objLever = playField:GetObject('Lever_onPlace');

		objChandelier:SetY(turned == true and gameState.chandelierInitPosY + gameState.chandelierShift or gameState.chandelierInitPosY);
		objChandelierReflection:SetY(turned == true and gameState.chandelierReflectionInitPosY - gameState.chandelierShift or gameState.chandelierReflectionInitPosY);
		objLever:SetAngle(turned == true and gameState.leverTurnAngle or 0.0);
	end
end

--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxUpdatePeriodicAnimations(dt)
	if (gameState.nextAnimationDelay == 0.0) then
		local animations = {};

		for compositionName, composition in pairs(templeHallCompositions) do
			if (composition:IsCyclic() == false) then
				table.insert(animations, composition:GetName());
			end
		end

		local animName;
		if (table.getn(animations) > 0) then
			animName = animations[math.random(1, table.getn(animations))];
		end
		if (animName ~= nil) then
			local composition = auxGetTempleHallAnimation(animName);

            if (composition ~= nil and composition:IsPaused() == true) then
				auxPlayTempleHallAnimation(animName);
			end
		end
		gameState.nextAnimationDelay = math.random(4, 11);
	else
		gameState.nextAnimationDelay = (gameState.nextAnimationDelay - dt >= 0.0 and gameState.nextAnimationDelay - dt or 0.0);
	end
end

--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxTestLevelCompleteCondition()
	if (gameState.leverTurned == true and

		gameState.allToolsApplied == true and
		gameState.levelCompleted == false and
		playField:GetLevelScreen():HasUncompletedTask() == false) then

		gameState.levelCompleted = true;
		TimerDoString('OnWin();', 2.0, playField:GetTimer());
	end
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

------------------------------------------------------------------------------
--
function OnDialogButtonPress(name, param)
end

------------------------------------------------------------------------------
--
function OnUpdate(dt)
    DefaultOnUpdate(dt);

	auxUpdatePeriodicAnimations(dt);
end

------------------------------------------------------------------------------
--
function OnWin()
	DefaultOnWin();
end

------------------------------------------------------------------------------
--
function OnObjectMouseEnter(object)
    local objectName = object:GetName();

    DefaultOnObjectMouseEnter(object);
	ActivateActiveZoneGlow(objectName);
end

------------------------------------------------------------------------------
--
function OnObjectMouseLeave(object)
    local objectName = object:GetName();

    DefaultOnObjectMouseLeave(object);
    DeactivateActiveZoneGlow(objectName);
end

------------------------------------------------------------------------------
--
function OnObjectMouseDown(object)
    local objectName = object:GetName();
    local isWrongClick = true;

	assert(gameState.activeZone ~= nil and gameState.locker:GetNReferences() > 0);

    if (gameState.lockedObjects[objectName] ~= true) then
        if (gameState.activeZone.HasObject(objectName)) then
            isWrongClick = DefaultOnZoomZoneActiveObjectClick(objectName);

			--// ...
			if (objectName == 'actZoneLever' and gameState.leverTurned == false) then
				if (gameState.crystalOnPlace == true and gameState.leverOnPlace) then
					gameState.leverTurned = true;
					PlaySound('L16S11');
					auxTurnLever();
					auxTestLevelCompleteCondition();
				else
					playField:GetLevelScreen():ShowTip(GetTextString('LEVEL16_HAVE_TO_FIX_TIP1'));
					return;
				end
			end

	        if (isWrongClick == true and playField:GetLevelScreen():IsTaskObject(objectName)) then
	            auxAttachInPlace(object, playField);
				object:ResetClippingRect();
				--// remove object from zoom-zone which contents it
				assert(gameState.activeZone.objects[objectName] ~= nil);
				gameState.activeZone.objects[objectName] = nil;

                playField:OnObjectFound(object);
                isWrongClick = false;
            end
        else
--			assert(gameState.activeZone ~= RootZoomZone and 
--				   gameState.locker:GetNReferences() > 1 and
--				   'Attempt to close root scene - you have clicked on an object which hasn`t been added to any zoom-zone');
            if (gameState.activeZone ~= RootZoomZone and gameState.locker:GetNReferences() > 1) then
                if (gameState.lockedObjects[gameState.activeZone.activeObject] == nil) then
                    SetZoneVisible(gameState.activeZone, false);
                end
            else
                Log('Lua: OnObjectMouseDown(\''..objectName..'\'): Was made click on object which hasn`t been attached to any zoom-zone');
            end
        end --// if (gameState.activeZone.HasObject(...
    end --// if (gameState.lockedObjects[...

	--// Tips - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	if ((objectName == 'actZoneCup1' or objectName == 'actZoneCup2' or objectName == 'actZoneCup3' or objectName == 'actZoneCup4') and
		 gameState.fuelPoured == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL16_FUEL_TIP1'));
	elseif ((objectName == 'actZoneCup1' or objectName == 'actZoneCup2' or objectName == 'actZoneCup3' or objectName == 'actZoneCup4') and
			 gameState.zippoUsed == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL16_LIGHTER_TIP1'));
	elseif (objectName == 'actZoneCrystal' and gameState.crystalOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL16_CRYSTAL_TIP1'));
	elseif (objectName == 'actZoneLever' and gameState.leverOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL16_LEVER_TIP1'));
	elseif (objectName == 'actZoneDoorFragment' and gameState.doorFragmentOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL16_GATE_PART_TIP1'));
	elseif (objectName == 'actZonePinion' and gameState.pinionOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL16_GATE_PINION_TIP1'));
	else
	    playField:GetLevelScreen():HideTip();
	end
	--//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

    DefaultOnObjectClick(object, isWrongClick, not playField:GetLevelScreen():IsTipShown());
    DefaultOnObjectMouseEnter(object);
end

------------------------------------------------------------------------------
--
function OnObjectMouseUp(object)
end

------------------------------------------------------------------------------
--
function OnObjectFound(object)
    local objectName = object:GetName();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	local objectMustBeHighlighted = DefaultOnObjectFound(object);
	return objectMustBeHighlighted;
end

------------------------------------------------------------------------------
--
function OnToolFound(tool)
end

------------------------------------------------------------------------------
--
function CanToolBeApplied(tool, object)
	local toolName = tool:GetName();
	local objName = object:GetName();
    local canToolBeApplied = true;
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	canToolBeApplied = DefaultCanToolBeApplied(tool, object);
	return canToolBeApplied;
end

------------------------------------------------------------------------------
--
function OnToolApply(tool, object)
	local toolName = tool:GetName();
	local objName = object:GetName();
    local toolApplied = false;

	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	if (toolName == 'Crystal' and objName == gameState.toolMap[toolName]) then
		gameState.crystalOnPlace = true;
		toolApplied = true;
	end
	if (toolName == 'DoorFragment' and objName == gameState.toolMap[toolName]) then
		gameState.doorFragmentOnPlace = true;
		toolApplied = true;
	end
	if (toolName == 'Pinion' and objName == gameState.toolMap[toolName]) then
		gameState.pinionOnPlace = true;
		toolApplied = true;
	end
	if (toolName == 'FuelCan' and (objName == gameState.toolMap[toolName] or 
								   objName == 'actZoneCup1' or 
								   objName == 'actZoneCup2' or
								   objName == 'actZoneCup3')) then
		gameState.fuelPoured = true;
		toolApplied = true;
		PlaySound('L16S10');
	end
	if (toolName == 'Zippo' and (objName == gameState.toolMap[toolName] or
								 objName == 'actZoneCup1' or 
								 objName == 'actZoneCup2' or
								 objName == 'actZoneCup3')) then
		if (gameState.fuelPoured == true) then
			gameState.zippoUsed = true;
			toolApplied = true;
			PlaySound('L16S12', true);
		else
		    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL16_HAVE_TO_POUR_FUEL'));
			return false;
		end
	end
	if (toolName == 'Lever' and objName == gameState.toolMap[toolName]) then
		gameState.leverOnPlace = true;
		toolApplied = true;
	end
	if (not toolApplied) then
	    playField:GetLevelScreen():ShowTip(GetTextString('WRONG_ITEM_APPLIED_TIP1'),
										   GetTextString('WRONG_ITEM_APPLIED_TIP2'));
	end

    assert(gameState.activeZone ~= nil);
    if (gameState.activeZone == GatesZoomZone and 
		(toolName == 'DoorFragment' or toolName == 'Pinion') and
		gameState.doorFragmentOnPlace == true and gameState.pinionOnPlace == true and 
		toolApplied == true) then

		auxOpenGatesMechanism();
		CloseAndBlockActiveZone();
    end


	if (gameState.crystalOnPlace == true and
		gameState.doorFragmentOnPlace == true and
		gameState.pinionOnPlace == true and
		gameState.fuelPoured == true and
		gameState.zippoUsed == true and
		gameState.leverOnPlace == true and
		gameState.allToolsApplied == false) then

		gameState.allToolsApplied = true;
		if (playField:GetLevelScreen():HasUncompletedTask() == true) then
		    playField:GetLevelScreen():ShowTip(GetTextString('HAVE_TO_FIND_ITEMS_MSG1'),
											   GetTextString('HAVE_TO_FIND_ITEMS_MSG2'));
		else
			auxTestLevelCompleteCondition();
		end
	end

	auxProcessToolObjectStateAnCursorType();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    DefaultOnObjectMouseEnter(object);
	if (toolApplied == true) then
	    DeactivateActiveZoneDeactivatedGlow(object:GetName());
	end
	return toolApplied;
end

------------------------------------------------------------------------------
--
function OnObjectReachPanel(object)
    local objectName = object:GetName();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	auxTestLevelCompleteCondition();
end

------------------------------------------------------------------------------
--
function OnButtonPress(zoneName)
    DefaultOnButtonPress(zoneName);
end

------------------------------------------------------------------------------
--
function OnMouseMove(prevMousePos, currentMousePos)
end

------------------------------------------------------------------------------
--
function OnSetTool(tool)
end

------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData()
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/background.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('RootBackground',anim,512,384,98,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/ape.png',0,0,84,110,1,0)
	anim:SetHotSpot(42,55)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('ape',anim,954,399,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/beads.png',0,0,60,76,1,0)
	anim:SetHotSpot(30,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('beads',anim,299,237,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/box.png',0,0,130,121,1,0)
	anim:SetHotSpot(65,60)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('box',anim,955,709,109,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/chandelier.png',0,0,138,114,1,0)
	anim:SetHotSpot(69,57)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('chandelier',anim,279,15,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/chest.png',0,0,144,70,1,0)
	anim:SetHotSpot(72,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('chest',anim,168,646,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/coin.png',0,0,63,38,1,0)
	anim:SetHotSpot(31,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('coin',anim,501,736,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/column.png',0,0,56,165,1,0)
	anim:SetHotSpot(28,82)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('column',anim,766,432,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/crystal.png',0,0,52,51,1,0)
	anim:SetHotSpot(26,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('crystal',anim,541,91,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/cup.png',0,0,105,98,1,0)
	anim:SetHotSpot(52,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('cup',anim,217,723,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/dino.png',0,0,209,137,1,0)
	anim:SetHotSpot(104,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('dino',anim,935,617,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/egg.png',0,0,42,55,1,0)
	anim:SetHotSpot(21,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('egg',anim,484,493,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/feather.png',0,0,63,138,1,0)
	anim:SetHotSpot(31,69)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('feather',anim,137,63,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/flowers.png',0,0,69,66,1,0)
	anim:SetHotSpot(34,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('flowers',anim,321,465,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/frog.png',0,0,163,68,1,0)
	anim:SetHotSpot(81,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('frog',anim,471,735,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/gem.png',0,0,32,50,1,0)
	anim:SetHotSpot(16,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('gem',anim,784,164,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/gorgon.png',0,0,78,123,1,0)
	anim:SetHotSpot(39,61)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('gorgon',anim,650,70,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/harp.png',0,0,121,110,1,0)
	anim:SetHotSpot(60,55)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('harp',anim,661,593,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/key.png',0,0,115,36,1,0)
	anim:SetHotSpot(57,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('key',anim,702,751,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/mask.png',0,0,63,90,1,0)
	anim:SetHotSpot(31,45)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('mask',anim,926,161,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/owl.png',0,0,88,79,1,0)
	anim:SetHotSpot(44,39)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('owl',anim,1000,49,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/papyrus.png',0,0,47,66,1,0)
	anim:SetHotSpot(23,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('papyrus',anim,195,430,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/peacock.png',0,0,65,129,1,0)
	anim:SetHotSpot(32,64)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('peacock',anim,708,499,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/pot.png',0,0,91,70,1,0)
	anim:SetHotSpot(45,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pot',anim,278,738,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/raven.png',0,0,94,66,1,0)
	anim:SetHotSpot(47,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('raven',anim,642,291,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/ruby.png',0,0,57,69,1,0)
	anim:SetHotSpot(28,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('ruby',anim,462,363,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/rug.png',0,0,100,114,1,0)
	anim:SetHotSpot(50,57)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('rug',anim,392,52,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/shield.png',0,0,44,73,1,0)
	anim:SetHotSpot(22,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shield',anim,842,332,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/spider.png',0,0,111,108,1,0)
	anim:SetHotSpot(55,54)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('spider',anim,854,22,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/statue.png',0,0,62,181,1,0)
	anim:SetHotSpot(31,90)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('statue',anim,246,546,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/sun.png',0,0,67,67,1,0)
	anim:SetHotSpot(33,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('sun',anim,682,406,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/sword.png',0,0,51,174,1,0)
	anim:SetHotSpot(25,87)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('sword',anim,540,203,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/tassel.png',0,0,33,103,1,0)
	anim:SetHotSpot(16,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('tassel',anim,876,471,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/terrestrialGlobe.png',0,0,104,91,1,0)
	anim:SetHotSpot(52,45)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('terrestrialGlobe',anim,433,644,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/tip.png',0,0,64,121,1,0)
	anim:SetHotSpot(32,60)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('tip',anim,1012,203,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/vase.png',0,0,140,145,1,0)
	anim:SetHotSpot(70,72)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('vase',anim,765,701,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Misc/wing.png',0,0,59,69,1,0)
	anim:SetHotSpot(29,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('wing',anim,641,431,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/chandelier.png',0,0,239,156,1,0)
	anim:SetHotSpot(119,78)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('chandelierLayer',anim,518,574,107,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/chandelierChain.png',0,0,8,645,1,0)
	anim:SetHotSpot(4,322)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('chandelierChain',anim,517,179,106,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/roundCarpet.png',0,0,264,98,1,0)
	anim:SetHotSpot(132,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('roundCarpet',anim,537,692,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/chandelier.png',0,0,239,156,1,0)
	anim:SetHotSpot(119,119)
	anim:SetBlendMode(2)
	anim:SetColor('0x40FFFFFF')
	play_field:CreateObject('chandelierReflection',anim,522,712,99,0,1,-1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverApe.png',0,0,72,137,1,0)
	anim:SetHotSpot(38,72)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverApe',anim,940,416,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverChest.png',0,0,179,85,1,0)
	anim:SetHotSpot(89,42)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverChest',anim,179,645,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverColumn.png',0,0,76,200,1,0)
	anim:SetHotSpot(38,100)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverColumn',anim,773,435,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverDino.png',0,0,153,118,1,0)
	anim:SetHotSpot(76,59)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverDino',anim,925,630,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverEgg.png',0,0,65,31,1,0)
	anim:SetHotSpot(32,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverEgg',anim,485,518,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverFlowers.png',0,0,42,103,1,0)
	anim:SetHotSpot(21,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverFlowers',anim,296,462,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverOwl.png',0,0,76,85,1,0)
	anim:SetHotSpot(38,42)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverOwl',anim,994,65,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/layerOverPeacock.png',0,0,45,145,1,0)
	anim:SetHotSpot(22,72)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('layerOverPeacock',anim,723,480,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverRug.png',0,0,59,222,1,0)
	anim:SetHotSpot(29,111)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverRug',anim,371,101,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverTerrestrialGlobe.png',0,0,47,44,1,0)
	anim:SetHotSpot(23,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverTerrestrialGlobe',anim,274,620,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverCupWithFlame1.png',0,0,82,24,1,0)
	anim:SetHotSpot(41,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverCupWithFlame1',anim,347,600,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverCupWithFlame2.png',0,0,130,30,1,0)
	anim:SetHotSpot(65,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverCupWithFlame2',anim,229,619,107,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverCupWithFlame3.png',0,0,84,20,1,0)
	anim:SetHotSpot(42,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverCupWithFlame3',anim,728,598,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Layers/LayerOverCupWithFlame4.png',0,0,132,26,1,0)
	anim:SetHotSpot(66,13)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverCupWithFlame4',anim,834,619,107,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF1060FF')
	play_field:CreateObject('columnCrystalsGlow1',anim,299,168,106,0,2.2,1.8)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF1060FF')
	play_field:CreateObject('columnCrystalsGlow2',anim,365,273,106,0,2.2,1.4)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF1060FF')
	play_field:CreateObject('columnCrystalsGlow3',anim,712,275,106,0,2.2,1.4)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF1060FF')
	play_field:CreateObject('columnCrystalsGlow4',anim,777,163,106,0,2.2,1.8)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF10AAFF')
	play_field:CreateObject('stainedGlassWindowGlow',anim,544,183,106,0,4,6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/fire1.png',0,0,86,128,31,14)
	anim:SetHotSpot(43,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xDDFFBBFF')
	play_field:CreateObject('gobletFlame1',anim,345,561,101,0,-0.9,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/Common/fire1.png',0,0,86,128,31,14)
	anim:SetHotSpot(43,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xDDFFBBFF')
	play_field:CreateObject('gobletFlame2',anim,224,551,106,0,1.6,1.6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/fire1.png',0,0,86,128,31,14)
	anim:SetHotSpot(43,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xDDFFBBFF')
	play_field:CreateObject('gobletFlame3',anim,727,563,101,0,0.9,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/Common/fire1.png',0,0,86,128,31,14)
	anim:SetHotSpot(43,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xDDFFBBFF')
	play_field:CreateObject('gobletFlame4',anim,832,555,106,0,-1.6,1.6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFAA00')
	play_field:CreateObject('gobletFlame1Glow',anim,343,558,103,0,2,2.5)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xEEFFAA00')
	play_field:CreateObject('gobletFlame2Glow',anim,219,529,108,0,3,4)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFAA00')
	play_field:CreateObject('gobletFlame3Glow',anim,715,561,103,0,2,2.5)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xEEFFAA00')
	play_field:CreateObject('gobletFlame4Glow',anim,825,533,108,0,3,4)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Crystal.png',0,0,38,52,1,0)
	anim:SetHotSpot(19,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Crystal',anim,540,47,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/DoorFragment.png',0,0,72,51,1,0)
	anim:SetHotSpot(36,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('DoorFragment',anim,404,607,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/FuelCan.png',0,0,63,68,1,0)
	anim:SetHotSpot(31,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('FuelCan',anim,656,613,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Lever.png',0,0,75,45,1,0)
	anim:SetHotSpot(37,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Lever',anim,830,747,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Pinion.png',0,0,75,44,1,0)
	anim:SetHotSpot(37,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Pinion',anim,537,686,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Zippo.png',0,0,64,70,1,0)
	anim:SetHotSpot(32,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Zippo',anim,852,683,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Crystal_onPlace.png',0,0,40,44,1,0)
	anim:SetHotSpot(20,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Crystal_onPlace',anim,602,555,106,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Lever_onPlace.png',0,0,50,43,1,0)
	anim:SetHotSpot(44,5)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Lever_onPlace',anim,956,581,106,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneCrystal',anim,587,572,108,0,0.8,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneLever',anim,956,607,107,0,0.6,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneCup1',anim,344,577,103,0,0.8,0.6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneCup2',anim,231,593,108,0,1.1,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneCup3',anim,730,577,103,0,0.8,0.6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneCup4',anim,834,594,108,0,1.1,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneGates',anim,547,442,101,0,1.1,1.3)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Zones/Gates/Layers/background.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('ZoomGatesBackground',anim,573,391,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Zones/Gates/Layers/mechanismRight.png',0,0,223,208,1,0)
	anim:SetHotSpot(111,104)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('mechanismRight',anim,683,410,204,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Zones/Gates/Layers/mechanismRightAnimation.png',0,0,223,205,16,12)
	anim:SetHotSpot(111,102)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('mechanismRightAnimation',anim,683,410,203,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Zones/Gates/Layers/mechanismLeftAnimation.png',0,0,137,228,16,12)
	anim:SetHotSpot(169,114)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('mechanismLeftAnimation',anim,548,426,203,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Zones/Gates/Layers/LayerOverX.png',0,0,136,194,1,0)
	anim:SetHotSpot(68,97)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('LayerOverX',anim,742,508,205,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/DoorFragment_onPlace.png',0,0,68,69,1,0)
	anim:SetHotSpot(34,34)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('DoorFragment_onPlace',anim,686,537,203,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZonePinion',anim,682,391,204,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneDoorFragment',anim,686,530,206,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/DoorFragment_ghost.png',0,0,90,90,1,0)
	anim:SetHotSpot(45,45)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('DoorFragment_ghost',anim,687,543,210,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Lever_ghost.png',0,0,64,64,1,0)
	anim:SetHotSpot(32,32)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Lever_ghost',anim,936,599,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Pinion_ghost.png',0,0,76,76,1,0)
	anim:SetHotSpot(38,38)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Pinion_ghost',anim,683,393,210,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Crystal_ghost.png',0,0,64,72,1,0)
	anim:SetHotSpot(32,36)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Crystal_ghost',anim,601,554,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Zippo_ghost.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Zippo_ghost1',anim,334,557,110,45,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/FuelCan_ghost.png',0,0,96,120,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('FuelCan_ghost1',anim,358,550,110,-30,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Zippo_ghost.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Zippo_ghost2',anim,206,575,110,45,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/FuelCan_ghost.png',0,0,96,120,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('FuelCan_ghost2',anim,249,570,110,-30,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Zippo_ghost.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Zippo_ghost3',anim,715,557,110,45,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/FuelCan_ghost.png',0,0,96,120,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('FuelCan_ghost3',anim,737,552,110,-30,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/Zippo_ghost.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Zippo_ghost4',anim,812,576,110,45,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/16_TempleHall/Items/FuelCan_ghost.png',0,0,96,120,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('FuelCan_ghost4',anim,860,571,110,-30,1,1)
end

function FreeData()
end
-- CLEAR_ON_SAVE_END
