forcaLetame = {};
function forcaLetame.prerequisitesPresent(specializations) return true; end;
function forcaLetame:load(xmlFile) self.objectInRangeFL = forcaLetame.objectInRangeFL;
	self.currentBalle = -1; self.currentPunte = 1; self.currentSupport = true; self.sceltaPunteE = 3; self.currentPosizione = 2;
	self.capacityFill = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.capacity"), 0.0);
	self.smokeParticleSystems = {}; local entry = {}; entry.particleSystems = {};
    Utils.loadParticleSystem(xmlFile, entry.particleSystems, "vehicle.smokeParticleSystem", self.components, false, nil, self.baseDirectory);
    if table.getn(entry.particleSystems) > 0 then entry.isActive = false; table.insert(self.smokeParticleSystems, entry); end; local i = 0;
	while true do local baseName = string.format("vehicle.smokeParticleSystems.smokeParticleSystem(%d)", i);
		if not hasXMLProperty(xmlFile, baseName) then break; end;
        local entry = {}; entry.particleSystems = {};
        Utils.loadParticleSystem(xmlFile, entry.particleSystems, baseName, self.components, false, nil, self.baseDirectory);
        if table.getn(entry.particleSystems) > 0 then entry.isActive = false; table.insert(self.smokeParticleSystems, entry); end;
        i = i + 1; end; end;
function forcaLetame:delete() 
	for _, entry in ipairs(self.smokeParticleSystems) do Utils.deleteParticleSystem(entry.particleSystems); entry.isActive = false; end; end;
function forcaLetame:mouseEvent(posX, posY, isDown, isUp, button) end;
function forcaLetame:keyEvent(unicode, sym, modifier, isDown) end;
function forcaLetame:objectInRangeFL(refNode) local nearestDistance = 3; local nearestBale = nil; local px, py, pz = getWorldTranslation(refNode.node);
    for index, item in pairs(g_currentMission.itemsToSave) do if item.item:isa(Bale) then local vx, vy, vz = getWorldTranslation(item.item.nodeId); local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);
		if distance < nearestDistance then nearestDistance = distance; nearestBale = item.item; end; end; end; return nearestBale; end;
function forcaLetame:update(dt) if self.currentAttacco ~= 0 or self.currentAttacco == 1 then local bale = self:objectInRangeFL(self.lockPrima); if bale ~= nil or self.setBaleLoader > 0 then if self.capacity > 100 then self.capacity = self.capacityBale; end; self:playAnimation("collisione", 1); self.currentFillType = 0; elseif self.currentFillType > 0 then self.capacity = self.capacityFill; if self.currentBalle > -1 then self:setcurrentBalle(-1); end; self:getFirstEnabledFillType(); self:playAnimation("collisione", -1); end; end; end;
function forcaLetame:loadFromAttributesAndNodes(xmlFile, key, resetVehicles) return BaseMission.VEHICLE_LOAD_OK; end;
function forcaLetame:getSaveAttributesAndNodes(nodeIdent) end;
function forcaLetame:updateTick(dt) if self.isClient then for _,particleSystems in pairs(self.smokeParticleSystems) do                  
    if self.currentFillType == Fillable.FILLTYPE_MANURE and self.fillLevel > 2000 and self.setmovingDirection < 300 
	then Utils.setEmittingState(particleSystems.particleSystems, true); else Utils.setEmittingState(particleSystems.particleSystems, false); end; end; end; if self.currentPiloni ~= 1 then self:setcurrentPiloni(1); end; end;
function forcaLetame:draw() end;
function forcaLetame:onAttach(attacherVehicle, jointDescIndex)  end;
function forcaLetame:onDetach() end;
function forcaLetame:onDeactivate() end;