

.namespace SequenceZone


--c'est une area qui enclenche un dialogue j'imagine
function OnEnable()
	self.CurrentManager = GetCurrentManager()
	self.GameVariables = GameVariables
	self.Conditions = Conditions
	self.FlagsFunctions = FlagsFunctions
end


function OnWbpMouseLDown(x,y)
	if self.CanClickOn() then
		SequencePlayer.Enabled = true
		if self.SeqToPlay~="" then
			SequencePlayer.PlaySequence(self.SeqToPlay, self.CurrentManager)
		else
			SequencePlayer.PlaySequence(self.Name, self.CurrentManager)
		end
		self.isPlayed=true
		return true
	end
end


function CompareFlag( p_flag )
	return self.FlagsFunctions.CompareFlag( p_flag, nil, self.Name )
end


function AddFlag( p_flag )
	self.FlagsFunctions.AddFlag( p_flag, nil, self.Name )
end


function SubFlag( p_flag )
	self.FlagsFunctions.SubFlag( p_flag, nil, self.Name )
end


function OnUpdateAll()
	if self.CompareFlag(AREA_FOUND) then
		self.Flags_Visible = true
	end
	if self.CompareFlag(AREA_RESOLVED) then
		self.Flags_Visible = false
	end
end


function SetCursor()
	if self.CanClickOn() then
		OPUnitFactory.GetUnit("Cursor","Cursor").ChangeCursor(CURSOR_AREA_INFO)
	
		if not self.CompareFlag(AREA_FOUND) then
			self.AddFlag(AREA_FOUND)
			self.CurrentManager.OnUpdate()
		end
		return true
	end
	
	return false
end


function Resolve()
	self.AddFlag( AREA_RESOLVED )
	if self.CurrentManager.OnAreaResolved~=nil then
		self.CurrentManager.OnAreaResolved(self.Name)
	end
end


function CanClickOn()
	local res = self.Flags_Visible
	
	if self.PrivateCanClickOn ~= nil then
		res = res and self.PrivateCanClickOn()
	end	
	return res
end

