This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 524
/
Copy pathTriggerShovelAIDriver.lua
67 lines (56 loc) · 2.23 KB
/
TriggerShovelAIDriver.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--[[
This file is part of Courseplay (https://github.com/Courseplay/courseplay)
Copyright (C) 2021 Courseplay Dev team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]
---@class TriggerShovelAIDriver : ShovelAIDriver
TriggerShovelAIDriver = CpObject(ShovelAIDriver)
TriggerShovelAIDriver.MAX_SPEED_IN_LOADING_TRIGGER = 7
function TriggerShovelAIDriver:start(startingPoint)
ShovelAIDriver.start(self,startingPoint)
--- Make sure unloading at bunker silo is overwritten.
self:changeSiloState(self.states.DRIVING_NORMAL_COURSE)
end
function TriggerShovelAIDriver:setHudContent()
BunkerSiloAIDriver.setHudContent(self)
courseplay.hud:setTriggerHandlerShovelModeAIDriverContent(self.vehicle)
end
function TriggerShovelAIDriver:driveUnloadingCourse(dt)
if self:getSiloSelectedFillTypeSetting():isEmpty() then
self:hold()
self:setInfoText('NO_SELECTED_FILLTYPE')
else
self:clearInfoText('NO_SELECTED_FILLTYPE')
end
--- Only allow loading near the first waypoint.
if self:isNearFillPoint() then
self.triggerHandler:enableFillTypeLoading()
self:setSpeed(self.MAX_SPEED_IN_LOADING_TRIGGER)
else
self.triggerHandler:disableFillTypeLoading()
end
ShovelAIDriver.driveUnloadingCourse(self)
end
function TriggerShovelAIDriver:onEndCourse()
if self:isDrivingUnloadingCourse() then
--- Make sure unloading at bunker silo is overwritten,
--- so we don't call BunkerSiloAIDriver.onEndCourse() here.
AIDriver.onEndCourse(self)
end
end
--- The course is always a loop course.
function TriggerShovelAIDriver:shouldStopAtEndOfCourse()
return false
end
function TriggerShovelAIDriver:getSiloSelectedFillTypeSetting()
return self.vehicle.cp.settings.siloSelectedFillTypeShovelModeDriver
end