class 'l_06_Town_Z_Bench' (ZoomZone)

function l_06_Town_Z_Bench:__init(name, mode, PlayField)
	ZoomZone.__init(self, name, mode, PlayField)
	 self:entityHide('area_find_handle','aggressive_manul','area_find_button','manul_runaway', 'zb_button_2')

	-----------------------------------------------------------------------

	self:registerBBT('area_BBT_handle', 'BBT_02_HANDLE')

	do -- apply screwdriver
		local apply_screwdriver_counter = 2	
		local function on_apply_zr_screwdriver(e)
		    self:entityHide(e.target)
		    local i = string.sub(e.target, -1)
		    
		    if not e.save then
		    	self:playSound('06_apply_screwdriver')
		        self:entityFadeHide('screw'..i)
		    else
		        self:entityHide('screw'..i)
		    end
		    
		    apply_screwdriver_counter = apply_screwdriver_counter - 1
		    if apply_screwdriver_counter<=0 then
		        self:entityShow('area_find_handle')
		        self:entityHide('area_BBT_handle')
		    end
		end
		self:registerToolApplyInfo('09_screwdriver', {'area_apply_screwdriver_1', 'area_apply_screwdriver_2'}, on_apply_zr_screwdriver, 'BBT_06_NEED_SCREWDRIVER')
	end

	-- find tool -----------------------------------------------------------
	do
		local function on_find_handle(event)
			self:entityHide('slat')
			self.playfield:entityShow('Layer_cover_handle')
			if  IsToolFound ('06_bridge_button')	then
				self:closeAndDisable()
			end
		end

		self:registerToolFindInfo('06_handle','area_find_handle', on_find_handle)
	end
	------------------------------------------------------------------------
	do
		local function on_apply_dog(e)
		    self:entityHide(e.target)
		    self.playfield:entityHide('Cover_maunl','Layer_manul')
		    if not e.save then
		    	local dog  = createVideo({video = 'dog',  order = 601, x = 617, y = 478, isLooped = false, isAlpha = true, parent = self:getEntityAnchor()})
		        dog:play()
		        self:playSound('06_dog')
		        dog.onFinish:add(function() 
		        	dog:hide()
		        	    self:entityFadeShow('zb_button_2')
		        	    self:entityFadeHide('zb_button')
		    			self:entityShow('area_find_button')
		        				end)
		        self:entityFadeHide('idle_manul')
		        self:getEntityNamed('manul_runaway'):show()
		    	
		    	local manul_runaway = self:getEntityNamed('manul_runaway')
		    	manul_runaway:stop()
		    	manul_runaway:play()
		    	self.mouseBlocker:push()
				manul_runaway.onFinish:add(function() 
		            						self.mouseBlocker:pop()	
        									end)

			else
				self:entityShow('area_find_button')
				self:entityHide('idle_manul')	
        	    self:entityShow('zb_button_2')
		        self:entityHide('zb_button')
		    end
		end
		local info = self:registerToolApplyInfo('dog', 'area_apply_dog', on_apply_dog, 'BBT_02_BUTTON')

		local aggressive_manul = self:getEntityNamed('aggressive_manul')
		aggressive_manul:stop()
		aggressive_manul.onFinish:add(function() 
            self.mouseBlocker:pop()	
            self:entityFadeShow('idle_manul')
            self.timer:add( function()						  	
           						self:entityFadeHide('aggressive_manul')
						    end, 0.3)
        
        end)
        
		info.on_target_click = function ()
			self:entityFadeShow('aggressive_manul')			
			self.timer:add( function() 
								self:entityFadeHide('idle_manul')
	                        end, 0.3)   
			self.mouseBlocker:push()
			aggressive_manul:play()
			self:playSound('06_aggressive_manul')
			
			local dog_barking  = createVideo({video = 'dog_barks' , order = 600, x = 752, y = 544, isLooped = false, isAlpha = true, parent = self:getEntityAnchor()})
			dog_barking:play()
			self:playSound('06_dog_barks')
		    dog_barking.onFinish:add( function() 
		        						dog_barking:hide()
		        					  end)
		end
	end	

	do  -- button found
		local function on_find_button(event)
			self:entityHide('zb_button_2')	
			if IsToolFound('06_handle') then
				self:closeAndDisable()
			end
		end

		self:registerToolFindInfo('06_bridge_button','area_find_button', on_find_button)
	end
end

function l_06_Town_Z_Bench:onOpenFinished()
	if not HasGameState('06_dog_barks', 'true') then
		self.mouseBlocker:push()
				SetGameState('06_dog_barks', 'true')
				local dog_barking  = createVideo({video = 'dog_barks' , order = 600, x = 752, y = 544, isLooped = false, isAlpha = true, parent = self:getEntityAnchor()})
				dog_barking:play()
				self:playSound('06_dog_barks')
			    dog_barking.onFinish:add( function() 
			        						dog_barking:hide()
				self.mouseBlocker:pop()	
			        					  end)

	end	
end
--------------------------------------------------------------------------------
--                      GENERATED CONTENT. DO NOT EDIT.                       --
--------------------------------------------------------------------------------

function l_06_Town_Z_Bench:CreateLoaderTable()
	local objects =
	{
		{ name = 'Bg',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/Bg.jpg',  width = 640,  height = 480,  },
		{ name = 'slat',  entityType = 'SpriteEntity',  x = 595,  y = 367,  order = 10,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/slat.png',  width = 438,  height = 112,  },
		{ name = 'screw1',  entityType = 'SpriteEntity',  x = 461.5,  y = 386.5,  order = 11,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/screw1.png',  width = 29,  height = 25,  },
		{ name = 'screw2',  entityType = 'SpriteEntity',  x = 774,  y = 330,  order = 11,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/screw2.png',  width = 26,  height = 26,  },
		{ name = 'list3png',  entityType = 'SpriteEntity',  x = 297.5,  y = 603,  order = 2,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/list3png.png',  width = 97,  height = 40,  },
		{ name = 'list2',  entityType = 'SpriteEntity',  x = 239,  y = 582,  order = 1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/list2.png',  width = 44,  height = 60,  },
		{ name = 'list1',  entityType = 'SpriteEntity',  x = 193,  y = 549,  order = 1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/list1.png',  width = 50,  height = 96,  },
		{ name = 'bush',  entityType = 'SpriteEntity',  x = 294,  y = 451,  order = 3,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/bush.png',  width = 210,  height = 168,  },
		{ name = 'foliage',  entityType = 'SpriteEntity',  x = 331,  y = 152,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/foliage.png',  width = 164,  height = 94,  },
		{ name = '06_Town_Anim_Z_Bench',  entityType = 'CompositionContainer',  x = 192,  y = 144,  order = 2,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  path = 'Data/Scripts/Scenes/06_Town/Anim/06_Town_Anim_Z_Bench.lua',  },
		{ name = 'compositionZoom_Bench',  entityType = 'CompositionSequence',  parentName = '06_Town_Anim_Z_Bench',  x = 0,  y = 0,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'zb_cover',  entityType = 'SpriteEntity',  x = 534,  y = 420,  order = 5,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/zb_cover.png',  width = 294,  height = 193,  },
		{ name = 'zb_button',  entityType = 'SpriteEntity',  x = 581,  y = 501,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/zb_button.png',  width = 40,  height = 27,  },
		{ name = 'idle_manul',  entityType = 'VideoEntity',  x = 507,  y = 445,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  path = 'Data/Video/Scenes/06_Town/idle_manul.webm',  hasAlpha = true,  isLooped = true,  fps = 24,  },
		{ name = 'aggressive_manul',  entityType = 'VideoEntity',  x = 540,  y = 435,  order = 6,  editingLocked = false,  treeItemIsExpanded = false,  path = 'Data/Video/Scenes/06_Town/aggressive_manul.webm',  hasAlpha = true,  isLooped = false,  fps = 24,  },
		{ name = 'area_apply_screwdriver_1',  entityType = 'SpriteEntity',  x = 465,  y = 387,  order = 31,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_apply_screwdriver_2',  entityType = 'SpriteEntity',  x = 764,  y = 329,  order = 31,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_find_handle',  entityType = 'SpriteEntity',  x = 586,  y = 358,  order = 30,  angle = -12,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 500,  height = 100,  },
		{ name = 'area_apply_dog',  entityType = 'SpriteEntity',  x = 536.112,  y = 470.54,  order = 30,  angle = -12,  scaleX = 0.862774,  scaleY = 0.587453,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 96.5987, y = 97.1485},  width = 193,  height = 194,  },
		{ name = 'area_BBT_handle',  entityType = 'SpriteEntity',  x = 589.584,  y = 369.441,  order = 30,  angle = -12,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 250, y = 42.3947},  width = 500,  height = 85,  },
		{ name = 'manul_runaway',  entityType = 'VideoEntity',  x = 467,  y = 456,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  path = 'Data/Video/Scenes/06_Town/manul_runaway.webm',  hasAlpha = true,  isLooped = false,  fps = 24,  },
		{ name = 'area_find_button',  entityType = 'SpriteEntity',  x = 638,  y = 524,  order = 31,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 50, y = 50},  width = 120,  height = 120,  },
		{ name = 'ol',  entityType = 'SpriteEntity',  x = 277,  y = 539,  order = 1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/ol.png',  width = 172,  height = 182,  },
		{ name = 'zb_button_2',  entityType = 'SpriteEntity',  x = 639,  y = 541,  order = 0,  scale = 1.3,  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 20, y = 13.5},  texturePath = 'Data/Textures/Scenes/06_Town/Z_Bench/zb_button.png',  width = 40,  height = 27,  },
	}
	return objects
end
