
-- by modelleicher
--

FendtAllrad = {};

function FendtAllrad.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(Motorized, specializations);
end;

function FendtAllrad:load(xmlFile)


		 
		 self.Allrad = false
		 
		 
	-- Allradwelle --
	self.GelenkF = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.Allradwelle.GelenkF#index"));
    self.Welle = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.Allradwelle.Welle#index"));    

	self.RotPoint = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.Allradwelle.RotPoint#index"));

		 
		 	
	
	-- Allrad Symbol--
	
	self.hudallrad_yesPosX = 0.77;
    self.hudallrad_yesWidth = 0.05;
    self.hudallrad_yesPosY = 0.22;
    self.hudallrad_yesHeight = 0.05;

	self.infoPanelAllradPath = Utils.getFilename("Textur/allrad_symb_yes.dds", self.baseDirectory);
	self.hudallrad_yesOverlay = Overlay:new("hudallrad_yesOverlay", self.infoPanelAllradPath, self.hudallrad_yesPosX, self.hudallrad_yesPosY, self.hudallrad_yesWidth, self.hudallrad_yesHeight);

	self.showHudallrad_yes = false;

				 
end;

function FendtAllrad:delete()

	  -- Allradsymbol --
    if self.hudallradyesOverlay ~= nil then
		self.hudallrad_yesOverlay:delete();
	end;
end;

function FendtAllrad:mouseEvent(posX, posY, isDown, isUp, button)
end;

function FendtAllrad:keyEvent(unicode, sym, modifier, isDown)
end;

function FendtAllrad:update(dt)

    if self:getIsActiveForInput() and self.isEntered then
    		
		if InputBinding.hasEvent(InputBinding.ALLRAD939) then
		   	if self.Allrad == false then
		   	   self.Allrad = true
		   	else
		   		self.Allrad = false
		   	end;
		end;

		
   		-- Allrad Symbol Status --
   		if self.Allrad == true then
					self.showHudallrad_yes = true
					else
					self.showHudallrad_yes = false
		end;
   		
		
		-- autoRotateBackSpeed -- Automatisches Zurückdrehen ausschalten --
		if self.steeringlocked == false then
		   self.autoRotateBackSpeed	= 2.5
		end;
		
		if self.steeringlocked == true then
		   self.autoRotateBackSpeed = 0.0
		end;

		-- Allrad -- driveMode 2 = Allrad , driveMode 0 = kein Antrieb --
		if self.Allrad == true then
		 	self.wheels[1].driveMode =2
		 	self.wheels[2].driveMode =2
		 	self.wheels[3].driveMode =2
		 	self.wheels[4].driveMode =2
		else
		 	self.wheels[1].driveMode =0
		 	self.wheels[2].driveMode =0
		 	self.wheels[3].driveMode =2
		 	self.wheels[4].driveMode =2
		end;
		
	   -- Allradwelle --
	   if self.Allrad == true then
	   self.PointRot = getRotation(self.RotPoint)

       setRotation(self.GelenkF,0 ,0 ,self.PointRot);
       setRotation(self.Welle,0 ,0 ,self.PointRot);
	   end;
	   				
	end;			 

end;

function FendtAllrad:draw()
		
  	if self.showHudallrad_yes and self.isEntered then
		self.hudallrad_yesOverlay:render();
	end;

end;

