Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Dec 13, 2024
1 parent 36ad2d4 commit b31137a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions scripts/ai/controllers/TrailerController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function TrailerController:getDriveData()
maxSpeed = 0
self:debugSparse("Waiting for unloading!")
end
if self.trailerSpec.tipState == Trailer.TIPSTATE_OPENING then
if self.implement:getDischargeNodeEmptyFactor(self.dischargeData.dischargeNode) < 0.1 then
--- Trailer not yet ready to unload.
maxSpeed = 0
self:debugSparse("Waiting for trailer animation opening!")
Expand All @@ -39,22 +39,22 @@ function TrailerController:update(dt)
if self.isDischargingToGround then
if self:isEmpty() then
if self:isDischarging() then
self.implement:setDischargeState(Dischargeable.DISCHARGE_STATE_OFF)
self.implement:setManualDischargeState(Dischargeable.DISCHARGE_STATE_OFF)
end
if self.implement:getAIHasFinishedDischarge(self.dischargeData.dischargeNode) then
self:finishedDischarge()
end
return
end
local fillLevel = self.implement:getFillUnitFillLevelPercentage(self.dischargeData.dischargeNode.fillUnitIndex)
if fillLevel ~= self.dischargeData.lastFillLevel then
self:debugSparse("Resetting the discharge timer")
self.isDischargingTimer:set(true, 250)
end
self.dischargeData.lastFillLevel = fillLevel
if self.implement:getCanDischargeToGround(self.dischargeData.dischargeNode) then
--- Update discharge timer
local fillLevel = self.implement:getFillUnitFillLevelPercentage(self.dischargeData.dischargeNode)
if fillLevel ~= self.dischargeData.lastFillLevel then
self.isDischargingTimer:set(true, 10000)
end
self.dischargeData.lastFillLevel = fillLevel
if not self:isDischarging() then
self.implement:setDischargeState(Dischargeable.DISCHARGE_STATE_GROUND)
self.implement:setManualDischargeState(Dischargeable.DISCHARGE_STATE_GROUND)
end
end
end
Expand Down Expand Up @@ -141,7 +141,7 @@ function TrailerController:prepareForUnload()
end

function TrailerController:onFinished()
self.implement:setDischargeState(Dischargeable.DISCHARGE_STATE_OFF)
self.implement:setManualDischargeState(Dischargeable.DISCHARGE_STATE_OFF)
end

function TrailerController:isDischarging()
Expand Down

0 comments on commit b31137a

Please sign in to comment.