
.namespace AreaCloseup

function OnEnable()
	self.CurrentManager = GetCurrentManager()
	self.GameVariables = GameVariables
	self.Conditions = Conditions
	self.FlagsFunctions = FlagsFunctions
end


function OnWbpMouseLDown(x,y)
	if self.CanClickOn() then
		self.Destination.ParentArea=self
		
		--Si un callback PrivateSwitchTo existe, alors on utilise ce callback plutot que le Switch du navigation Manager.
		if self.PrivateSwitchTo ~= nil then
			self.PrivateSwitchTo(self.CurrentManager,self.Destination.Name)
		else
			NavigationManager.SwitchTo(self.CurrentManager,self.Destination.Name)
		end
		
		return true
    end
end

function SetCursor()
	if self.CanClickOn() then
		OPUnitFactory.GetUnit("Cursor","Cursor").ChangeCursor(CURSOR_AREA_CLOSEUP)
		
		return true
	end
	
	return false
end

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

