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