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 | FoldableSetFoldDirectionEvent = {}; |
4 | FoldableSetFoldDirectionEvent_mt = Class(FoldableSetFoldDirectionEvent, Event); |
5 | |
6 | InitStaticEventClass(FoldableSetFoldDirectionEvent, "FoldableSetFoldDirectionEvent", EventIds.EVENT_FOLDABLE_SET_FOLD_DIRECTION); |
7 | |
8 | function FoldableSetFoldDirectionEvent:emptyNew() |
9 | local self = Event:new(FoldableSetFoldDirectionEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function FoldableSetFoldDirectionEvent:new(object, direction, moveToMiddle) |
14 | local self = FoldableSetFoldDirectionEvent:emptyNew() |
15 | self.object = object; |
16 | self.direction = Utils.sign(direction); |
17 | self.moveToMiddle = moveToMiddle; |
18 | return self; |
19 | end; |
20 | |
21 | function FoldableSetFoldDirectionEvent:readStream(streamId, connection) |
22 | local id = streamReadInt32(streamId); |
23 | self.direction = streamReadUIntN(streamId, 2)-1; |
24 | self.moveToMiddle = streamReadBool(streamId); |
25 | self.object = networkGetObject(id); |
26 | self:run(connection); |
27 | end; |
28 | |
29 | function FoldableSetFoldDirectionEvent:writeStream(streamId, connection) |
30 | streamWriteInt32(streamId, networkGetObjectId(self.object)); |
31 | streamWriteUIntN(streamId, self.direction+1, 2); |
32 | streamWriteBool(streamId, self.moveToMiddle); |
33 | end; |
34 | |
35 | function FoldableSetFoldDirectionEvent:run(connection) |
36 | if self.object ~= nil then |
37 | self.object:setFoldState(self.direction, self.moveToMiddle, true); |
38 | end; |
39 | if not connection:getIsServer() then |
40 | g_server:broadcastEvent(FoldableSetFoldDirectionEvent:new(self.object, self.direction, self.moveToMiddle), nil, connection, self.object); |
41 | end; |
42 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de