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 | ChainsawStateEvent = {}; |
4 | ChainsawStateEvent_mt = Class(ChainsawStateEvent, Event); |
5 | |
6 | InitStaticEventClass(ChainsawStateEvent, "ChainsawStateEvent", EventIds.EVENT_CHAINSAW_STATE); |
7 | |
8 | function ChainsawStateEvent:emptyNew() |
9 | local self = Event:new(ChainsawStateEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function ChainsawStateEvent:new(player, isCutting, isHorizontalCut) |
14 | local self = ChainsawStateEvent:emptyNew() |
15 | self.player = player; |
16 | self.isCutting = isCutting; |
17 | self.isHorizontalCut = isHorizontalCut; |
18 | return self; |
19 | end; |
20 | |
21 | function ChainsawStateEvent:readStream(streamId, connection) |
22 | self.player = networkGetObject(streamReadInt32(streamId)); |
23 | self.isCutting = streamReadBool(streamId); |
24 | self.isHorizontalCut = streamReadBool(streamId); |
25 | self:run(connection); |
26 | end; |
27 | |
28 | function ChainsawStateEvent:writeStream(streamId, connection) |
29 | streamWriteInt32(streamId, networkGetObjectId(self.player)); |
30 | streamWriteBool(streamId, self.isCutting); |
31 | streamWriteBool(streamId, self.isHorizontalCut); |
32 | end; |
33 | |
34 | function ChainsawStateEvent:run(connection) |
35 | if not connection:getIsServer() then |
36 | g_server:broadcastEvent(self, false, connection, self.player); |
37 | end; |
38 | |
39 | local currentTool = self.player.currentTool; |
40 | if currentTool ~= nil and currentTool.setCutting ~= nil then |
41 | currentTool:setCutting(self.isCutting, self.isHorizontalCut, true); |
42 | end; |
43 | end; |
44 | |
45 | function ChainsawStateEvent.sendEvent(player, isCutting, isHorizontalCut, noEventSend) |
46 | local currentTool = player.currentTool; |
47 | if currentTool ~= nil and currentTool.setCutting ~= nil and currentTool.isCutting ~= isCutting then |
48 | if noEventSend == nil or noEventSend == false then |
49 | if g_server ~= nil then |
50 | g_server:broadcastEvent(ChainsawStateEvent:new(player, isCutting, isHorizontalCut), nil, nil, player); |
51 | else |
52 | g_client:getServerConnection():sendEvent(ChainsawStateEvent:new(player, isCutting, isHorizontalCut)); |
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