self.rightExtended = false;
if self.rightMarkerOuter ~= nil then
local x, y, z = getRotation(self.rightMarkerOuter.node);
local minRot = self.rightMarkerOuter.minRot;
local eps = self.rightMarkerOuter.touchRotLimit;
if math.abs(x-minRot[1]) < eps and math.abs(y-minRot[2]) < eps and math.abs(z-minRot[3]) < eps then
self.rightExtended = true;
end;
end;
if self.seederBoom1 ~= nil then
local x, y, z = getRotation(self.seederBoom1.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.seederBoom1.maxRot, self.seederBoom1.minRot, 3, self.seederBoom1.rotTime, dt, self.attacherVehicle.lowerBooms);
setRotation(self.seederBoom1.node, unpack(newRot));
end;
if self.seederBoom2 ~= nil then
local x, y, z = getRotation(self.seederBoom2.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.seederBoom2.maxRot, self.seederBoom2.minRot, 3, self.seederBoom2.rotTime, dt, self.attacherVehicle.lowerBooms);
setRotation(self.seederBoom2.node, unpack(newRot));
end;
if self.seederBoom3 ~= nil then
local x, y, z = getRotation(self.seederBoom3.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.seederBoom3.maxRot, self.seederBoom3.minRot, 3, self.seederBoom3.rotTime, dt, self.attacherVehicle.lowerBooms);
setRotation(self.seederBoom3.node, unpack(newRot));
end;
if self.seederBoom4 ~= nil then
local x, y, z = getRotation(self.seederBoom4.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.seederBoom4.maxRot, self.seederBoom4.minRot, 3, self.seederBoom4.rotTime, dt, self.attacherVehicle.lowerBooms);
setRotation(self.seederBoom4.node, unpack(newRot));
end;
if self.seederBoom5 ~= nil then
local x, y, z = getRotation(self.seederBoom5.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.seederBoom5.maxRot, self.seederBoom5.minRot, 3, self.seederBoom5.rotTime, dt, self.attacherVehicle.lowerBooms);
setRotation(self.seederBoom5.node, unpack(newRot));
end;
if self.seederBoom6 ~= nil then
local x, y, z = getRotation(self.seederBoom6.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.seederBoom6.maxRot, self.seederBoom6.minRot, 3, self.seederBoom6.rotTime, dt, self.attacherVehicle.lowerBooms);
setRotation(self.seederBoom6.node, unpack(newRot));
end;
if self.leftMarkerInner ~= nil then
local x, y, z = getRotation(self.leftMarkerInner.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.leftMarkerInner.maxRot, self.leftMarkerInner.minRot, 3, self.leftMarkerInner.rotTime, dt, self.extendLeft);
setRotation(self.leftMarkerInner.node, unpack(newRot));
end;
if self.leftMarkerOuter ~= nil then
local x, y, z = getRotation(self.leftMarkerOuter.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.leftMarkerOuter.maxRot, self.leftMarkerOuter.minRot, 3, self.leftMarkerOuter.rotTime, dt, self.extendLeft);
setRotation(self.leftMarkerOuter.node, unpack(newRot));
end;
if self.leftMarkerPush ~= nil then
local x, y, z = getTranslation(self.leftMarkerPush.node);
local trans = {x,y,z};
local newTrans = Utils.getMovedLimitedValues(trans, self.leftMarkerPush.maxTrans, self.leftMarkerPush.minTrans, 3, self.leftMarkerPush.transTime, dt, not self.extendLeft);
setTranslation(self.leftMarkerPush.node, unpack(newTrans));
end;
if self.rightMarkerInner ~= nil then
local x, y, z = getRotation(self.rightMarkerInner.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.rightMarkerInner.maxRot, self.rightMarkerInner.minRot, 3, self.rightMarkerInner.rotTime, dt, self.extendRight);
setRotation(self.rightMarkerInner.node, unpack(newRot));
end;
if self.rightMarkerOuter ~= nil then
local x, y, z = getRotation(self.rightMarkerOuter.node);
local rot = {x,y,z};
local newRot = Utils.getMovedLimitedValues(rot, self.rightMarkerOuter.maxRot, self.rightMarkerOuter.minRot, 3, self.rightMarkerOuter.rotTime, dt, self.extendRight);
setRotation(self.rightMarkerOuter.node, unpack(newRot));
end;
if self.rightMarkerPush ~= nil then
local x, y, z = getTranslation(self.rightMarkerPush.node);
local trans = {x,y,z};
local newTrans = Utils.getMovedLimitedValues(trans, self.rightMarkerPush.maxTrans, self.rightMarkerPush.minTrans, 3, self.rightMarkerPush.transTime, dt, not self.extendRight);
setTranslation(self.rightMarkerPush.node, unpack(newTrans));
end;
end;
end;
if self.wingRotation <= self.minWingRotation then
self.fullyExtended = true;
else
self.fullyExtended = false;
end;
-- Markers
if self.attacherVehicle ~= nil then
if self.leftMarkerDisc ~= nil and self.leftExtended then
local axleSpeed = getRotation(self.wheels[2].repr)
setRotation(self.leftMarkerDisc, axleSpeed*-1.3,0,0);
if self.markerAreas[1] ~= nil then
local x,y,z = getWorldTranslation(self.markerAreas[1].start);
local x1,y1,z1 = getWorldTranslation(self.markerAreas[1].width);
local x2,y2,z2 = getWorldTranslation(self.markerAreas[1].height);
Utils.updatePloughArea(x, z, x1, z1, x2, z2, false);
end;
end;
if self.rightMarkerDisc ~= nil and self.rightExtended then
local axleSpeed = getRotation(self.wheels[1].repr)
setRotation(self.rightMarkerDisc, axleSpeed*-1.3,0,0);
if self.markerAreas[2] ~= nil then
local x,y,z = getWorldTranslation(self.markerAreas[2].start);
local x1,y1,z1 = getWorldTranslation(self.markerAreas[2].width);
local x2,y2,z2 = getWorldTranslation(self.markerAreas[2].height);
Utils.updatePloughArea(x, z, x1, z1, x2, z2, false);
end;
end;
end;
-- Seader wheels animation
if self.attacherVehicle ~= nil then
if self.boomsLowered then
local axleSpeed1 = getRotation(self.wheels[1].repr);
local axleSpeed2 = getRotation(self.wheels[2].repr);
local axleSpeed3 = (axleSpeed1 + axleSpeed2)/2;
-- Right wing
if self.rightFrontDisc ~= nil then
setRotation(self.rightFrontDisc, axleSpeed1*1.3,0,0);
end;
if self.rightRearDisc ~= nil then
setRotation(self.rightRearDisc, axleSpeed1*1.3,0,0);
end;
if self.rightFrontLevelWheel ~= nil then
setRotation(self.rightFrontLevelWheel, axleSpeed1*1.5,0,0);
end;
if self.rightRearLevelWheel ~= nil then
setRotation(self.rightRearLevelWheel, axleSpeed1*1.5,0,0);
end;
if self.rightFrontCowerWheel ~= nil then
setRotation(self.rightFrontCowerWheel, axleSpeed1*2,0,0);
end;
if self.rightRearCowerWheel ~= nil then
setRotation(self.rightRearCowerWheel, axleSpeed1*2,0,0);
end;
-- Center
if self.centerFrontDisc ~= nil then
setRotation(self.centerFrontDisc, axleSpeed3*1.3,0,0);
end;
if self.centerRearDisc ~= nil then
setRotation(self.centerRearDisc, axleSpeed3*1.3,0,0);
end;
if self.centerFrontLevelWheel ~= nil then
setRotation(self.centerFrontLevelWheel, axleSpeed3*1.5,0,0);
end;
if self.centerRearLevelWheel ~= nil then
setRotation(self.centerRearLevelWheel, axleSpeed3*1.5,0,0);
end;
if self.centerFrontCowerWheel ~= nil then
setRotation(self.centerFrontCowerWheel, axleSpeed3*2,0,0);
end;
if self.centerRearCowerWheel ~= nil then
setRotation(self.centerRearCowerWheel, axleSpeed3*2,0,0);
end;
-- left wing
if self.leftFrontDisc ~= nil then
setRotation(self.leftFrontDisc, axleSpeed2*1.3,0,0);
end;
if self.leftRearDisc ~= nil then
setRotation(self.leftRearDisc, axleSpeed2*1.3,0,0);
end;
if self.leftFrontLevelWheel ~= nil then
setRotation(self.leftFrontLevelWheel, axleSpeed2*1.5,0,0);
end;
if self.leftRearLevelWheel ~= nil then
setRotation(self.leftRearLevelWheel, axleSpeed2*1.5,0,0);
end;
if self.leftFrontCowerWheel ~= nil then
setRotation(self.leftFrontCowerWheel, axleSpeed2*2,0,0);
end;
if self.leftRearCowerWheel ~= nil then
setRotation(self.leftRearCowerWheel, axleSpeed2*2,0,0);
end;
end;
end;
-- Dolly simulation
if self.attacherVehicle ~= nil and self.simulatedDolly1 ~= nil then
local axleSpeed1 = self.attacherVehicle.lastSpeed*3600;
local axleSpeed2 = getWheelShapeAxleSpeed(self.wheels[1].node, self.wheels[1].wheelShape)*3.14/180; -- rad/sec
local frontAngle = 0;
local x,y,z = worldDirectionToLocal(self.dollyJoint1, localDirectionToWorld(self.attacherVehicle.steeringAxleNode, 0, 0, 1));
local dot = z; -- 0*x + z*1;
dot = dot / Utils.vector2Length(x,z);
local angle = math.acos(dot);
if x < 0 then
angle = -angle;
end;
local startSpeed = self.steeringAxleAngleScaleStart;
local endSpeed = self.steeringAxleAngleScaleEnd;
local scale = Utils.clamp(1 + (self.lastSpeed*3600-startSpeed) * 1.0/(startSpeed-endSpeed), 0, 1);
self.steeringAxleAngle = angle*scale;
frontAngle = self.steeringAxleAngle;
frontAngle = frontAngle * 0.70;
if axleSpeed2 < 0 then
frontAngle = frontAngle - 3.14;
end;
local adjustedRotation = frontAngle;
if self.lastDolly1Rotation > frontAngle+0.1 or self.lastDolly1Rotation < frontAngle-0.1 then
if self.lastDolly1Rotation < frontAngle then
adjustedRotation = self.lastDolly1Rotation - 0.6 * -1 * axleSpeed1/30;
elseif self.lastDolly1Rotation > frontAngle then
adjustedRotation = self.lastDolly1Rotation + 0.6 * -1 * axleSpeed1/30;
end;
end;
if self.wingRotation <= self.minWingRotation then
setRotation(self.simulatedDolly1, 0, adjustedRotation, 0);
self.lastDolly1Rotation = adjustedRotation;
end;
end;
if self.attacherVehicle ~= nil and self.simulatedDolly2 ~= nil then
local axleSpeed1 = self.attacherVehicle.lastSpeed*3600;
local axleSpeed2 = getWheelShapeAxleSpeed(self.wheels[2].node, self.wheels[2].wheelShape)*3.14/180; -- rad/sec
local frontAngle = 0;
local x,y,z = worldDirectionToLocal(self.dollyJoint2, localDirectionToWorld(self.attacherVehicle.steeringAxleNode, 0, 0, 1));
local dot = z; -- 0*x + z*1;
dot = dot / Utils.vector2Length(x,z);
local angle = math.acos(dot);
if x < 0 then
angle = -angle;
end;
local startSpeed = self.steeringAxleAngleScaleStart;
local endSpeed = self.steeringAxleAngleScaleEnd;
local scale = Utils.clamp(1 + (self.lastSpeed*3600-startSpeed) * 1.0/(startSpeed-endSpeed), 0, 1);
self.steeringAxleAngle = angle*scale;
frontAngle = self.steeringAxleAngle;
frontAngle = frontAngle * 0.70;
if axleSpeed2 < 0 then
frontAngle = frontAngle - 3.14;
end;
local adjustedRotation = frontAngle;
if self.lastDolly2Rotation > frontAngle+0.1 or self.lastDolly2Rotation < frontAngle-0.1 then
if self.lastDolly2Rotation < frontAngle then
adjustedRotation = self.lastDolly2Rotation - 0.6 * -1 * axleSpeed1/30;
elseif self.lastDolly2Rotation > frontAngle then
adjustedRotation = self.lastDolly2Rotation + 0.6 * -1 * axleSpeed1/30;
end;
end;
if self.wingRotation <= self.minWingRotation then
setRotation(self.simulatedDolly2, 0, adjustedRotation, 0);
self.lastDolly2Rotation = adjustedRotation;
end;
end;
-- Wheel rotation simulation
if self.wingRotation <= self.minWingRotation then
if self.simulatedWheel1 ~= nil then
local x,y,z = getRotation(self.wheels[1].repr);
setRotation(self.simulatedWheel1, x, y, z);
local x2,y2,z2 = getTranslation(self.wheels[1].repr);
local x3,y3,z3 = getTranslation(self.simulatedWheel1);
setTranslation(self.simulatedWheel1, x3,y2,z3);
end;
if self.simulatedWheel2 ~= nil then
local x,y,z = getRotation(self.wheels[2].repr);
setRotation(self.simulatedWheel2, x, y, z);
local x2,y2,z2 = getTranslation(self.wheels[2].repr);
local x3,y3,z3 = getTranslation(self.simulatedWheel2);
setTranslation(self.simulatedWheel2, x3,y2,z3);
end;
if self.simulatedWheel3 ~= nil then
local x,y,z = getRotation(self.wheels[1].repr);
setRotation(self.simulatedWheel3, x, y, z);
local x2,y2,z2 = getTranslation(self.wheels[1].repr);
local x3,y3,z3 = getTranslation(self.simulatedWheel3);
setTranslation(self.simulatedWheel3, x3,y2,z3);
end;
if self.simulatedWheel4 ~= nil then
local x,y,z = getRotation(self.wheels[2].repr);
setRotation(self.simulatedWheel4, x, y, z);
local x2,y2,z2 = getTranslation(self.wheels[2].repr);
local x3,y3,z3 = getTranslation(self.simulatedWheel4);
setTranslation(self.simulatedWheel4, x3,y2,z3);
end;
end;
if self.simulatedWheel5 ~= nil then
local x,y,z = getRotation(self.wheels[3].repr);
setRotation(self.simulatedWheel5, x, y, z);
local x2,y2,z2 = getTranslation(self.wheels[1].repr);
local x3,y3,z3 = getTranslation(self.simulatedWheel5);
setTranslation(self.simulatedWheel5, x3,y2,z3);
end;
if self.simulatedWheel6 ~= nil then
local x,y,z = getRotation(self.wheels[4].repr);
setRotation(self.simulatedWheel6, x, y, z);
local x2,y2,z2 = getTranslation(self.wheels[2].repr);
local x3,y3,z3 = getTranslation(self.simulatedWheel6);
setTranslation(self.simulatedWheel6, x3,y2,z3);
end;
-- Ground work sound
if self.attacherVehicle ~= nil and self.attacherVehicle.attacherVehicle ~= nil and self.attacherVehicle.attacherVehicle.isEntered then
if self.attacherVehicle.attacherVehicle.movingDirection ~= 0 and self.boomsLowered then
self.groundWork = true;
else
self.GroundWorkPlaying = false;
self.groundWork = false;
if self.GroundWorkPlaying ~= nil then
stopSample(self.GroundWorkSoundId);
end;
end;
else
self.groundWork = false;
end;
if self.attacherVehicle ~= nil and self.attacherVehicle.attacherVehicle ~= nil and not self.attacherVehicle.attacherVehicle.isEntered then
if self.attacherVehicle.attacherVehicle.movingDirection ~= 0 and self.boomsLowered then
setVisibility(self.externalGroundWorkSound, true);
self.externalGroundWork = true;
else
setVisibility(self.externalGroundWorkSound, false);
self.externalGroundWork = false;
end;
else
setVisibility(self.externalGroundWorkSound, false);
self.externalGroundWork = false;
end;
if self.groundWork and self:getIsActiveForSound() then
if not self.GroundWorkPlaying then
playSample(self.GroundWorkSoundId, 0, 1, 0);
self.GroundWorkPlaying = true;
end;
else
if self.GroundWorkPlaying then
stopSample(self.GroundWorkSoundId);
self.GroundWorkPlaying = false;
end;
end;
if self.groundWork or self.externalGroundWork then
Utils.setEmittingState(self.particleSystems1, true);
Utils.setEmittingState(self.particleSystems2, true);
Utils.setEmittingState(self.particleSystems3, true);
Utils.setEmittingState(self.particleSystems4, true);
Utils.setEmittingState(self.particleSystems5, true);
Utils.setEmittingState(self.particleSystems6, true);
else
Utils.setEmittingState(self.particleSystems1, false);
Utils.setEmittingState(self.particleSystems2, false);
Utils.setEmittingState(self.particleSystems3, false);
Utils.setEmittingState(self.particleSystems4, false);
Utils.setEmittingState(self.particleSystems5, false);
Utils.setEmittingState(self.particleSystems6, false);
end;
-- Hydraulics sound
if self.attacherVehicle ~= nil and self.attacherVehicle.attacherVehicle ~= nil and self.attacherVehicle.attacherVehicle.isEntered then
if not self.boomsLowered and not self.boomsRaised then
self.hydraulicLiftersSound = true
else
self.hydraulicLiftersSound = false;
end;
else
self.hydraulicLiftersSound = false;
end;
if (self.hydraulicLiftersSound or self.hydraulicSound) and self:getIsActiveForSound() then
if not self.HydraulicPlaying then
playSample(self.HydraulicSoundId, 0, 1, 0);
self.HydraulicPlaying = true;
end;
else
if self.HydraulicPlaying then
stopSample(self.HydraulicSoundId);
self.HydraulicPlaying = false;
end;
end;
-- Speed monitoring
if self.attacherVehicle ~= nil then
if self.attacherVehicle.attacherVehicle ~= nil then
if self.fullyExtended and self.boomsLowered then
if self.attacherVehicle.lastSpeed*3600 > self.speedlimit then
self.speedViolationTimer = self.speedViolationTimer - dt;
else
self.speedViolationTimer = self.speedViolationMaxTime;
end;
end;
end;
end;
if self.attacherVehicle ~= nil and self.attacherVehicle.airCart then
-- Establishing graintype in cart
if self.attacherVehicle.attacherVehicle ~= nil then
local frontTankFill = self.attacherVehicle.currentFrontFillType;
local rearTankFill = self.attacherVehicle.currentRearFillType;
self.currentSeedType = FruitUtil.FRUITTYPE_UNKNOWN;
self.usingCartTankNo = -1;
self.fertilize = false;
if frontTankFill == rearTankFill and rearTankFill ~= FruitUtil.FRUITTYPE_FERTILIZER then
self.currentSeedType = frontTankFill;
self.usingCartTankNo = 1;
self.fertilize = false;
elseif frontTankFill == FruitUtil.FRUITTYPE_UNKNOWN and rearTankFill ~= FruitUtil.FRUITTYPE_FERTILIZER then
self.currentSeedType = rearTankFill;
self.usingCartTankNo = 2;
self.fertilize = false;
elseif rearTankFill == FruitUtil.FRUITTYPE_UNKNOWN and frontTankFill ~= FruitUtil.FRUITTYPE_FERTILIZER then
self.currentSeedType = frontTankFill;
self.usingCartTankNo = 1;
self.fertilize = false;
elseif frontTankFill == FruitUtil.FRUITTYPE_FERTILIZER and rearTankFill ~= FruitUtil.FRUITTYPE_UNKNOWN then
self.currentSeedType = rearTankFill;
self.usingCartTankNo = 2;
self.fertilize = true;
elseif rearTankFill == FruitUtil.FRUITTYPE_FERTILIZER and frontTankFill ~= FruitUtil.FRUITTYPE_UNKNOWN then
self.currentSeedType = frontTankFill;
self.usingCartTankNo = 1;
self.fertilize = true;
end;
end;
if self.noCombination then
-- Harrowing
if not self.seeding then
if self.attacherVehicle.attacherVehicle ~= nil then
if self.fullyExtended and self.boomsLowered and not self.attacherVehicle.attacherVehicle.isAITractorActivated then
if self.speedViolationTimer > 0 and self.lastSpeed*3600 > 0.2 then
for k, cuttingArea in pairs(self.cuttingAreas) do
local x,y,z = getWorldTranslation(cuttingArea.start);
local x1,y1,z1 = getWorldTranslation(cuttingArea.width);
local x2,y2,z2 = getWorldTranslation(cuttingArea.height);
Utils.updateCultivatorArea(x, z, x1, z1, x2, z2, false);
end;
end;
end;
end;
end;
-- Seeding
if self.seeding then
if self.attacherVehicle.attacherVehicle ~= nil then
if self.fullyExtended and self.boomsLowered then
if self.speedViolationTimer > 0 and self.lastSpeed*3600 > 0.2 then
for v,sowingArea in pairs(self.sowingAreas) do
if self.currentSeedType ~= FruitUtil.FRUITTYPE_UNKNOWN and self.attacherVehicle.FanOn then
local x,y,z = getWorldTranslation(sowingArea.start);
local x1,y1,z1 = getWorldTranslation(sowingArea.width);
local x2,y2,z2 = getWorldTranslation(sowingArea.height);
local area = 0;
area = Utils.updateSowingArea(self.currentSeedType, x, z, x1, z1, x2, z2);
local fruitDesc = FruitUtil.fruitIndexToDesc[self.currentSeedType];
local pixelToSqm = g_currentMission:getTerrainDetailPixelsToSqm(); -- 8192px are mapped to 2048m
local sqm = area*pixelToSqm;
local ha = sqm/10000;
local usage = fruitDesc.seedUsagePerSqm*sqm;
g_currentMission.missionStats.seedUsageTotal = g_currentMission.missionStats.seedUsageTotal + usage;
g_currentMission.missionStats.seedUsageSession = g_currentMission.missionStats.seedUsageSession + usage;
g_currentMission.missionStats.hectaresSeededTotal = g_currentMission.missionStats.hectaresSeededTotal + ha;
g_currentMission.missionStats.hectaresSeededSession = g_currentMission.missionStats.hectaresSeededSession + ha;
-- Retract used grain from cart
if self.usingCartTankNo == 1 then
self.attacherVehicle.frontFillLevel = self.attacherVehicle.frontFillLevel - usage;
self.attacherVehicle:setFrontFillLevel(self.attacherVehicle.frontFillLevel, self.currentSeedType);
elseif self.usingCartTankNo == 2 then
self.attacherVehicle.rearFillLevel = self.attacherVehicle.rearFillLevel - usage;
self.attacherVehicle:setRearFillLevel(self.attacherVehicle.rearFillLevel, self.currentSeedType);
end;
--Utils.updateCropsAt(x, z, x1, z1, x2, z2, 1.0);
--Utils.updateGrassAt(x, z, x1, z1, x2, z2, 0.0);
--Utils.updateCropsAt(x, z, x1, z1, x2, z2, 0.0);
-- Fertilize
if self.fertilize then
Utils.updateSprayArea(x, z, x1, z1, x2, z2);
-- Retract used fertilizer from cart
if self.usingCartTankNo == 1 then
self.attacherVehicle.rearFillLevel = self.attacherVehicle.rearFillLevel - (usage * 0.
;
self.attacherVehicle:setRearFillLevel(self.attacherVehicle.rearFillLevel, self.currentSeedType);
elseif self.usingCartTankNo == 2 then
self.attacherVehicle.frontFillLevel = self.attacherVehicle.frontFillLevel - (usage * 0.
;
self.attacherVehicle:setFrontFillLevel(self.attacherVehicle.frontFillLevel, self.currentSeedType);
end;
end;
end;
end;
g_currentMission.missionStats.seedingDurationTotal = g_currentMission.missionStats.seedingDurationTotal + dt/(1000*60);
g_currentMission.missionStats.seedingDurationSession = g_currentMission.missionStats.seedingDurationSession + dt/(1000*60);
end;
end;
end;
end;
else
if self.attacherVehicle.attacherVehicle ~= nil then
if self.fullyExtended and self.boomsLowered then
if self.speedViolationTimer > 0 then
for k, combinationArea in pairs(self.combinationAreas) do
if self.currentSeedType ~= FruitUtil.FRUITTYPE_UNKNOWN and self.attacherVehicle.FanOn then
local x,y,z = getWorldTranslation(combinationArea.start);
local x1,y1,z1 = getWorldTranslation(combinationArea.width);
local x2,y2,z2 = getWorldTranslation(combinationArea.height);
local area = 0;
if not self.attacherVehicle.attacherVehicle.isAITractorActivated then
Utils.updateCultivatorArea(x, z, x1, z1, x2, z2, false);
end;
area = Utils.updateSowingArea(self.currentSeedType, x, z, x1, z1, x2, z2);
local fruitDesc = FruitUtil.fruitIndexToDesc[self.currentSeedType];
local pixelToSqm = g_currentMission:getTerrainDetailPixelsToSqm(); -- 8192px are mapped to 2048m
local sqm = area*pixelToSqm;
local ha = sqm/10000;
local usage = fruitDesc.seedUsagePerSqm*sqm;
g_currentMission.missionStats.seedUsageTotal = g_currentMission.missionStats.seedUsageTotal + usage;
g_currentMission.missionStats.seedUsageSession = g_currentMission.missionStats.seedUsageSession + usage;
g_currentMission.missionStats.hectaresSeededTotal = g_currentMission.missionStats.hectaresSeededTotal + ha;
g_currentMission.missionStats.hectaresSeededSession = g_currentMission.missionStats.hectaresSeededSession + ha;
-- Retract used grain from cart
if self.usingCartTankNo == 1 then
self.attacherVehicle.frontFillLevel = self.attacherVehicle.frontFillLevel - usage;
self.attacherVehicle:setFrontFillLevel(self.attacherVehicle.frontFillLevel, self.currentSeedType);
elseif self.usingCartTankNo == 2 then
self.attacherVehicle.rearFillLevel = self.attacherVehicle.rearFillLevel - usage;
self.attacherVehicle:setRearFillLevel(self.attacherVehicle.rearFillLevel, self.currentSeedType);
end;
--Utils.updateCropsAt(x, z, x1, z1, x2, z2, 1.0);
--Utils.updateGrassAt(x, z, x1, z1, x2, z2, 0.0);
--Utils.updateCropsAt(x, z, x1, z1, x2, z2, 0.0);
-- Fertilize
if self.fertilize then
Utils.updateSprayArea(x, z, x1, z1, x2, z2);
-- Retract used fertilizer from cart
if self.usingCartTankNo == 1 then
self.attacherVehicle.rearFillLevel = self.attacherVehicle.rearFillLevel - (usage * 0.
;
self.attacherVehicle:setRearFillLevel(self.attacherVehicle.rearFillLevel, self.currentSeedType);
elseif self.usingCartTankNo == 2 then
self.attacherVehicle.frontFillLevel = self.attacherVehicle.frontFillLevel - (usage * 0.
;
self.attacherVehicle:setFrontFillLevel(self.attacherVehicle.frontFillLevel, self.currentSeedType);
end;
end;
end;
end;
g_currentMission.missionStats.seedingDurationTotal = g_currentMission.missionStats.seedingDurationTotal + dt/(1000*60);
g_currentMission.missionStats.seedingDurationSession = g_currentMission.missionStats.seedingDurationSession + dt/(1000*60);
end;
end;
end;
end;
end;
self.seeding = not self.seeding;
end;
function Airseeder:draw()
if self.attacherVehicle ~= nil and self.attacherVehicle.airCart and self.attacherVehicle.hudOn >= 2 then
-- Status texts
setTextColor(1, 1, 1, 1.0);
setTextBold(false);
if self.boomsLowered then
renderText(0.70, 0.57, 0.020, string.format("heben der Saemaschine ["..self.keyType(InputBinding.JD1890LOWER).."]"));
else
renderText(0.704, 0.57, 0.020, string.format("senken der Saemaschine ["..self.keyType(InputBinding.JD1890LOWER).."]"));
end;
renderText(0.70, 0.55, 0.020, string.format("Saemaschine zuklappen ["..self.keyType(InputBinding.JD1890FOLD).."]"));
renderText(0.70, 0.53, 0.020, string.format("Saemaschine aufklappen ["..self.keyType(InputBinding.JD1890UNFOLD).."]"));
if self.autoMarkersEnabled then
renderText(0.70, 0.51, 0.020, string.format("Aut. marker aus ["..self.keyType(InputBinding.JD1890AUTOMARKERS).."]"));
else
renderText(0.70, 0.51, 0.020, string.format("Aut. marker an ["..self.keyType(InputBinding.JD1890AUTOMARKERS).."]"));
end;
if self.markerPos == 1 then
renderText(0.70, 0.49, 0.020, string.format("einklappen markers ["..self.keyType(InputBinding.JD1890MAKERTRANSPORT).."]"));
renderText(0.70, 0.47, 0.020, string.format("rechter Marker ["..self.keyType(InputBinding.JD1890MAKERRIGHT).."]"));
elseif self.markerPos == 2 or self.markerPos == 0 then
renderText(0.70, 0.49, 0.020, string.format("linker Marker ["..self.keyType(InputBinding.JD1890MAKERLEFT).."]"));
renderText(0.70, 0.47, 0.020, string.format("rechter Marker ["..self.keyType(InputBinding.JD1890MAKERRIGHT).."]"));
elseif self.markerPos == 3 then
renderText(0.70, 0.49, 0.020, string.format("einklappen markers ["..self.keyType(InputBinding.JD1890MAKERTRANSPORT).."]"));
renderText(0.70, 0.47, 0.020, string.format("linker Marker ["..self.keyType(InputBinding.JD1890MAKERLEFT).."]"));
end;
end;
if math.abs(self.speedViolationTimer - self.speedViolationMaxTime) > 2 then
if self.attacherVehicle ~= nil and self.fullyExtended and self.boomsLowered then
g_currentMission:addWarning("Sie fahren zu schnell, um zu saeen", 0.07+0.022, 0.019+0.029);
end;
end;
if self.attacherVehicle ~= nil and not self.attacherVehicle.airCart then
g_currentMission:addWarning("Sie muessen die Aircart vor der Saemaschine spannen", 0.07+0.022, 0.019+0.029);
end;
end;
function Airseeder:onDetach()
end;
function Airseeder:onLeave()
end;
function Airseeder:onDeactivate()
end;
function Airseeder:onDeactivateSounds()
end;