---Plug
---LEMKEN 3

-----[[[[[Author]]]]]]--------
-----MAJSTER2009

lemken = {};

function lemken.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(Plough, specializations);
end;
function lemken:load(xmlFile)
 local rotationPartNodekolo = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.kolo#index"));
    if rotationPartNodekolo ~= nil then
        self.rotationPartkolo = {};
        self.rotationPartkolo.node = rotationPartNodekolo;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartkolo#minRot"));
        self.rotationPartkolo.minRot = {};
        self.rotationPartkolo.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkolo.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkolo.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.kolo#maxRot"));
        self.rotationPartkolo.maxRot = {};
        self.rotationPartkolo.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkolo.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkolo.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartkolo.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.kolo#rotTime"), 2)*1000;
        self.rotationPartkolo.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.kolo#touchRotLimit"), 10));
    end;	          

end;

function lemken:delete()
end;


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

function lemken:keyEvent(unicode, sym, modifier, isDown)
	
 if isDown and sym == Input.KEY_b then 
		self.rotationMaxkolo = not self.rotationMaxkolo;
	end;	
end;


function lemken:update(dt)
	
if self.rotationPartkolo ~= nil then
	local x, y, z = getRotation(self.rotationPartkolo.node);
	local rot = {x,y,z};
	local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartkolo.maxRot, self.rotationPartkolo.minRot, 3, self.rotationPartkolo.rotTime, dt, not self.rotationMaxkolo);
	setRotation(self.rotationPartkolo.node, unpack(newRot));
end	
	


end;


 function lemken:draw()

end; 

function lemken:onDetach()

end;


function lemken:onAttach()
		
end; 


