--kompass
--by Bullgore80


kompass = {};

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

function kompass:load(xmlFile)

    self.pipeLight = nil
    if self.pipeLight ~= nil then
	setVisibility(self.pipeLight, false);
    end;
    self.pipeLightActive = false;
    self.balcamera = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.balcamera#index"));
    self.jobbcamera = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.jobbcamera#index"));
    end;	

function kompass:delete()

end;

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

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

function kompass:update(dt)

	if self.isEntered then


    				--Kompass
	local x,y,z = localDirectionToWorld(self.rootNode, 0, 0, 1);
	local length = Utils.vector2Length(x,z);
	local dX = x/length;
	local dZ = z/length;
	local Richtung = math.deg(math.atan2(dX,dZ));
	if Richtung < 0  then 
		Richtung = 360 - (Richtung * -1);
    end;
	renderText(0.71,0.015,0.03,string.format("%3.0f ",360 - math.floor(Richtung + 0.5) ));
	
	
   		
		end;
	
        	

end;

function kompass:draw()  
end;

function kompass:onEnter()

    self.lepcsoMax = true;

end;

function kompass:onLeave()

    if self.pipeLight ~= nil then
    	setVisibility(self.pipeLight, false);
    end;
	
end;

