--Specjalizacja dla : mtz 82
--#Autor: Dj Tedex
--#Pomoc: Asd4&Maciusbpss1
--#data: 20.10.2011 r.
--
--

mtz82 = {};


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

function mtz82:load(xmlFile)
local drzwip = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.drzwip#index"));
if drzwip ~= nil then
 self.drzwip = drzwip;
end;

local drzwil = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.drzwil#index"));
if drzwil ~= nil then
 self.drzwil = drzwil;
end;
end;
 function mtz82:delete()
end;
function mtz82:keyEvent(unicode, sym, modifier, isDown)
 end;
 
 





function mtz82:update(dt)
 if self:getIsActiveForInput() then
  if InputBinding.isPressed(InputBinding.Ciegnaup) then
              self:setAnimationTime(1, self.animationParts[1].currentPosition+(self.animationParts[1].offSet+dt), false);
          elseif InputBinding.isPressed(InputBinding.Ciegnadown) then
              self:setAnimationTime(1, self.animationParts[1].currentPosition-(self.animationParts[1].offSet+dt), false);
           end;
		   
		if InputBinding.hasEvent(InputBinding.Szyba_tyl) then
			if self.animationParts[4].clipEndTime then
				self:setAnimationTime(4, self.animationParts[4].offSet);
			elseif self.animationParts[4].clipStartTime then
				self:setAnimationTime(4, self.animationParts[4].animDuration);
			end;
		end; 
      if InputBinding.hasEvent(InputBinding.wajchawom) then
			if self.animationParts[5].clipEndTime then
				self:setAnimationTime(5, self.animationParts[5].offSet);
			elseif self.animationParts[5].clipStartTime then
				self:setAnimationTime(5, self.animationParts[5].animDuration);
			end;
		end;   		
	end;

	
 local nearestDistance = 2.1;
 local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
 
 local px, py, pz = getWorldTranslation(self.drzwip); 
 local distance = Utils.vector3Length(px-vx, py-vy, pz-vz); 
 if distance < nearestDistance then
  self.przydrzwip = true; 
 else
  self.przydrzwip = false; 
 end;
 
if self.przydrzwip or self.isEntered then
 if InputBinding.hasEvent(InputBinding.drzwip) then
  if self.animationParts[2].clipEndTime then
   self:setAnimationTime(2, self.animationParts[2].offSet);
  elseif self.animationParts[2].clipStartTime then
   self:setAnimationTime(2, self.animationParts[2].animDuration);
  end;
 end;
	end;	   
 local rx, ry, rz = getWorldTranslation(self.drzwil); 
 local distance = Utils.vector3Length(rx-vx, ry-vy, rz-vz); 
 if distance < nearestDistance then
  self.przydrzwil = true; 
 else
  self.przydrzwil = false; 
 end;
 if self.przydrzwil or self.isEntered then
 if InputBinding.hasEvent(InputBinding.drzwil) then
  if self.animationParts[3].clipEndTime then
   self:setAnimationTime(3, self.animationParts[3].offSet);
  elseif self.animationParts[3].clipStartTime then
   self:setAnimationTime(3, self.animationParts[3].animDuration);
  end;
 end;
end;
  if self.przydrzwip then
if self.animationParts[2].clipStartTime then
  g_currentMission:addExtraPrintText(string.format("%s: Otworz prawe drzwi", InputBinding.getKeyNamesOfDigitalAction(InputBinding.drzwip)));
 else
  g_currentMission:addExtraPrintText(string.format("%s: Zamknij prawe drzwi", InputBinding.getKeyNamesOfDigitalAction(InputBinding.drzwip)));
 end;
end;
 
   if self.przydrzwil then
if self.animationParts[3].clipStartTime then
  g_currentMission:addExtraPrintText(string.format("%s: Otworz lewe drzwi", InputBinding.getKeyNamesOfDigitalAction(InputBinding.drzwil)));
 else
  g_currentMission:addExtraPrintText(string.format("%s: Zamknij lewe drzwi", InputBinding.getKeyNamesOfDigitalAction(InputBinding.drzwil)));
 end;
end;

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

function mtz82:validateAttacherJoint(implement, jointDesc, dt)
    return true;
end;
function mtz82:draw()
	end;




    


	
  


