dofile ('Data/Scripts/Common/Tools/Tools.lua')

function getToolGlobalTargets(toolName)
	if toolName == 'dog' then
		return {
				GlobalToolTarget('01_Boat_crash_site', toolName, 'area_apply_dog'),
				GlobalToolTarget('06_Town', toolName, 'area_apply_dog')
			   }
    elseif toolName == '01_wrench' then
		return {
				GlobalToolTarget('03_Panorama', toolName, 'area_apply_zr_wrench_1'),
				GlobalToolTarget('03_Panorama', toolName, 'area_apply_zr_wrench_2')
			   }
	elseif toolName == '05_coal' then
		return {
				GlobalToolTarget('04_Gazebo', toolName, 'area_apply_zr_coal_1'),
				GlobalToolTarget('04_Gazebo', toolName, 'area_apply_zr_coal_2')
			   }	
	elseif toolName == '01_ce_fish_bone_03_04_06' then
		return {
				GlobalToolTarget('03_CE_Cantellos_shop', toolName, 'area_apply_fish_bone'),
				GlobalToolTarget('04_CE_Lauras_room', 	 toolName, 'area_apply_fish_bone'),
				GlobalToolTarget('06_CE_Andreas_house',  toolName, 'area_apply_fish_bone')
			   }
	elseif toolName == '01_ce_fish_skull_02_05' then
		return {
				GlobalToolTarget('02_CE_Town', 			 toolName, 'area_apply_fish_skull'),
				GlobalToolTarget('05_CE_Bazar', 	 	 toolName, 'area_apply_fish_skull'),
			   }
	elseif toolName == '12_ce_gladius_09_10' then
		return {
				GlobalToolTarget('09_CE_Labyrinth', 	    toolName, 'area_apply_gladius'),
				GlobalToolTarget('10_CE_Field_near_temple', toolName, 'area_apply_gladius'),
			   }	  
	elseif toolName == '03_ce_broom_02_03' then
		return {
				GlobalToolTarget('03_CE_Cantellos_shop', 	 toolName, 'area_apply_broom'),
				GlobalToolTarget('02_CE_Town', 				 toolName, 'area_apply_broom'),
			   }	 
	end
	
	return nil
end

function getCollectionTools(toolName)
local collection_tools = 
	{		
		['number_key'] = 		 {tools = { '01_number_key_1', '02_number_key_2', '04_number_key_3'}},
		['binocular'] = 		 {tools = { '30_monocular_1', '14_monocular_2' }},	
	}

	for collection_name, obj in pairs(collection_tools) do
		obj.ind = obj.ind or 1
		if table.has_value(obj.tools, toolName) then
			return CollectionTool(obj.tools, obj.ind)
		end
	end
	return nil
end

function isUniqueTool(toolName)
	local unique_tools = {'dog'}
	
	for _, name_tool in pairs(unique_tools) do		
		if name_tool == toolName then
			return true
		end
	end	
	return false
end


function getUniqueNamedTool(toolName)
	local name_state = 'TOOL_NAME_' .. toolName:upper()
	if isUniqueTool(toolName) and HasGameState(name_state) then	
		return GetGameState(name_state):get(0)
	end

	return 'TOOL_HINT_' .. toolName:upper()
end

function decorateToolSprite(toolName, tool_picture, isBigPicture)
	local decorated_tools = 
	{
		['dog'] =
		{
			wnd = function()
				local entity = CreateVideoEntity("Data/Textures/Tools/dog/dog_tool_video.webm", true)
				entity:setLooped(true)
				entity:attachTo(tool_picture)
				tool_picture:setColor(1,1,1,0.001)
			end,
			inv = function()
				local entity = CreateSpriteEntity("Data/Textures/Tools/dog/dog_tool_seq.png")
				entity:setAnimationSize(64, 64)
				entity:setFPS(24)
				entity:setFramesCount(85)
				entity:setMode(_ANIM_LOOP)
				entity:play()
				entity:attachTo(tool_picture)
				tool_picture:setColor(1,1,1,0.001)
			end,
		},

		['01_fish'] =
		{
			wnd = function()
			
			end,
			inv = function()
				local entity = CreateSpriteEntity("Data/Textures/Tools/01_fish/fish_tool_seq.png")
				entity:setAnimationSize(65, 65)
				entity:setFPS(12)
				entity:setFramesCount(12)
				entity:setMode(_ANIM_LOOP)
				entity:play()
				entity:attachTo(tool_picture)
				tool_picture:setColor(1,1,1,0.001)
			end,
		},
	}

	if decorated_tools[toolName] then
		if isBigPicture then
			decorated_tools[toolName].wnd()
		else
			decorated_tools[toolName].inv()
		end
	end
end