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