--
-- NIVA CK 5M
-- by Northern_Strike(RUS) for LSSA 
-- http://www.lsmods-rus.com & http://lssa.ru/
-- 20.12.11 
--

ZhZE5 = {};

source("dataS/scripts/vehicles/specializations/Cutter.lua");

function ZhZE5.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(Cutter, specializations);
end;

function ZhZE5:load(xmlFile)
	

end;

function ZhZE5:delete()
end;

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

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

function ZhZE5:update(dt)
	
	if self.setAnimationTime ~= nil then
		if self.reelStarted then
			self:setAnimationTime(1, 1);
			self:setAnimationTime(2, 1);
		else
			self:setAnimationTime(1, 0);
			self:setAnimationTime(2, 0);
		end;
	end;		
	
	if self.inrange then
		if InputBinding.isPressed(InputBinding.zhatkaHIGH) then
			self:setAnimationTime(3, self.animationParts[3].currentPosition+(self.animationParts[3].offSet+dt), false);
		elseif InputBinding.isPressed(InputBinding.zhatkaLOW) then
			self:setAnimationTime(3, self.animationParts[3].currentPosition-(self.animationParts[3].offSet+dt), false);
		end;
	end;
	
		if self.inrange then
			g_currentMission:addExtraPrintText("Planka: High/Low J/N ");
		end;
	
	
end;

function ZhZE5:updateTick(dt)
if g_currentMission.player ~= nil then
		-- Getting the distance between the player and the implement 
		local nearestDistance = 4.0; --max distance allowed
		local px, py, pz = getWorldTranslation(self.rootNode); 
		local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
		local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);	
		if distance < nearestDistance then
			self.inrange = true; 
		else
			self.inrange = false; 
		end;
end;
end;

function ZhZE5:draw()
end;

function ZhZE5:onDetach()
end;

function ZhZE5:onLeave()
end;