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 | SetCoverStateEvent = {}; |
4 | SetCoverStateEvent_mt = Class(SetCoverStateEvent, Event); |
5 | |
6 | InitStaticEventClass(SetCoverStateEvent, "SetCoverStateEvent", EventIds.EVENT_SET_COVER_STATE); |
7 | |
8 | function SetCoverStateEvent:emptyNew() |
9 | local self = Event:new(SetCoverStateEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function SetCoverStateEvent:new(object, isOpen) |
14 | local self = SetCoverStateEvent:emptyNew() |
15 | self.object = object; |
16 | self.isOpen = isOpen; |
17 | return self; |
18 | end; |
19 | |
20 | function SetCoverStateEvent:readStream(streamId, connection) |
21 | local id = streamReadInt32(streamId); |
22 | self.object = networkGetObject(id); |
23 | self.isOpen = streamReadBool(streamId); |
24 | self:run(connection); |
25 | end; |
26 | |
27 | function SetCoverStateEvent:writeStream(streamId, connection) |
28 | streamWriteInt32(streamId, networkGetObjectId(self.object)); |
29 | streamWriteBool(streamId, self.isOpen); |
30 | end; |
31 | |
32 | function SetCoverStateEvent: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:setCoverState(self.isOpen, true); |
38 | end; |
39 | end; |
40 | |
41 | function SetCoverStateEvent.sendEvent(vehicle, isOpen, noEventSend) |
42 | if vehicle.isCoverOpen ~= isOpen then |
43 | if noEventSend == nil or noEventSend == false then |
44 | if g_server ~= nil then |
45 | g_server:broadcastEvent(SetCoverStateEvent:new(vehicle, isOpen), nil, nil, vehicle); |
46 | else |
47 | g_client:getServerConnection():sendEvent(SetCoverStateEvent:new(vehicle, isOpen)); |
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