--
-- FoldingBoards
-- author: Burner
-- date: 23.08.2012
--

FoldingBoards = {};

function FoldingBoards.prerequisitesPresent(specializations)
	return true;
end;

function FoldingBoards:load(xmlFile)
	self.itemInRange = FoldingBoards.itemInRange;
end;

function FoldingBoards:delete()
end;

function FoldingBoards:update(dt)
	if self.isClient then
		if self:itemInRange(self.animationParts[1].rootNode) then
			if InputBinding.isPressed(InputBinding.BURT_DOWN) then
				self:setAnimationTime(1, self.animationParts[1].currentPosition+(self.animationParts[1].offSet+dt), false);
			elseif InputBinding.isPressed(InputBinding.BURT_UP) then
				self:setAnimationTime(1, self.animationParts[1].currentPosition-(self.animationParts[1].offSet+dt), false);
			end;
			g_currentMission:addExtraPrintText(string.format(""..InputBinding.getKeyNamesOfDigitalAction(InputBinding.BURT_DOWN) .. " / " .. InputBinding.getKeyNamesOfDigitalAction(InputBinding.BURT_UP)..": "..g_i18n:getText("BURT_DOWN_UP")..""));
		elseif self:itemInRange(self.animationParts[2].rootNode) then
			if InputBinding.isPressed(InputBinding.BURT_DOWN) then
				self:setAnimationTime(2, self.animationParts[2].currentPosition+(self.animationParts[2].offSet+dt), false);
			elseif InputBinding.isPressed(InputBinding.BURT_UP) then
				self:setAnimationTime(2, self.animationParts[2].currentPosition-(self.animationParts[2].offSet+dt), false);
			end;
			g_currentMission:addExtraPrintText(string.format(""..InputBinding.getKeyNamesOfDigitalAction(InputBinding.BURT_DOWN) .. " / " .. InputBinding.getKeyNamesOfDigitalAction(InputBinding.BURT_UP)..": "..g_i18n:getText("BURT_DOWN_UP")..""));
		elseif self:itemInRange(self.animationParts[3].rootNode) then
			if InputBinding.isPressed(InputBinding.BURT_DOWN) then
				self:setAnimationTime(3, self.animationParts[3].currentPosition+(self.animationParts[3].offSet+dt), false);
			elseif InputBinding.isPressed(InputBinding.BURT_UP) then
				self:setAnimationTime(3, self.animationParts[3].currentPosition-(self.animationParts[3].offSet+dt), false);
			end;
			g_currentMission:addExtraPrintText(string.format(""..InputBinding.getKeyNamesOfDigitalAction(InputBinding.BURT_DOWN) .. " / " .. InputBinding.getKeyNamesOfDigitalAction(InputBinding.BURT_UP)..": "..g_i18n:getText("BURT_DOWN_UP")..""));
		end;
	end;
end;

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

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

function FoldingBoards:draw()
end;

function FoldingBoards:itemInRange(object)
	if g_currentMission.player ~= nil and object ~= nil then
		local nearestDistance = 2;
		local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
		local px, py, pz = getWorldTranslation(object); 
		local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);	
		if distance < nearestDistance then
			return true;
		else
			return false;
		end;
	else
		return false;
	end;
end;

function FoldingBoards:onAttach(attacherVehicle)
end;

function FoldingBoards:onDetach()
end;

function FoldingBoards:onDeactivate()
end;

function FoldingBoards:onDeactivateSounds()
end;

function FoldingBoards:onLeave()
end;