97 | function BaleLoader:load(savegame) |
98 | |
99 | self.doStateChange = BaleLoader.doStateChange; |
100 | self.getBaleGrabberDropBaleAnimName = BaleLoader.getBaleGrabberDropBaleAnimName; |
101 | self.pickupBale = BaleLoader.pickupBale; |
102 | |
103 | self.balesToLoad = {} |
104 | |
105 | self.balesToMount = {}; |
106 | |
107 | self.isInWorkPosition = false; |
108 | self.grabberIsMoving = false; |
109 | self.allowGrabbing = false; |
110 | self.synchronizeFillLevel = false; |
111 | |
112 | self.rotatePlatformDirection = 0; |
113 | self.frontBalePusherDirection = 0; |
114 | |
115 | self.emptyState = BaleLoader.EMPTY_NONE; |
116 | self.itemsToSave = {} |
117 | |
118 | self.balePickupRange = Utils.getNoNil(getXMLFloat(self.xmlFile, "vehicle.baleLoader#pickupRange"), 3.0) |
119 | |
120 | self.textTransportPosition = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#textTransportPosition"), "action_baleloaderTransportPosition") |
121 | self.textOperatingPosition = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#textOperatingPosition"), "action_baleloaderOperatingPosition") |
122 | self.textUnload = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#textUnload"), "action_baleloaderUnload") |
123 | self.textTilting = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#textTilting"), "info_baleloaderTiltingTable") |
124 | self.textLowering = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#textLowering"), "info_baleloaderLoweringTable") |
125 | self.textLowerPlattform = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#textLowerPlattform"), "action_baleloaderLowerPlatform") |
126 | self.textAbortUnloading = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#textAbortUnloading"), "action_baleloaderAbortUnloading") |
127 | self.textUnloadHere = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#textUnloadHere"), "action_baleloaderUnloadHere") |
128 | |
129 | self.rotatePlatformAnimName = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#rotatePlatformAnimName"), "rotatePlatform"); |
130 | self.rotatePlatformBackAnimName = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#rotatePlatformBackAnimName"), "rotatePlatform"); |
131 | self.rotatePlatformEmptyAnimName = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.baleLoader#rotatePlatformEmptyAnimName"), "rotatePlatform"); |
132 | |
133 | self.moveBalePlacesAfterRotatePlatform = Utils.getNoNil(getXMLBool(self.xmlFile, "vehicle.baleLoader#moveBalePlacesAfterRotatePlatform"), false); |
134 | self.alwaysMoveBalePlaces = Utils.getNoNil(getXMLBool(self.xmlFile, "vehicle.baleLoader#alwaysMoveBalePlaces"), false); |
135 | |
136 | self.baleGrabber = {}; |
137 | self.baleGrabber.grabNode = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.baleGrabber#grabNode")); |
138 | |
139 | self.startBalePlace = {}; |
140 | self.startBalePlace.bales = {}; |
141 | self.startBalePlace.node = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.balePlaces#startBalePlace")); |
142 | if self.startBalePlace.node ~= nil then |
143 | self.startBalePlace.numOfPlaces = getNumOfChildren(self.startBalePlace.node) |
144 | if self.startBalePlace.numOfPlaces == 0 then |
145 | self.startBalePlace.node = nil; |
146 | else |
147 | self.startBalePlace.origRot = {}; |
148 | self.startBalePlace.origTrans = {}; |
149 | for i=1, self.startBalePlace.numOfPlaces do |
150 | local node = getChildAt(self.startBalePlace.node, i-1); |
151 | local x,y,z = getRotation(node); |
152 | self.startBalePlace.origRot[i] = {x,y,z}; |
153 | local x,y,z = getTranslation(node); |
154 | self.startBalePlace.origTrans[i] = {x,y,z}; |
155 | end |
156 | end |
157 | end |
158 | self.startBalePlace.count = 0; |
159 | |
160 | self.currentBalePlace = 1; |
161 | self.balePlaces = {}; |
162 | local i=0; |
163 | while true do |
164 | local key = string.format("vehicle.balePlaces.balePlace(%d)", i); |
165 | if not hasXMLProperty(self.xmlFile, key) then |
166 | break; |
167 | end |
168 | local node = Utils.indexToObject(self.components, getXMLString(self.xmlFile, key.."#node")); |
169 | local collision = Utils.indexToObject(self.components, getXMLString(self.xmlFile, key.."#collision")); |
170 | if node ~= nil then |
171 | local entry = {}; |
172 | entry.node = node; |
173 | entry.collision = collision; |
174 | table.insert(self.balePlaces, entry); |
175 | end |
176 | i = i + 1; |
177 | end |
178 | |
179 | self.baleGrabParticleSystem = {}; |
180 | local psName = "vehicle.baleGrabParticleSystem"; |
181 | ParticleUtil.loadParticleSystem(self.xmlFile, self.baleGrabParticleSystem, psName, self.components, false, nil, self.baseDirectory); |
182 | self.baleGrabParticleSystemDisableTime = 0; |
183 | self.baleGrabParticleSystemDisableDuration = Utils.getNoNil(getXMLFloat(self.xmlFile, psName.."#disableDuration"), 0.6)*1000; |
184 | |
185 | if self.isClient then |
186 | self.sampleBaleGrab = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.baleGrabSound", nil, self.baseDirectory); |
187 | self.sampleBaleLoaderHydraulic = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.baleLoaderHydraulicSound", nil, self.baseDirectory); |
188 | end |
189 | |
190 | self.workTransportButton = InputBinding.IMPLEMENT_EXTRA; |
191 | self.emptyAbortButton = InputBinding.IMPLEMENT_EXTRA2; |
192 | self.emptyButton = InputBinding.IMPLEMENT_EXTRA3; |
193 | |
194 | --[[self.baleTypes = {}; |
195 | local i = 0; |
196 | while true do |
197 | local key = string.format("vehicle.baleTypes.baleType(%d)", i); |
198 | if not hasXMLProperty(self.xmlFile, key) then |
199 | break; |
200 | end |
201 | local filename = getXMLString(self.xmlFile, key.."#filename"); |
202 | if filename ~= nil then |
203 | filename = Utils.getFilename(filename, self.baseDirectory); |
204 | table.insert(self.baleTypes, filename); |
205 | end |
206 | i = i + 1; |
207 | end |
208 | if table.getn(self.baleTypes) == 0 then |
209 | table.insert(self.baleTypes, "data/maps/models/objects/strawbale/strawbaleBaler.i3d"); |
210 | end]] |
211 | |
212 | self.showInvalidBaleWarning = false; |
213 | self.allowedBaleTypes = {}; |
214 | local i =0; |
215 | while true do |
216 | local key = string.format("vehicle.baleTypes.baleType(%d)", i); |
217 | if not hasXMLProperty(self.xmlFile, key) then |
218 | break; |
219 | end |
220 | local minBaleDiameter = getXMLFloat(self.xmlFile, key.."#minBaleDiameter"); |
221 | local maxBaleDiameter = getXMLFloat(self.xmlFile, key.."#maxBaleDiameter"); |
222 | local minBaleWidth = getXMLFloat(self.xmlFile, key.."#minBaleWidth"); |
223 | local maxBaleWidth = getXMLFloat(self.xmlFile, key.."#maxBaleWidth"); |
224 | local minBaleHeight = getXMLFloat(self.xmlFile, key.."#minBaleHeight"); |
225 | local maxBaleHeight = getXMLFloat(self.xmlFile, key.."#maxBaleHeight"); |
226 | local minBaleLength = getXMLFloat(self.xmlFile, key.."#minBaleLength"); |
227 | local maxBaleLength = getXMLFloat(self.xmlFile, key.."#maxBaleLength"); |
228 | if minBaleDiameter ~= nil and maxBaleDiameter ~= nil and minBaleWidth ~= nil and maxBaleWidth ~= nil then |
229 | table.insert(self.allowedBaleTypes, { |
230 | minBaleDiameter = Utils.round(minBaleDiameter, 2), |
231 | maxBaleDiameter = Utils.round(maxBaleDiameter, 2), |
232 | minBaleWidth = Utils.round(minBaleWidth, 2), |
233 | maxBaleWidth = Utils.round(maxBaleWidth, 2)}); |
234 | elseif minBaleWidth ~= nil and maxBaleWidth ~= nil and minBaleHeight ~= nil and maxBaleHeight ~= nil and minBaleLength ~= nil and maxBaleLength ~= nil then |
235 | table.insert(self.allowedBaleTypes, { |
236 | minBaleWidth = Utils.round(minBaleWidth, 2), |
237 | maxBaleWidth = Utils.round(maxBaleWidth, 2), |
238 | minBaleHeight = Utils.round(minBaleHeight, 2), |
239 | maxBaleHeight = Utils.round(maxBaleHeight, 2), |
240 | minBaleLength = Utils.round(minBaleLength, 2), |
241 | maxBaleLength = Utils.round(maxBaleLength, 2) |
242 | }); |
243 | end |
244 | i = i + 1; |
245 | end |
246 | |
247 | self.baleloaderTurnedOnScrollers = Utils.loadScrollers(self.components, self.xmlFile, "vehicle.baleloaderTurnedOnScrollers.baleloaderTurnedOnScroller", {}, false); |
248 | |
249 | self.baleDummyFillType = next(self.fillUnits[1].fillTypes) |
250 | |
251 | self.transportPositionAfterUnloading = Utils.getNoNil(getXMLBool(self.xmlFile, "vehicle.baleLoader#transportPositionAfterUnloading"), true) |
252 | |
253 | self.synchronizeFullFillLevel = true; |
254 | end |
259 | function BaleLoader:postLoad(savegame) |
260 | if savegame ~= nil then |
261 | if Utils.getNoNil(getXMLBool(savegame.xmlFile, savegame.key.."#isInWorkPosition"), false) then |
262 | if not self.isInWorkPosition then |
263 | self.grabberIsMoving = true; |
264 | self.isInWorkPosition = true; |
265 | BaleLoader.moveToWorkPosition(self, true); |
266 | end |
267 | end; |
268 | |
269 | self.currentBalePlace = 1; |
270 | |
271 | self.startBalePlace.count = 0; |
272 | local numBales = 0 |
273 | if not savegame.resetVehicles then |
274 | local i=0; |
275 | while true do |
276 | local baleKey = savegame.key..string.format(".bale(%d)", i); |
277 | if not hasXMLProperty(savegame.xmlFile, baleKey) then |
278 | break; |
279 | end |
280 | local filename = getXMLString(savegame.xmlFile, baleKey.."#filename"); |
281 | if filename ~= nil then |
282 | filename = Utils.convertFromNetworkFilename(filename); |
283 | |
284 | local x,y,z = Utils.getVectorFromString(getXMLString(savegame.xmlFile, baleKey.."#position")); |
285 | local xRot,yRot,zRot = Utils.getVectorFromString(getXMLString(savegame.xmlFile, baleKey.."#rotation")); |
286 | local fillLevel = getXMLFloat(savegame.xmlFile, baleKey.."#fillLevel"); |
287 | local balePlace = getXMLInt(savegame.xmlFile, baleKey.."#balePlace"); |
288 | local helper = getXMLInt(savegame.xmlFile, baleKey.."#helper"); |
289 | if balePlace == nil or (balePlace > 0 and (x == nil or y == nil or z == nil or xRot == nil or yRot == nil or zRot == nil)) or (balePlace < 1 and helper == nil) then |
290 | print("Warning: Corrupt savegame, bale "..filename.." could not be loaded"); |
291 | else |
292 | local translation; |
293 | local rotation; |
294 | if balePlace > 0 then |
295 | translation = {x,y,z}; |
296 | rotation={xRot, yRot, zRot}; |
297 | else |
298 | translation = {0,0,0}; |
299 | rotation={0,0,0}; |
300 | end |
301 | local parentNode = nil; |
302 | local bales = nil; |
303 | if balePlace < 1 then |
304 | if self.startBalePlace.node ~= nil and helper <= self.startBalePlace.numOfPlaces then |
305 | parentNode = getChildAt(self.startBalePlace.node, helper-1); |
306 | if self.startBalePlace.bales == nil then |
307 | self.startBalePlace.bales = {}; |
308 | end |
309 | bales = self.startBalePlace.bales; |
310 | self.startBalePlace.count = self.startBalePlace.count+1; |
311 | end |
312 | elseif balePlace <= table.getn(self.balePlaces) then |
313 | self.currentBalePlace = math.max(self.currentBalePlace, balePlace+1); |
314 | parentNode = self.balePlaces[balePlace].node; |
315 | if self.balePlaces[balePlace].bales == nil then |
316 | self.balePlaces[balePlace].bales = {}; |
317 | end |
318 | bales = self.balePlaces[balePlace].bales; |
319 | end |
320 | if parentNode ~= nil then |
321 | local baleValueScale = getXMLFloat(savegame.xmlFile, baleKey.."#baleValueScale"); |
322 | local wrappingState = getXMLFloat(savegame.xmlFile, baleKey.."#wrappingState"); |
323 | numBales = numBales+1; |
324 | table.insert(self.balesToLoad, {parentNode=parentNode, filename=filename, bales=bales, translation=translation, rotation=rotation, fillLevel=fillLevel, baleValueScale=baleValueScale, wrappingState=wrappingState}); |
325 | end |
326 | end |
327 | end |
328 | i = i +1; |
329 | end |
330 | end |
331 | |
332 | -- update animations |
333 | BaleLoader.updateBalePlacesAnimations(self); |
334 | |
335 | self:setFillLevel(numBales, self.baleDummyFillType) |
336 | for i, place in pairs(self.balePlaces) do |
337 | if place.collision ~= nil then |
338 | if i <= numBales then |
339 | setCollisionMask(place.collision, 8194); |
340 | else |
341 | setCollisionMask(place.collision, 0); |
342 | end; |
343 | end; |
344 | end; |
345 | end |
346 | end |
384 | function BaleLoader:readStream(streamId, connection) |
385 | |
386 | self.isInWorkPosition = streamReadBool(streamId); |
387 | self.frontBalePusherDirection = streamReadIntN(streamId, 3); |
388 | self.rotatePlatformDirection = streamReadIntN(streamId, 3); |
389 | |
390 | -- note: we do not sync grabberMoveState, this may lead to visual artifacts for a few seconds at the bigging |
391 | |
392 | if self.isInWorkPosition then |
393 | BaleLoader.moveToWorkPosition(self); |
394 | end |
395 | |
396 | local emptyState = streamReadUIntN(streamId, 4); |
397 | |
398 | self.currentBalePlace = streamReadInt8(streamId); |
399 | |
400 | -- read bale at bale grabber |
401 | if streamReadBool(streamId) then |
402 | self.baleGrabber.currentBale = readNetworkNodeObjectId(streamId); |
403 | self.balesToMount[self.baleGrabber.currentBale] = {serverId=self.baleGrabber.currentBale, linkNode=self.baleGrabber.grabNode, trans={0,0,0}, rot={0,0,0} }; |
404 | end |
405 | |
406 | -- read bales at start bale places |
407 | self.startBalePlace.count = streamReadUIntN(streamId, 3); |
408 | for i=1, self.startBalePlace.count do |
409 | local baleServerId = readNetworkNodeObjectId(streamId); |
410 | |
411 | local attachNode = getChildAt(self.startBalePlace.node, i-1) |
412 | self.balesToMount[baleServerId] = {serverId=baleServerId, linkNode=attachNode, trans={0,0,0}, rot={0,0,0} }; |
413 | |
414 | table.insert(self.startBalePlace.bales, baleServerId); |
415 | end |
416 | |
417 | |
418 | -- read bales at normal bale places |
419 | for i=1, table.getn(self.balePlaces) do |
420 | local balePlace = self.balePlaces[i]; |
421 | |
422 | local numBales = streamReadUIntN(streamId, 3); |
423 | if numBales > 0 then |
424 | balePlace.bales = {}; |
425 | |
426 | for baleI=1, numBales do |
427 | local baleServerId = readNetworkNodeObjectId(streamId); |
428 | local x = streamReadFloat32(streamId); |
429 | local y = streamReadFloat32(streamId); |
430 | local z = streamReadFloat32(streamId); |
431 | |
432 | table.insert(balePlace.bales, baleServerId); |
433 | |
434 | self.balesToMount[baleServerId] = {serverId=baleServerId, linkNode=balePlace.node, trans={ x,y,z}, rot={0,0,0} }; |
435 | end |
436 | end |
437 | end |
438 | |
439 | -- read num bales on platform |
440 | -- read bales on baleloader |
441 | -- ignore |
442 | |
443 | -- grabberMoveState ? int:nil |
444 | -- isInWorkPosition bool |
445 | -- emptyState ? int:nil |
446 | -- rotatePlatformDirection |
447 | -- frontBalePusherDirection |
448 | -- grabberIsMoving: bool |
449 | |
450 | |
451 | -- update animations |
452 | BaleLoader.updateBalePlacesAnimations(self); |
453 | |
454 | if emptyState >= BaleLoader.EMPTY_TO_WORK then |
455 | self:doStateChange(BaleLoader.CHANGE_EMPTY_START); |
456 | AnimatedVehicle.updateAnimations(self, 99999999); |
457 | if emptyState >= BaleLoader.EMPTY_ROTATE_PLATFORM then |
458 | self:doStateChange(BaleLoader.CHANGE_EMPTY_ROTATE_PLATFORM); |
459 | AnimatedVehicle.updateAnimations(self, 99999999); |
460 | if emptyState >= BaleLoader.EMPTY_ROTATE1 then |
461 | self:doStateChange(BaleLoader.CHANGE_EMPTY_ROTATE1); |
462 | AnimatedVehicle.updateAnimations(self, 99999999); |
463 | if emptyState >= BaleLoader.EMPTY_CLOSE_GRIPPERS then |
464 | self:doStateChange(BaleLoader.CHANGE_EMPTY_CLOSE_GRIPPERS); |
465 | AnimatedVehicle.updateAnimations(self, 99999999); |
466 | if emptyState >= BaleLoader.EMPTY_HIDE_PUSHER1 then |
467 | self:doStateChange(BaleLoader.CHANGE_EMPTY_HIDE_PUSHER1); |
468 | AnimatedVehicle.updateAnimations(self, 99999999); |
469 | if emptyState >= BaleLoader.EMPTY_HIDE_PUSHER2 then |
470 | self:doStateChange(BaleLoader.CHANGE_EMPTY_HIDE_PUSHER2); |
471 | AnimatedVehicle.updateAnimations(self, 99999999); |
472 | if emptyState >= BaleLoader.EMPTY_ROTATE2 then |
473 | self:doStateChange(BaleLoader.CHANGE_EMPTY_ROTATE2); |
474 | AnimatedVehicle.updateAnimations(self, 99999999); |
475 | if emptyState >= BaleLoader.EMPTY_WAIT_TO_DROP then |
476 | self:doStateChange(BaleLoader.CHANGE_EMPTY_WAIT_TO_DROP); |
477 | AnimatedVehicle.updateAnimations(self, 99999999); |
478 | if emptyState == BaleLoader.EMPTY_CANCEL or emptyState == BaleLoader.EMPTY_WAIT_TO_REDO then |
479 | self:doStateChange(BaleLoader.CHANGE_EMPTY_CANCEL); |
480 | AnimatedVehicle.updateAnimations(self, 99999999); |
481 | if emptyState == BaleLoader.EMPTY_WAIT_TO_REDO then |
482 | self:doStateChange(BaleLoader.CHANGE_EMPTY_WAIT_TO_REDO); |
483 | AnimatedVehicle.updateAnimations(self, 99999999); |
484 | end |
485 | elseif emptyState == BaleLoader.EMPTY_WAIT_TO_SINK or emptyState == BaleLoader.EMPTY_SINK then |
486 | self:doStateChange(BaleLoader.CHANGE_DROP_BALES); |
487 | AnimatedVehicle.updateAnimations(self, 99999999); |
488 | |
489 | if emptyState == BaleLoader.EMPTY_SINK then |
490 | self:doStateChange(BaleLoader.CHANGE_SINK); |
491 | AnimatedVehicle.updateAnimations(self, 99999999); |
492 | end |
493 | end |
494 | end |
495 | |
496 | end |
497 | end |
498 | end |
499 | end |
500 | end |
501 | end |
502 | end |
503 | self.emptyState = emptyState; |
504 | end |
626 | function BaleLoader:update(dt) |
627 | |
628 | if self.firstTimeRun then |
629 | for k,v in pairs(self.balesToLoad) do |
630 | local baleObject = Bale:new(self.isServer, self.isClient); |
631 | local x,y,z = unpack(v.translation); |
632 | local rx,ry,rz = unpack(v.rotation); |
633 | baleObject:load(v.filename, x,y,z,rx,ry,rz, v.fillLevel); |
634 | baleObject:mount(self, v.parentNode, x,y,z, rx,ry,rz); |
635 | if v.baleValueScale ~= nil then |
636 | baleObject.baleValueScale = v.baleValueScale; |
637 | end |
638 | if v.wrappingState ~= nil and baleObject.setWrappingState ~= nil then |
639 | baleObject:setWrappingState(v.wrappingState); |
640 | end |
641 | baleObject:register(); |
642 | |
643 | table.insert(v.bales, networkGetObjectId(baleObject)); |
644 | self.balesToLoad[k] = nil; |
645 | end |
646 | |
647 | for k, baleToMount in pairs(self.balesToMount) do |
648 | local bale = networkGetObject(baleToMount.serverId); |
649 | if bale ~= nil then |
650 | local x,y,z = unpack(baleToMount.trans); |
651 | local rx,ry,rz = unpack(baleToMount.rot); |
652 | |
653 | bale:mount(self, baleToMount.linkNode, x,y,z, rx,ry,rz); |
654 | self.balesToMount[k] = nil; |
655 | end |
656 | end |
657 | end |
658 | |
659 | if self:getIsActive() then |
660 | if self:getIsActiveForInput() and self.isClient then |
661 | if InputBinding.hasEvent(self.emptyButton) then |
662 | g_client:getServerConnection():sendEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_BUTTON_EMPTY)); |
663 | elseif InputBinding.hasEvent(self.emptyAbortButton) then |
664 | g_client:getServerConnection():sendEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_BUTTON_EMPTY_ABORT)); |
665 | elseif InputBinding.hasEvent(self.workTransportButton) then |
666 | g_client:getServerConnection():sendEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_BUTTON_WORK_TRANSPORT)); |
667 | end |
668 | end |
669 | |
670 | if self.isClient then |
671 | if self.baleGrabParticleSystemDisableTime ~= 0 and self.baleGrabParticleSystemDisableTime < g_currentMission.time then |
672 | ParticleUtil.setEmittingState(self.baleGrabParticleSystem, false); |
673 | self.baleGrabParticleSystemDisableTime = 0; |
674 | end |
675 | end |
676 | |
677 | -- check if grabber is still moving |
678 | if self.grabberIsMoving then |
679 | if not self:getIsAnimationPlaying("baleGrabberTransportToWork") then |
680 | self.grabberIsMoving = false; |
681 | end |
682 | end |
683 | |
684 | self.allowGrabbing = false; |
685 | if self.isInWorkPosition and not self.grabberIsMoving and self.grabberMoveState == nil and self.startBalePlace.count < self.startBalePlace.numOfPlaces and self.frontBalePusherDirection == 0 and self.rotatePlatformDirection == 0 and (not self.alwaysMoveBalePlaces or not self:getIsAnimationPlaying("moveBalePlaces")) and self.emptyState == BaleLoader.EMPTY_NONE and self:getFillLevel(self.baleDummyFillType) < self:getCapacity(self.baleDummyFillType) then |
686 | self.allowGrabbing = true; |
687 | end |
688 | |
689 | self.showInvalidBaleWarning = false; |
690 | if self.allowGrabbing then |
691 | if self.baleGrabber.grabNode ~= nil and self.baleGrabber.currentBale == nil then |
692 | -- find nearest bale |
693 | local nearestBale, nearestBaleType = BaleLoader.getBaleInRange(self, self.baleGrabber.grabNode); |
694 | if nearestBale ~= nil then |
695 | if nearestBaleType == nil then |
696 | self.showInvalidBaleWarning = true; |
697 | elseif self.isServer then |
698 | self:pickupBale(nearestBale, nearestBaleType); |
699 | end |
700 | end |
701 | end |
702 | end |
703 | if self.isServer then |
704 | if self.grabberMoveState ~= nil then |
705 | if self.grabberMoveState == BaleLoader.GRAB_MOVE_UP then |
706 | if not self:getIsAnimationPlaying("baleGrabberWorkToDrop") then |
707 | --BaleLoader.CHANGE_GRAB_MOVE_UP |
708 | -- switch to grabberMoveState |
709 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_GRAB_MOVE_UP), true, nil, self); |
710 | end |
711 | elseif self.grabberMoveState == BaleLoader.GRAB_DROP_BALE then |
712 | if not self:getIsAnimationPlaying(self.currentBaleGrabberDropBaleAnimName) then |
713 | --BaleLoader.CHANGE_GRAB_DROP_BALE |
714 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_GRAB_DROP_BALE), true, nil, self); |
715 | end |
716 | elseif self.grabberMoveState == BaleLoader.GRAB_MOVE_DOWN then |
717 | --BaleLoader.CHANGE_GRAB_MOVE_DOWN |
718 | if not self:getIsAnimationPlaying("baleGrabberWorkToDrop") then |
719 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_GRAB_MOVE_DOWN), true, nil, self); |
720 | end |
721 | end |
722 | end |
723 | if self.frontBalePusherDirection ~= 0 then |
724 | if not self:getIsAnimationPlaying("frontBalePusher") then |
725 | --BaleLoader.CHANGE_FRONT_PUSHER |
726 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_FRONT_PUSHER), true, nil, self); |
727 | end |
728 | end |
729 | if self.rotatePlatformDirection ~= 0 then |
730 | local name = self.rotatePlatformAnimName; |
731 | if self.rotatePlatformDirection < 0 then |
732 | name = self.rotatePlatformBackAnimName; |
733 | end |
734 | if not self:getIsAnimationPlaying(name) and not self:getIsAnimationPlaying("moveBalePlacesExtrasOnce") then |
735 | --BaleLoader.CHANGE_ROTATE_PLATFORM |
736 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_ROTATE_PLATFORM), true, nil, self); |
737 | end |
738 | end |
739 | |
740 | if self.emptyState ~= BaleLoader.EMPTY_NONE then |
741 | if self.emptyState == BaleLoader.EMPTY_TO_WORK then |
742 | if not self:getIsAnimationPlaying("baleGrabberTransportToWork") then |
743 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_ROTATE_PLATFORM), true, nil, self); |
744 | end |
745 | elseif self.emptyState == BaleLoader.EMPTY_ROTATE_PLATFORM then |
746 | if not self:getIsAnimationPlaying(self.rotatePlatformEmptyAnimName) then |
747 | --BaleLoader.CHANGE_EMPTY_ROTATE1 |
748 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_ROTATE1), true, nil, self); |
749 | end |
750 | elseif self.emptyState == BaleLoader.EMPTY_ROTATE1 then |
751 | if not self:getIsAnimationPlaying("emptyRotate") and not self:getIsAnimationPlaying("moveBalePlacesToEmpty") then |
752 | --BaleLoader.CHANGE_EMPTY_CLOSE_GRIPPERS |
753 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_CLOSE_GRIPPERS), true, nil, self); |
754 | end |
755 | elseif self.emptyState == BaleLoader.EMPTY_CLOSE_GRIPPERS then |
756 | if not self:getIsAnimationPlaying("closeGrippers") then |
757 | --BaleLoader.CHANGE_EMPTY_HIDE_PUSHER1 |
758 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_HIDE_PUSHER1), true, nil, self); |
759 | end |
760 | elseif self.emptyState == BaleLoader.EMPTY_HIDE_PUSHER1 then |
761 | if not self:getIsAnimationPlaying("emptyHidePusher1") then |
762 | --BaleLoader.CHANGE_EMPTY_HIDE_PUSHER2 |
763 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_HIDE_PUSHER2), true, nil, self); |
764 | end |
765 | elseif self.emptyState == BaleLoader.EMPTY_HIDE_PUSHER2 then |
766 | if self:getAnimationTime("moveBalePusherToEmpty") < 0.7 or not self:getIsAnimationPlaying("moveBalePusherToEmpty") then |
767 | --BaleLoader.CHANGE_EMPTY_ROTATE2 |
768 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_ROTATE2), true, nil, self); |
769 | end |
770 | elseif self.emptyState == BaleLoader.EMPTY_ROTATE2 then |
771 | if not self:getIsAnimationPlaying("emptyRotate") then |
772 | --BaleLoader.CHANGE_EMPTY_WAIT_TO_DROP |
773 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_WAIT_TO_DROP), true, nil, self); |
774 | end |
775 | elseif self.emptyState == BaleLoader.EMPTY_SINK then |
776 | if not self:getIsAnimationPlaying("emptyRotate") and |
777 | not self:getIsAnimationPlaying("moveBalePlacesToEmpty") and |
778 | not self:getIsAnimationPlaying("emptyHidePusher1") and |
779 | not self:getIsAnimationPlaying(self.rotatePlatformEmptyAnimName) |
780 | then |
781 | --BaleLoader.CHANGE_EMPTY_STATE_NIL |
782 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_STATE_NIL), true, nil, self); |
783 | end |
784 | elseif self.emptyState == BaleLoader.EMPTY_CANCEL then |
785 | if not self:getIsAnimationPlaying("emptyRotate") then |
786 | --BaleLoader.CHANGE_EMPTY_WAIT_TO_REDO |
787 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_WAIT_TO_REDO), true, nil, self); |
788 | end |
789 | end |
790 | end |
791 | end |
792 | |
793 | if self.isClient then |
794 | local hasAnimationsPlaying = next(self.activeAnimations) ~= nil; |
795 | if hasAnimationsPlaying then |
796 | if self:getIsActiveForSound() then |
797 | SoundUtil.playSample(self.sampleBaleLoaderHydraulic, 0, 0, nil); |
798 | end |
799 | else |
800 | SoundUtil.stopSample(self.sampleBaleLoaderHydraulic); |
801 | end |
802 | end |
803 | end |
804 | |
805 | -- re mount bale in grabber, which was unmounted to be saved as normal bale |
806 | if self.baleGrabber.currentBaleIsUnmounted == true then |
807 | self.baleGrabber.currentBaleIsUnmounted = false; |
808 | local bale = networkGetObject(self.baleGrabber.currentBale); |
809 | if bale ~= nil then |
810 | bale:mount(self, self.baleGrabber.grabNode, 0,0,0, 0,0,0); |
811 | end |
812 | end |
813 | |
814 | end |
954 | function BaleLoader:doStateChange(id, nearestBaleServerId) |
955 | |
956 | if id == BaleLoader.CHANGE_DROP_BALES then |
957 | -- drop all bales to ground (and add to save by mission) |
958 | self.currentBalePlace = 1; |
959 | for _, balePlace in pairs(self.balePlaces) do |
960 | if balePlace.bales ~= nil then |
961 | for _, baleServerId in pairs(balePlace.bales) do |
962 | local bale = networkGetObject(baleServerId); |
963 | if bale ~= nil then |
964 | bale:unmount(); |
965 | end |
966 | self.balesToMount[baleServerId] = nil; |
967 | end |
968 | balePlace.bales = nil; |
969 | end |
970 | end |
971 | |
972 | self:setFillLevel(0, self.baleDummyFillType) |
973 | for _, place in pairs(self.balePlaces) do |
974 | if place.collision ~= nil then |
975 | setCollisionMask(place.collision, 0); |
976 | end; |
977 | end; |
978 | |
979 | self:playAnimation("releaseFrontplattform", 1, nil, true); |
980 | self:playAnimation("closeGrippers", -1, nil, true); |
981 | self.emptyState = BaleLoader.EMPTY_WAIT_TO_SINK; |
982 | elseif id == BaleLoader.CHANGE_SINK then |
983 | self:playAnimation("emptyRotate", -1, nil, true); |
984 | self:playAnimation("moveBalePlacesToEmpty", -1, nil, true); |
985 | self:playAnimation("emptyHidePusher1", -1, nil, true); |
986 | self:playAnimation(self.rotatePlatformEmptyAnimName, -1, nil, true); |
987 | if not self.isInWorkPosition then |
988 | self:playAnimation("closeGrippers", 1, self:getAnimationTime("closeGrippers"), true); |
989 | self:playAnimation("baleGrabberTransportToWork", 1, nil, true); |
990 | end |
991 | self.emptyState = BaleLoader.EMPTY_SINK; |
992 | elseif id == BaleLoader.CHANGE_EMPTY_REDO then |
993 | self:playAnimation("emptyRotate", 1, nil, true); |
994 | self.emptyState = BaleLoader.EMPTY_ROTATE2; |
995 | elseif id == BaleLoader.CHANGE_EMPTY_START then |
996 | -- move to work position in case it is not there now |
997 | BaleLoader.moveToWorkPosition(self); |
998 | self.emptyState = BaleLoader.EMPTY_TO_WORK; |
999 | elseif id == BaleLoader.CHANGE_EMPTY_CANCEL then |
1000 | self:playAnimation("emptyRotate", -1, nil, true); |
1001 | self.emptyState = BaleLoader.EMPTY_CANCEL; |
1002 | elseif id == BaleLoader.CHANGE_MOVE_TO_TRANSPORT then |
1003 | if self.isInWorkPosition then |
1004 | self.grabberIsMoving = true; |
1005 | self.isInWorkPosition = false; |
1006 | -- move to transport position |
1007 | BaleLoader.moveToTransportPosition(self); |
1008 | end |
1009 | elseif id == BaleLoader.CHANGE_MOVE_TO_WORK then |
1010 | if not self.isInWorkPosition then |
1011 | self.grabberIsMoving = true; |
1012 | self.isInWorkPosition = true; |
1013 | -- move to work position |
1014 | BaleLoader.moveToWorkPosition(self); |
1015 | end |
1016 | elseif id == BaleLoader.CHANGE_GRAB_BALE then |
1017 | local bale = networkGetObject(nearestBaleServerId); |
1018 | self.baleGrabber.currentBale = nearestBaleServerId; |
1019 | if bale ~= nil then |
1020 | bale:mount(self, self.baleGrabber.grabNode, 0,0,0, 0,0,0); |
1021 | self.balesToMount[nearestBaleServerId] = nil; |
1022 | else |
1023 | self.balesToMount[nearestBaleServerId] = {serverId=nearestBaleServerId, linkNode=self.baleGrabber.grabNode, trans={0,0,0}, rot={0,0,0} }; |
1024 | end |
1025 | self.grabberMoveState = BaleLoader.GRAB_MOVE_UP; |
1026 | self:playAnimation("baleGrabberWorkToDrop", 1, nil, true); |
1027 | |
1028 | self:setFillLevel(math.floor(self:getFillLevel(self.baleDummyFillType)+0.5)+1, self.baleDummyFillType) |
1029 | for i, place in pairs(self.balePlaces) do |
1030 | if place.collision ~= nil then |
1031 | if i <= self:getFillLevel(self.baleDummyFillType) then |
1032 | setCollisionMask(place.collision, 8194); |
1033 | else |
1034 | setCollisionMask(place.collision, 0); |
1035 | end; |
1036 | end; |
1037 | end; |
1038 | |
1039 | if self.isClient then |
1040 | if self:getIsActiveForSound() then |
1041 | SoundUtil.playSample(self.sampleBaleGrab, 1, 0, nil); |
1042 | end |
1043 | ParticleUtil.setEmittingState(self.baleGrabParticleSystem, true); |
1044 | self.baleGrabParticleSystemDisableTime = g_currentMission.time + self.baleGrabParticleSystemDisableDuration; |
1045 | end |
1046 | elseif id == BaleLoader.CHANGE_GRAB_MOVE_UP then |
1047 | self.currentBaleGrabberDropBaleAnimName = self:getBaleGrabberDropBaleAnimName(); |
1048 | self:playAnimation(self.currentBaleGrabberDropBaleAnimName, 1, nil, true); |
1049 | self.grabberMoveState = BaleLoader.GRAB_DROP_BALE; |
1050 | elseif id == BaleLoader.CHANGE_GRAB_DROP_BALE then |
1051 | -- drop bale at platform |
1052 | if self.startBalePlace.count < self.startBalePlace.numOfPlaces and self.startBalePlace.node ~= nil then |
1053 | local attachNode = getChildAt(self.startBalePlace.node, self.startBalePlace.count) |
1054 | local bale = networkGetObject(self.baleGrabber.currentBale); |
1055 | if bale ~= nil then |
1056 | bale:mount(self, attachNode, 0,0,0, 0,0,0); |
1057 | self.balesToMount[self.baleGrabber.currentBale] = nil; |
1058 | else |
1059 | self.balesToMount[self.baleGrabber.currentBale] = {serverId=self.baleGrabber.currentBale, linkNode=attachNode, trans={0,0,0}, rot={0,0,0} }; |
1060 | end |
1061 | |
1062 | self.startBalePlace.count = self.startBalePlace.count + 1; |
1063 | table.insert(self.startBalePlace.bales, self.baleGrabber.currentBale); |
1064 | self.baleGrabber.currentBale = nil; |
1065 | --setRotation(baleNode, 0, 0, 0); |
1066 | --setTranslation(baleNode, 0, 0, 0); |
1067 | |
1068 | if self.startBalePlace.count < self.startBalePlace.numOfPlaces then |
1069 | self.frontBalePusherDirection = 1; |
1070 | self:playAnimation("balesToOtherRow", 1, nil, true); |
1071 | self:playAnimation("frontBalePusher", 1, nil, true); |
1072 | elseif self.startBalePlace.count == self.startBalePlace.numOfPlaces then |
1073 | BaleLoader.rotatePlatform(self); |
1074 | end |
1075 | |
1076 | self:playAnimation(self.currentBaleGrabberDropBaleAnimName, -5, nil, true); |
1077 | self:playAnimation("baleGrabberWorkToDrop", -1, nil, true); |
1078 | self.grabberMoveState = BaleLoader.GRAB_MOVE_DOWN; |
1079 | end |
1080 | elseif id == BaleLoader.CHANGE_GRAB_MOVE_DOWN then |
1081 | self.grabberMoveState = nil; |
1082 | elseif id == BaleLoader.CHANGE_FRONT_PUSHER then |
1083 | if self.frontBalePusherDirection > 0 then |
1084 | self:playAnimation("frontBalePusher", -1, nil, true); |
1085 | self.frontBalePusherDirection = -1; |
1086 | else |
1087 | self.frontBalePusherDirection = 0; |
1088 | end |
1089 | elseif id == BaleLoader.CHANGE_ROTATE_PLATFORM then |
1090 | if self.rotatePlatformDirection > 0 then |
1091 | -- drop bales |
1092 | local balePlace = self.balePlaces[self.currentBalePlace]; |
1093 | self.currentBalePlace = self.currentBalePlace + 1; |
1094 | for i=1, table.getn(self.startBalePlace.bales) do |
1095 | local node = getChildAt(self.startBalePlace.node, i-1); |
1096 | local x,y,z = getTranslation(node); |
1097 | local rx,ry,rz = getRotation(node); |
1098 | local baleServerId = self.startBalePlace.bales[i]; |
1099 | local bale = networkGetObject(baleServerId); |
1100 | if bale ~= nil then |
1101 | bale:mount(self, balePlace.node, x,y,z, rx,ry,rz); |
1102 | self.balesToMount[baleServerId] = nil; |
1103 | else |
1104 | self.balesToMount[baleServerId] = {serverId=baleServerId, linkNode=balePlace.node, trans={ x,y,z}, rot={rx,ry,rz} }; |
1105 | end |
1106 | end |
1107 | balePlace.bales = self.startBalePlace.bales; |
1108 | self.startBalePlace.bales = {}; |
1109 | self.startBalePlace.count = 0; |
1110 | |
1111 | for i=1, self.startBalePlace.numOfPlaces do |
1112 | local node = getChildAt(self.startBalePlace.node, i-1); |
1113 | setRotation(node, unpack(self.startBalePlace.origRot[i])); |
1114 | setTranslation(node, unpack(self.startBalePlace.origTrans[i])); |
1115 | end |
1116 | |
1117 | if self.emptyState == BaleLoader.EMPTY_NONE then |
1118 | -- we are not waiting to start emptying, rotate back |
1119 | self.rotatePlatformDirection = -1; |
1120 | self:playAnimation(self.rotatePlatformBackAnimName, -1, nil, true); |
1121 | |
1122 | if self.moveBalePlacesAfterRotatePlatform then |
1123 | -- currentBalePlace+1 needs to be at the first position |
1124 | if self.currentBalePlace <= table.getn(self.balePlaces) or self.alwaysMoveBalePlaces then |
1125 | self:playAnimation("moveBalePlaces", 1, (self.currentBalePlace-1)/table.getn(self.balePlaces), true); |
1126 | self:setAnimationStopTime("moveBalePlaces", (self.currentBalePlace)/table.getn(self.balePlaces)); |
1127 | self:playAnimation("moveBalePlacesExtrasOnce", 1, nil, true); |
1128 | end |
1129 | end |
1130 | else |
1131 | self.rotatePlatformDirection = 0; |
1132 | end |
1133 | else |
1134 | self.rotatePlatformDirection = 0; |
1135 | end |
1136 | elseif id == BaleLoader.CHANGE_EMPTY_ROTATE_PLATFORM then |
1137 | self.emptyState = BaleLoader.EMPTY_ROTATE_PLATFORM; |
1138 | if self.startBalePlace.count == 0 then |
1139 | self:playAnimation(self.rotatePlatformEmptyAnimName, 1, nil, true); |
1140 | else |
1141 | BaleLoader.rotatePlatform(self) |
1142 | end |
1143 | elseif id == BaleLoader.CHANGE_EMPTY_ROTATE1 then |
1144 | self:playAnimation("emptyRotate", 1, nil, true); |
1145 | self:setAnimationStopTime("emptyRotate", 0.2); |
1146 | local balePlacesTime = self:getRealAnimationTime("moveBalePlaces"); |
1147 | self:playAnimation("moveBalePlacesToEmpty", 1.5, balePlacesTime/self:getAnimationDuration("moveBalePlacesToEmpty"), true); |
1148 | self:playAnimation("moveBalePusherToEmpty", 1.5, balePlacesTime/self:getAnimationDuration("moveBalePusherToEmpty"), true); |
1149 | self.emptyState = BaleLoader.EMPTY_ROTATE1; |
1150 | elseif id == BaleLoader.CHANGE_EMPTY_CLOSE_GRIPPERS then |
1151 | self:playAnimation("closeGrippers", 1, nil, true); |
1152 | self.emptyState = BaleLoader.EMPTY_CLOSE_GRIPPERS; |
1153 | elseif id == BaleLoader.CHANGE_EMPTY_HIDE_PUSHER1 then |
1154 | self:playAnimation("emptyHidePusher1", 1, nil, true); |
1155 | self.emptyState = BaleLoader.EMPTY_HIDE_PUSHER1; |
1156 | elseif id == BaleLoader.CHANGE_EMPTY_HIDE_PUSHER2 then |
1157 | self:playAnimation("moveBalePusherToEmpty", -2, nil, true); |
1158 | self.emptyState = BaleLoader.EMPTY_HIDE_PUSHER2; |
1159 | elseif id == BaleLoader.CHANGE_EMPTY_ROTATE2 then |
1160 | self:playAnimation("emptyRotate", 1, self:getAnimationTime("emptyRotate"), true); |
1161 | self.emptyState = BaleLoader.EMPTY_ROTATE2; |
1162 | elseif id == BaleLoader.CHANGE_EMPTY_WAIT_TO_DROP then |
1163 | -- wait for the user to react (abort or drop) |
1164 | self.emptyState = BaleLoader.EMPTY_WAIT_TO_DROP; |
1165 | elseif id == BaleLoader.CHANGE_EMPTY_STATE_NIL then |
1166 | self.emptyState = BaleLoader.EMPTY_NONE; |
1167 | if self.transportPositionAfterUnloading then |
1168 | BaleLoader.moveToTransportPosition(self); |
1169 | if self.isServer then |
1170 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_MOVE_TO_TRANSPORT), true, nil, self); |
1171 | end |
1172 | end; |
1173 | elseif id == BaleLoader.CHANGE_EMPTY_WAIT_TO_REDO then |
1174 | self.emptyState = BaleLoader.EMPTY_WAIT_TO_REDO; |
1175 | elseif id == BaleLoader.CHANGE_BUTTON_EMPTY then |
1176 | -- Server only code |
1177 | assert(self.isServer); |
1178 | if self.emptyState ~= BaleLoader.EMPTY_NONE then |
1179 | if self.emptyState == BaleLoader.EMPTY_WAIT_TO_DROP then |
1180 | -- BaleLoader.CHANGE_DROP_BALES |
1181 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_DROP_BALES), true, nil, self); |
1182 | elseif self.emptyState == BaleLoader.EMPTY_WAIT_TO_SINK then |
1183 | -- BaleLoader.CHANGE_SINK |
1184 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_SINK), true, nil, self); |
1185 | elseif self.emptyState == BaleLoader.EMPTY_WAIT_TO_REDO then |
1186 | -- BaleLoader.CHANGE_EMPTY_REDO |
1187 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_REDO), true, nil, self); |
1188 | end |
1189 | else |
1190 | --BaleLoader.CHANGE_EMPTY_START |
1191 | if BaleLoader.getAllowsStartUnloading(self) then |
1192 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_START), true, nil, self); |
1193 | end |
1194 | end |
1195 | elseif id == BaleLoader.CHANGE_BUTTON_EMPTY_ABORT then |
1196 | -- Server only code |
1197 | assert(self.isServer); |
1198 | if self.emptyState ~= BaleLoader.EMPTY_NONE then |
1199 | if self.emptyState == BaleLoader.EMPTY_WAIT_TO_DROP then |
1200 | --BaleLoader.CHANGE_EMPTY_CANCEL |
1201 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_EMPTY_CANCEL), true, nil, self); |
1202 | end |
1203 | end |
1204 | elseif id == BaleLoader.CHANGE_BUTTON_WORK_TRANSPORT then |
1205 | -- Server only code |
1206 | assert(self.isServer); |
1207 | if self.emptyState == BaleLoader.EMPTY_NONE and self.grabberMoveState == nil then |
1208 | if self.isInWorkPosition then |
1209 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_MOVE_TO_TRANSPORT), true, nil, self); |
1210 | else |
1211 | g_server:broadcastEvent(BaleLoaderStateEvent:new(self, BaleLoader.CHANGE_MOVE_TO_WORK), true, nil, self); |
1212 | end |
1213 | end |
1214 | end |
1215 | end |