Sprache Deutsch Language English

Script Dokumentation LS 2015 - FoldableSetFoldDirectionEvent (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/specializations/FoldableSetFoldDirectionEvent.lua

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
3FoldableSetFoldDirectionEvent = {};
4FoldableSetFoldDirectionEvent_mt = Class(FoldableSetFoldDirectionEvent, Event);
5
6InitStaticEventClass(FoldableSetFoldDirectionEvent, "FoldableSetFoldDirectionEvent", EventIds.EVENT_FOLDABLE_SET_FOLD_DIRECTION);
7
8function FoldableSetFoldDirectionEvent:emptyNew()
9 local self = Event:new(FoldableSetFoldDirectionEvent_mt);
10 return self;
11end;
12
13function 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;
19end;
20
21function 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);
27end;
28
29function FoldableSetFoldDirectionEvent:writeStream(streamId, connection)
30 streamWriteInt32(streamId, networkGetObjectId(self.object));
31 streamWriteUIntN(streamId, self.direction+1, 2);
32 streamWriteBool(streamId, self.moveToMiddle);
33end;
34
35function 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;
42end;
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
Script Dokumentation Übersicht