forcaRotoballe = {};
function forcaRotoballe.prerequisitesPresent(specializations) return true; end;
function forcaRotoballe:load(xmlFile) 
	self.setsceltaPunteA = SpecializationUtil.callSpecializationsFunction("setsceltaPunteA"); self.sceltaPunteA = 3; self.currentSupport = true; self.currentBalle = -1; self.currentPosizione = 2; end;
function forcaRotoballe:readStream(streamId, connection) self:setsceltaPunteA(streamReadInt8(streamId), true); end;
function forcaRotoballe:writeStream(streamId, connection) streamWriteInt8(streamId, self.sceltaPunteA); end;
function forcaRotoballe:setsceltaPunteA(int, noEventSend) self.sceltaPunteA = int; setsceltaPunteAEvent.sendEvent(self, int, noEventSend); end;
function forcaRotoballe:loadFromAttributesAndNodes(xmlFile, key, resetVehicles)
	local sceltaPunteA = getXMLInt(xmlFile, key .. "#sceltaPunteA"); if sceltaPunteA ~= nil then self:setsceltaPunteA(sceltaPunteA-1); end;
	return BaseMission.VEHICLE_LOAD_OK; end;
function forcaRotoballe:getSaveAttributesAndNodes(nodeIdent) local attributes = 'sceltaPunteA="' .. self.sceltaPunteA .. '"'; return attributes; end;
function forcaRotoballe:delete() end;
function forcaRotoballe:mouseEvent(posX, posY, isDown, isUp, button) end;
function forcaRotoballe:keyEvent(unicode, sym, modifier, isDown) end;
function forcaRotoballe:update(dt)
	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:setsceltaPunteA(2); end;
			if InputBinding.hasEvent(InputBinding.selectLeftKP)  and self.currentPunte == 11 and not self:getIsAnimationPlaying("punteInterne") and not self:getIsAnimationPlaying("punte") then self:setsceltaPunteA(0); end;
			if self.sceltaPunteA == 3 and not self:getIsAnimationPlaying("punteInterne") then g_currentMission:addExtraPrintText(g_i18n:getText("baleLoaderRotondeNoPilaN"));
			elseif self.sceltaPunteA == 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.sceltaPunteA == 1 then g_currentMission:addHelpButtonText(g_i18n:getText("punteEsterne"), InputBinding.selectRightKP); 
				elseif self.sceltaPunteA == 3 then g_currentMission:addHelpButtonText(g_i18n:getText("punteInterne"), InputBinding.selectLeftKP); end; end; end; end; end;
function forcaRotoballe:updateTick(dt) 
	if     self.sceltaPunteA == 0 then self:playAnimation("punteInterne", 1, nil, true); self.sceltaPunteA = 1;
	elseif self.sceltaPunteA == 2 then self:playAnimation("punteInterne", -1, nil, true); self.sceltaPunteA = 3; end; end;
function forcaRotoballe:draw() if self.currentAttacco > 6 and self.currentPunte == 1 and self.currentBalle > -1 then
		if self.sceltaPunteA == 3 then g_currentMission:addExtraPrintText(g_i18n:getText("baleLoaderRotondeNoPilaN"));
		elseif self.sceltaPunteA == 1 then g_currentMission:addExtraPrintText(g_i18n:getText("baleLoaderRotondePilaN")); end; end; end;
function forcaRotoballe:onAttach(attacherVehicle, jointDescIndex) end;
function forcaRotoballe:onDetach() end;
function forcaRotoballe:onDeactivate() end;
setsceltaPunteAEvent = {}; setsceltaPunteAEvent_mt = Class(setsceltaPunteAEvent, Event); InitEventClass(setsceltaPunteAEvent, "setsceltaPunteAEvent");
function setsceltaPunteAEvent:emptyNew() local self = Event:new(setsceltaPunteAEvent_mt); self.className="setsceltaPunteAEvent"; return self; end;
function setsceltaPunteAEvent:new(vehicle, sceltaPunteA) local self = setsceltaPunteAEvent:emptyNew() self.vehicle = vehicle; self.sceltaPunteA = sceltaPunteA; return self; end;
function setsceltaPunteAEvent:readStream(streamId, connection) local id = streamReadInt32(streamId);
    self.vehicle = networkGetObject(id); self.sceltaPunteA = streamReadInt8(streamId); self.vehicle:setsceltaPunteA(self.sceltaPunteA, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setsceltaPunteAEvent:new(self.vehicle, self.sceltaPunteA), nil, connection, self.vehicle); end; end;
function setsceltaPunteAEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.sceltaPunteA); end;
function setsceltaPunteAEvent.sendEvent(vehicle, sceltaPunteA, noEventSend)	if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setsceltaPunteAEvent:new(vehicle, sceltaPunteA), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setsceltaPunteAEvent:new(vehicle, sceltaPunteA)); end; end; end;