forcaExtraElevazione = {};
function forcaExtraElevazione.prerequisitesPresent(specializations) return true; end;
function forcaExtraElevazione:load(xmlFile) 
	self.setsceltaPunteC = SpecializationUtil.callSpecializationsFunction("setsceltaPunteC"); self.sceltaPunteC = 3; self.posizione = true; 
	self.tubiIdraulici = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.tubiIdraulici#index")); self.currentBalle = -1; self.currentSupport = true; self.balesAttached = false; self.currentPosizione = 2; end;
function forcaExtraElevazione:readStream(streamId, connection) self:setsceltaPunteC(streamReadInt8(streamId), true); end;
function forcaExtraElevazione:writeStream(streamId, connection) streamWriteInt8(streamId, self.sceltaPunteC); end;
function forcaExtraElevazione:setsceltaPunteC(int, noEventSend) self.sceltaPunteC = int; setsceltaPunteCEvent.sendEvent(self, int, noEventSend); end;
function forcaExtraElevazione:loadFromAttributesAndNodes(xmlFile, key, resetVehicles)
	local sceltaPunteC = getXMLInt(xmlFile, key .. "#sceltaPunteC"); if sceltaPunteC ~= nil then self:setsceltaPunteC(sceltaPunteC-1); end;
	return BaseMission.VEHICLE_LOAD_OK; end;
function forcaExtraElevazione:getSaveAttributesAndNodes(nodeIdent) local attributes = 'sceltaPunteC="' .. self.sceltaPunteC .. '"'; return attributes; end;
function forcaExtraElevazione:delete() end;
function forcaExtraElevazione:mouseEvent(posX, posY, isDown, isUp, button) end;
function forcaExtraElevazione:keyEvent(unicode, sym, modifier, isDown) end;
function forcaExtraElevazione:update(dt)
	if self:getIsActiveForInput() and self.currentAttacco > 0 then 
		if InputBinding.hasEvent(InputBinding.SHOPLIST_UP) and not self.balesAttached and not self:getIsAnimationPlaying("telaioMobile") then self:playAnimation("telaioMobile", 1); end;
		if InputBinding.hasEvent(InputBinding.SHOPLIST_DOWN) and not self.balesAttached and not self:getIsAnimationPlaying("telaioMobile") then self:playAnimation("telaioMobile", -1.75); end; end; 
	if g_currentMission.player ~= nil and g_currentMission.player.isEntered then
		local px, py, pz = getWorldTranslation(g_currentMission.player.rootNode);
		local tx, ty, tz = getWorldTranslation(self.components[1].node);
		if self.attacherVehicle ~= nil and Utils.vector3Length(px-tx, py-ty, pz-tz) < 3 then
			if InputBinding.hasEvent(InputBinding.selectRightKP) and self.currentPunte == 11 and not self:getIsAnimationPlaying("punteInterne") and not self:getIsAnimationPlaying("punte") then self:setsceltaPunteC(2); end;
			if InputBinding.hasEvent(InputBinding.selectLeftKP) and self.currentPunte == 11 and not self:getIsAnimationPlaying("punteInterne") and not self:getIsAnimationPlaying("punte") then self:setsceltaPunteC(0); end;
			if self.sceltaPunteC == 3 and not self:getIsAnimationPlaying("punteInterne") and not self:getIsAnimationPlaying("punte") then g_currentMission:addExtraPrintText(g_i18n:getText("baleLoaderRotondeNoPilaN"));
			elseif self.sceltaPunteC == 1 and not self:getIsAnimationPlaying("punteInterne") then g_currentMission:addExtraPrintText(g_i18n:getText("baleLoaderRotondePilaN")); end;
			if self.currentPunte == 11 and not self:getIsAnimationPlaying("punte") then
				if self.sceltaPunteC == 1 then g_currentMission:addHelpButtonText(g_i18n:getText("punteEsterne"), InputBinding.selectRightKP); 
				elseif self.sceltaPunteC == 3 then g_currentMission:addHelpButtonText(g_i18n:getText("punteInterne"), InputBinding.selectLeftKP); end; end; end; end; end;
function forcaExtraElevazione:updateTick(dt) 
	if     self.sceltaPunteC == 0 then self:playAnimation("punteInterne", 1, nil, true); self.sceltaPunteC = 1;
	elseif self.sceltaPunteC == 2 then self:playAnimation("punteInterne", -1, nil, true); self.sceltaPunteC = 3; end; end;
function forcaExtraElevazione:draw() if not self.balesAttached and not self:getIsAnimationPlaying("telaioMobile") then g_currentMission:addHelpButtonText(g_i18n:getText("forcaEstendi"), InputBinding.SHOPLIST_UP);g_currentMission:addHelpButtonText(g_i18n:getText("forcaRitrai"), InputBinding.SHOPLIST_DOWN); end;
	if self.currentAttacco > 0 and self.currentPunte == 1 and self.currentBalle > -1 then
		if self.sceltaPunteC == 3 then g_currentMission:addExtraPrintText(g_i18n:getText("baleLoaderRotondeNoPilaN"));
		elseif self.sceltaPunteC == 1 then g_currentMission:addExtraPrintText(g_i18n:getText("baleLoaderRotondePilaN")); end; end; end;
function forcaExtraElevazione:onAttach(attacherVehicle, jointDescIndex) setVisibility(self.tubiIdraulici, false); end;
function forcaExtraElevazione:onDetach() setVisibility(self.tubiIdraulici, true); end;
function forcaExtraElevazione:onDeactivate() end;
setsceltaPunteCEvent = {}; setsceltaPunteCEvent_mt = Class(setsceltaPunteCEvent, Event); InitEventClass(setsceltaPunteCEvent, "setsceltaPunteCEvent");
function setsceltaPunteCEvent:emptyNew() local self = Event:new(setsceltaPunteCEvent_mt); self.className="setsceltaPunteCEvent"; return self; end;
function setsceltaPunteCEvent:new(vehicle, sceltaPunteC) local self = setsceltaPunteCEvent:emptyNew() self.vehicle = vehicle; self.sceltaPunteC = sceltaPunteC; return self; end;
function setsceltaPunteCEvent:readStream(streamId, connection) local id = streamReadInt32(streamId); self.vehicle = networkGetObject(id); self.sceltaPunteC = streamReadInt8(streamId); self.vehicle:setsceltaPunteC(self.sceltaPunteC, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setsceltaPunteCEvent:new(self.vehicle, self.sceltaPunteC), nil, connection, self.vehicle); end; end;
function setsceltaPunteCEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.sceltaPunteC); end;
function setsceltaPunteCEvent.sendEvent(vehicle, sceltaPunteC, noEventSend) if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setsceltaPunteCEvent:new(vehicle, sceltaPunteC), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setsceltaPunteCEvent:new(vehicle, sceltaPunteC)); end; end; end;