Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
2 | |
3 | FillableTipTrigger = {}; |
4 | |
5 | local FillableTipTrigger_mt = Class(FillableTipTrigger, TipTrigger); |
6 | |
7 | InitStaticObjectClass(FillableTipTrigger, "FillableTipTrigger", ObjectIds.OBJECT_FILLABLE_TIP_TRIGGER); |
8 | |
9 | function FillableTipTrigger:new(isServer, isClient, customMt) |
10 | if customMt == nil then |
11 | customMt = FillableTipTrigger_mt; |
12 | end |
13 | local self = TipTrigger:new(isServer, isClient, customMt); |
14 | return self; |
15 | end; |
16 | |
17 | function FillableTipTrigger:load(id, fillable) |
18 | self.fillable = fillable; |
19 | |
20 | -- overwrite fill type loading |
21 | self.priceMultipliers = {}; |
22 | self.acceptedFillTypes = {}; |
23 | return FillableTipTrigger:superClass().load(self, id); |
24 | end; |
25 | |
26 | function FillableTipTrigger:delete() |
27 | FillableTipTrigger:superClass().delete(self); |
28 | end; |
29 | |
30 | function FillableTipTrigger:readStream(streamId, connection) |
31 | if connection:getIsServer() then |
32 | if self.movingId ~= nil then |
33 | local x,y,z = getTranslation(self.movingId); |
34 | y = streamReadFloat32(streamId); |
35 | setTranslation(self.movingId, x, y, z); |
36 | end; |
37 | end; |
38 | end |
39 | |
40 | function FillableTipTrigger:updateTrailerTipping(trailer, fillDelta, fillType) |
41 | if fillDelta < 0 then |
42 | self.fillable:resetFillLevelIfNeeded(fillType); |
43 | local fillLevel = self.fillable:getFillLevel(fillType); |
44 | self.fillable:setFillLevel(fillLevel - fillDelta, fillType); |
45 | end |
46 | end |
47 | |
48 | |
49 | function FillableTipTrigger:getTipInfoForTrailer(trailer, tipReferencePointIndex) |
50 | if self.fillable.getAllowFillShovel ~= nil then |
51 | if not self.fillable:getAllowFillShovel(trailer.currentFillType) then |
52 | return true, math.huge; |
53 | end |
54 | else |
55 | if not self.fillable:allowFillType(trailer.currentFillType) then |
56 | return true, math.huge; |
57 | end |
58 | end |
59 | if self.fillable:getFillLevel(trailer.currentFillType) >= self.fillable:getCapacity() then |
60 | return true, math.huge; |
61 | end |
62 | local minDistance, bestPoint = self:getTipDistanceFromTrailer(trailer, tipReferencePointIndex); |
63 | |
64 | local isAllowed = true; |
65 | return isAllowed, minDistance, bestPoint; |
66 | end |
67 | |
68 | function FillableTipTrigger:getTipDistanceFromTrailer(trailer, tipReferencePointIndex) |
69 | |
70 | return FillableTipTrigger:superClass().getTipDistanceFromTrailer(self, trailer, tipReferencePointIndex); |
71 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de