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