Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
AITaskWaitForFilling
ParentAITaskFunctions
addAllowedFillType
DescriptionDefinitionaddAllowedFillType()Code
42 | function AITaskWaitForFilling:addAllowedFillType(fillType) |
43 | self.fillTypes[fillType] = true |
44 | end |
addFillUnits
DescriptionDefinitionaddFillUnits()Code
119 | function AITaskWaitForFilling:addFillUnits(vehicle, fillUnitIndex) |
120 | table.insert(self.fillUnitInfo, {vehicle=vehicle, fillUnitIndex=fillUnitIndex}) |
121 | end |
new
DescriptionDefinitionnew()Code
16 | function AITaskWaitForFilling.new(isServer, job, customMt) |
17 | local self = AITask.new(isServer, job, customMt or AITaskWaitForFilling_mt) |
18 | |
19 | self.fillTypes = {} |
20 | self.vehicle = nil |
21 | self.fillUnitInfo = {} |
22 | self.waitTime = 0 |
23 | self.waitDuration = 3 * 1000 |
24 | self.isFullyLoaded = false |
25 | |
26 | return self |
27 | end |
reset
DescriptionDefinitionreset()Code
31 | function AITaskWaitForFilling:reset() |
32 | self.vehicle = nil |
33 | self.fillTypes = {} |
34 | self.fillUnitInfo = {} |
35 | self.waitTime = 0 |
36 | self.isFullyLoaded = false |
37 | AITaskWaitForFilling:superClass().reset(self) |
38 | end |
setVehicle
DescriptionDefinitionsetVehicle()Code
113 | function AITaskWaitForFilling:setVehicle(vehicle) |
114 | self.vehicle = vehicle |
115 | end |
start
DescriptionDefinitionstart()Code
88 | function AITaskWaitForFilling:start() |
89 | AITaskWaitForFilling:superClass().start(self) |
90 | |
91 | if self.isServer then |
92 | self.isFullyLoaded = false |
93 | for _, fillUnitInfo in ipairs(self.fillUnitInfo) do |
94 | fillUnitInfo.vehicle:aiPrepareLoading(fillUnitInfo.fillUnitIndex, self) |
95 | end |
96 | end |
97 | end |
stop
DescriptionDefinitionstop()Code
101 | function AITaskWaitForFilling:stop(wasJobStopped) |
102 | AITaskWaitForFilling:superClass().stop(self, wasJobStopped) |
103 | |
104 | if self.isServer then |
105 | for _, fillUnitInfo in ipairs(self.fillUnitInfo) do |
106 | fillUnitInfo.vehicle:aiFinishLoading(fillUnitInfo.fillUnitIndex, self) |
107 | end |
108 | end |
109 | end |
update
DescriptionDefinitionupdate()Code
48 | function AITaskWaitForFilling:update(dt) |
49 | if self.isServer then |
50 | if not self.isFullyLoaded then |
51 | local valid = false |
52 | local isFullyLoaded = true |
53 | for _, fillUnitInfo in ipairs(self.fillUnitInfo) do |
54 | local vehicle = fillUnitInfo.vehicle |
55 | local fillUnitIndex = fillUnitInfo.fillUnitIndex |
56 | local fillType = vehicle:getFillUnitFillType(fillUnitIndex) |
57 | local fillLevel = vehicle:getFillUnitFillLevel(fillUnitIndex) |
58 | local freeCapacity = vehicle:getFillUnitFreeCapacity(fillUnitIndex) |
59 | |
60 | if freeCapacity > 0 then |
61 | isFullyLoaded = false |
62 | end |
63 | |
64 | if (fillLevel > 0 and self.fillTypes[fillType]) or fillLevel == 0 then |
65 | valid = true |
66 | end |
67 | end |
68 | |
69 | if not valid then |
70 | g_currentMission.aiSystem:stopJob(self.job, AIMessageErrorNoValidFillTypeLoaded.new()) |
71 | return |
72 | end |
73 | |
74 | if isFullyLoaded then |
75 | self.isFullyLoaded = true |
76 | self.waitTime = g_time + self.waitDuration |
77 | end |
78 | else |
79 | if g_time > self.waitTime then |
80 | self.isFinished = true |
81 | end |
82 | end |
83 | end |
84 | end |