
.namespace s13_SearchSite

function OnEnable()
	SearchSite.OnEnable()
	OPLog.Log("OnEnable unit "..self.Name)
	--On définit le nom du tableau
	if  SampleLevel.IsEqual("s13_search_1","unstarted") and SampleLevel.IsEqual("s13_search_1","unstarted") then 
	liste_13_01.Enabled = true
	liste_13_03.Enabled = true
	end
end

function OnEnter()
	if SampleLevel.IsEqual("s13_firstenter",true) then
		SequencePlayer.Enabled = true
		SequencePlayer.PlaySequence("GP_1301",nil,nil)
		--@ObjectManager.LaunchNewResearch("s13",3)
		SampleLevel.Set("s13_firstenter",false)
	end	
	if SampleLevel.IsEqual("s13_search_3","finished") and SampleLevel.IsEqual("s13_search_1","finished") then
		SequencePlayer.Enabled = true
		SequencePlayer.PlaySequence("GP_1304",s13_SearchSite,nil)
	end
end


function UpdateAll()
	
end

function OnPickObject(objname)
	if objname == "obj_coffre" then
	SampleLevel.Set("Page_7",true)
	PopupManager.OpenPopup("msg_ig_livre",nil,"Livre")
	end
	if objname == "obj_cage" then
	 SequencePlayer.Enabled = true
		SequencePlayer.PlaySequence("GP_1308",nil,nil)
	end
end

function OnSearchEnd(typesearch)
	if typesearch == 3 and SampleLevel.IsEqual("s13_search_1","unstarted") then
		InventoryManager.AddInInventory("InventoryIndicePort2","msg_ig_inventaire")
		InventoryIndicePort2.Equipped = true
		InventoryManager.RemoveFromInventory("InventoryIndicePort")
		SampleLevel.Set("s13_bouteille",true)
	elseif typesearch == 3 and SampleLevel.IsEqual("s13_search_1","finished") then
		InventoryManager.AddInInventory("InventoryIndicePort3","msg_ig_inventaire")
		InventoryIndicePort3.Equipped = true
		InventoryManager.RemoveFromInventory("InventoryIndicePort2")
	end
	if typesearch == 1 and SampleLevel.IsEqual("s13_search_3","unstarted") then
		SampleLevel.Set("Page_7",true)
		InventoryManager.AddInInventory("InventoryIndicePort2","msg_ig_inventaire")
		InventoryIndicePort2.Equipped = true
		InventoryManager.RemoveFromInventory("InventoryIndicePort")
		SampleLevel.Set("s13_medaillon",true)
	elseif typesearch == 1 and SampleLevel.IsEqual("s13_search_3","finished") then
		SampleLevel.Set("Page_7",true)
		InventoryManager.AddInInventory("InventoryIndicePort3","msg_ig_inventaire")
		InventoryIndicePort3.Equipped = true
		InventoryManager.RemoveFromInventory("InventoryIndicePort2")
	end
end
function OnPopupLeave(objname)

end
function OnSequenceEnd (keyword)
	if keyword == "GP_1302" and SampleLevel.IsEqual("s13_search_3","finished") and SampleLevel.IsEqual("s13_search_1","finished")  then
	SequencePlayer.Enabled = true
	SequencePlayer.PlaySequence("GP_1304",s13_SearchSite,nil)
	return true
	 
  end
  if keyword == "GP_1303" and SampleLevel.IsEqual("s13_search_3","finished") and SampleLevel.IsEqual("s13_search_1","finished")  then
	SequencePlayer.Enabled = true
	SequencePlayer.PlaySequence("GP_1304",s13_SearchSite,nil)
	return true
  end
    if keyword == "GP_1304" then
	NavigationManager.SwitchTo(nil,"s13_c01")
	return true
  end
end


function CondSpecificToFinish()

end

function OnPopupLeave(objname)
	if objname == "InventoryIndicePort2" and SampleLevel.IsEqual("s13_search_1","unstarted") then
		SequencePlayer.Enabled = true
		SequencePlayer.PlaySequence("GP_1302",s13_SearchSite,nil)
	elseif objname == "InventoryIndicePort2" and SampleLevel.IsEqual("s13_search_3","unstarted") then
		SequencePlayer.Enabled = true
		SequencePlayer.PlaySequence("GP_1303",s13_SearchSite,nil)
	end
	if objname == "InventoryIndicePort3" and SampleLevel.IsEqual("s13_bouteille",true) then
		SequencePlayer.Enabled = true
		SequencePlayer.PlaySequence("GP_1303",s13_SearchSite,nil)
	elseif objname == "InventoryIndicePort3"and SampleLevel.IsEqual("s13_medaillon",true) then
		SequencePlayer.Enabled = true
		SequencePlayer.PlaySequence("GP_1302",s13_SearchSite,nil)
	end
	
end