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 | VehicleAttachEvent = {}; |
4 | VehicleAttachEvent_mt = Class(VehicleAttachEvent, Event); |
5 | |
6 | InitStaticEventClass(VehicleAttachEvent, "VehicleAttachEvent", EventIds.EVENT_VEHICLE_ATTACH); |
7 | |
8 | function VehicleAttachEvent:emptyNew() |
9 | local self = Event:new(VehicleAttachEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function VehicleAttachEvent:new(vehicle, implement, inputJointIndex, jointIndex, startLowered) |
14 | local self = VehicleAttachEvent:emptyNew() |
15 | self.jointIndex = jointIndex; |
16 | self.inputJointIndex = inputJointIndex; |
17 | self.vehicle = vehicle; |
18 | self.implement = implement; |
19 | self.startLowered = startLowered; |
20 | assert(self.jointIndex >= 0 and self.jointIndex < 127) |
21 | return self; |
22 | end; |
23 | |
24 | function VehicleAttachEvent:readStream(streamId, connection) |
25 | local id = streamReadInt32(streamId); |
26 | local implementId = streamReadInt32(streamId); |
27 | self.jointIndex = streamReadUIntN(streamId, 7); |
28 | self.inputJointIndex = streamReadUIntN(streamId, 7); |
29 | self.startLowered = streamReadBool(streamId); |
30 | self.vehicle = networkGetObject(id); |
31 | self.implement = networkGetObject(implementId); |
32 | self:run(connection); |
33 | end; |
34 | |
35 | function VehicleAttachEvent:writeStream(streamId, connection) |
36 | streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); |
37 | streamWriteInt32(streamId, networkGetObjectId(self.implement)); |
38 | streamWriteUIntN(streamId, self.jointIndex, 7); |
39 | streamWriteUIntN(streamId, self.inputJointIndex, 7); |
40 | streamWriteBool(streamId, self.startLowered); |
41 | end; |
42 | |
43 | function VehicleAttachEvent:run(connection) |
44 | self.vehicle:attachImplement(self.implement, self.inputJointIndex, self.jointIndex, true, nil, self.startLowered); |
45 | if not connection:getIsServer() then |
46 | g_server:broadcastEvent(self, nil, connection, self.object); |
47 | end; |
48 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de