
.namespace s05_SearchSite

function OnEnable()
	SearchSite.OnEnable()
	OPLog.Log("OnEnable unit "..self.Name)
	if  SampleLevel.IsEqual("s05_search_1","unstarted") then 
	liste_s05_1.Enabled = true
	s05_darkmask.Enabled = false
	s05_fulldark.Enabled = true
	fulldark_hotspot.Enabled = true
	end

end

function OnEnter()
		if SampleLevel.IsEqual("s05_search_1","finished") then
			-- SearchInterface.Enabled = false
		InventoryLampeTorcheOn.Equipped = false
		NavigationManager.SwitchTo(nil,"Map_parent")
			
			end
		
		if SampleLevel.IsEqual("s05_lampe",true) then
			s05_darkmask.Enabled = true
			s05_fulldark.Enabled = false
			fulldark_hotspot.Enabled = false
			liste_1.Enabled = true
			liste_1_hotspot.Enabled = true
			PlaySoundEffect("gmp_torch")
		
		else

			if InventoryLampeTorcheOff.Equipped == true or InventoryLampeTorcheOn.Equipped == true then
				SequencePlayer.Enabled = true
				SequencePlayer.PlaySequence("GP_500",nil,nil)
			else
				SequencePlayer.Enabled = true
				SequencePlayer.PlaySequence("GP_501",nil,nil)
			end
			
			
		end
	
end


function UpdateAll()
	
end

function OnPickObject(objname)
	if objname == "obj_boule_de_crystale" then
	SampleLevel.Set("Page_1",true)
	PopupManager.OpenPopup("msg_ig_livre",nil,"Livre")
	-- SequencePlayer.Enabled = true
	-- SequencePlayer.PlaySequence("GP_504",nil,nil)
	end
end

function OnTakeList(typeliste)
	OPLog.Log("Hello world")
end
function OnSearchEnd(typesearch)
		if typesearch == 1 then
			-- s05_SearchSite.Enabled = false
			SampleLevel.Set("Page_1",true)
			-- Map_parent.Enabled = true 
			InventoryManager.AddInInventory("InventoryMap","msg_ig_inventaire")	
			InventoryMap.Equipped = true
			
				-- for i=1,17 do
					-- if i > 9 then
						-- s="s"
					-- else 
						-- s="s0"
					-- end
					-- UserData.Set(s..i.."_discovered",false)
				-- end
			-- SaveManager.saveGame("Profil"..ProfilConfig.Get("CurrentProfil"))	
			
		end
end

function CondSpecificToFinish()

end

function OnPopupLeave(objname)
	if objname == "InventoryMap" then
		-- SearchInterface.Enabled = false
		InventoryLampeTorcheOn.Equipped = false
		NavigationManager.SwitchTo(nil,"Map_parent")
	end
end
	
function UpdateUnit()
	
	if SampleLevel.IsEqual("s05_lampe",true)  then
		local x,y = Cursor.GetCursorPosition()
		s05_darkmask.Position_X = x - (s05_darkmask.Dimension_Width/2) * s05_darkmask.Scale_X
		s05_darkmask.Position_Y = y - (s05_darkmask.Dimension_Height/2) * s05_darkmask.Scale_Y
	end
end

function OnDocumentUse(docname)
	if docname == "InventoryLampeTorcheOff" then
	SequencePlayer.Enabled = true
		SequencePlayer.PlaySequence("GP_505",nil,nil)
		return true
	end
	if docname == "InventoryLampeTorcheOn" then
		s05_darkmask.Enabled = true
		s05_fulldark.Enabled = false
		fulldark_hotspot.Enabled = false
		liste_s05_1.Enabled = true
		SampleLevel.Set("s05_lampe",true)
		PlaySoundEffect("gmp_torch")
		InventoryLampeTorcheOn.Equipped = false
		SequencePlayer.Enabled = true
		SequencePlayer.PlaySequence("GP_506",nil,nil)
		return true
	end
	return false
end
