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 | TrailerToggleTipEvent = {}; |
4 | TrailerToggleTipEvent_mt = Class(TrailerToggleTipEvent, Event); |
5 | |
6 | InitStaticEventClass(TrailerToggleTipEvent, "TrailerToggleTipEvent", EventIds.EVENT_TRAILER_TOGGLE_TIP); |
7 | |
8 | -- TODO FS17: remove |
9 | g_toggleTipEventManualTippingFixEnabled = true; |
10 | |
11 | function TrailerToggleTipEvent:emptyNew() |
12 | local self = Event:new(TrailerToggleTipEvent_mt); |
13 | return self; |
14 | end; |
15 | |
16 | function TrailerToggleTipEvent:new(object, isStart, tipTrigger, tipReferencePointIndex, tipManually) |
17 | local self = TrailerToggleTipEvent:emptyNew() |
18 | self.isStart = isStart; |
19 | self.tipTrigger = tipTrigger; |
20 | self.tipReferencePointIndex = Utils.getNoNil(tipReferencePointIndex, 1); |
21 | assert(self.tipReferencePointIndex <= 15); |
22 | self.object = object; |
23 | self.tipManually = Utils.getNoNil(tipManually, false); |
24 | return self; |
25 | end; |
26 | |
27 | function TrailerToggleTipEvent:readStream(streamId, connection) |
28 | local id = streamReadInt32(streamId); |
29 | self.isStart = streamReadBool(streamId); |
30 | if self.isStart then |
31 | local triggerId = streamReadInt32(streamId); |
32 | if triggerId ~= 0 then |
33 | self.tipTrigger = networkGetObject(triggerId); |
34 | end; |
35 | self.tipReferencePointIndex = streamReadUIntN(streamId, 4); |
36 | self.tipManually = streamReadBool(streamId); |
37 | end; |
38 | self.object = networkGetObject(id); |
39 | self:run(connection); |
40 | end; |
41 | |
42 | function TrailerToggleTipEvent:writeStream(streamId, connection) |
43 | streamWriteInt32(streamId, networkGetObjectId(self.object)); |
44 | streamWriteBool(streamId, self.isStart); |
45 | if self.isStart then |
46 | local triggerId = 0; |
47 | if self.tipTrigger ~= nil then |
48 | triggerId = networkGetObjectId(self.tipTrigger); |
49 | end; |
50 | streamWriteInt32(streamId, triggerId); |
51 | streamWriteUIntN(streamId, self.tipReferencePointIndex, 4); |
52 | streamWriteBool(streamId, self.tipManually); |
53 | end; |
54 | end; |
55 | |
56 | function TrailerToggleTipEvent:run(connection) |
57 | if not connection:getIsServer() then |
58 | g_server:broadcastEvent(self, false, connection, self.object); |
59 | end; |
60 | |
61 | if self.isStart then |
62 | self.object:onStartTip(self.tipTrigger, self.tipReferencePointIndex, true, self.tipManually); |
63 | else |
64 | self.object:onEndTip(true); |
65 | end; |
66 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de