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 | PickupSetStateEvent = {}; |
4 | PickupSetStateEvent_mt = Class(PickupSetStateEvent, Event); |
5 | |
6 | InitStaticEventClass(PickupSetStateEvent, "PickupSetStateEvent", EventIds.EVENT_SET_PICKUP_STATE); |
7 | |
8 | function PickupSetStateEvent:emptyNew() |
9 | local self = Event:new(PickupSetStateEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function PickupSetStateEvent:new(object, isPickupLowered) |
14 | local self = PickupSetStateEvent:emptyNew() |
15 | self.object = object; |
16 | self.isPickupLowered = isPickupLowered; |
17 | return self; |
18 | end; |
19 | |
20 | function PickupSetStateEvent:readStream(streamId, connection) |
21 | local id = streamReadInt32(streamId); |
22 | self.isPickupLowered = streamReadBool(streamId); |
23 | self.object = networkGetObject(id); |
24 | self:run(connection); |
25 | end; |
26 | |
27 | function PickupSetStateEvent:writeStream(streamId, connection) |
28 | streamWriteInt32(streamId, networkGetObjectId(self.object)); |
29 | streamWriteBool(streamId, self.isPickupLowered); |
30 | end; |
31 | |
32 | function PickupSetStateEvent:run(connection) |
33 | if not connection:getIsServer() then |
34 | g_server:broadcastEvent(self, false, connection, self.object); |
35 | end; |
36 | if self.object ~= nil then |
37 | self.object:setPickupState(self.isPickupLowered, true); |
38 | end; |
39 | end; |
40 | |
41 | function PickupSetStateEvent.sendEvent(vehicle, isPickupLowered, noEventSend) |
42 | if isPickupLowered ~= vehicle.isPickupLowered then |
43 | if noEventSend == nil or noEventSend == false then |
44 | if g_server ~= nil then |
45 | g_server:broadcastEvent(PickupSetStateEvent:new(vehicle, isPickupLowered), nil, nil, vehicle); |
46 | else |
47 | g_client:getServerConnection():sendEvent(PickupSetStateEvent:new(vehicle, isPickupLowered)); |
48 | end; |
49 | end; |
50 | end; |
51 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de