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