Script Dokumentation LS 2015 - BaleWrapperStateEvent (Patch 1.3)
scripts/vehicles/specializations/BaleWrapperStateEvent.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 | |
3 | BaleWrapperStateEvent = {}; |
4 | BaleWrapperStateEvent_mt = Class(BaleWrapperStateEvent, Event); |
5 | |
6 | InitStaticEventClass(BaleWrapperStateEvent, "BaleWrapperStateEvent", EventIds.EVENT_BALE_WRAPPER_STATE); |
7 | |
8 | function BaleWrapperStateEvent:emptyNew() |
9 | local self = Event:new(BaleWrapperStateEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function BaleWrapperStateEvent:new(object, stateId, nearestBaleServerId) |
14 | local self = BaleWrapperStateEvent:emptyNew() |
15 | self.object = object; |
16 | self.stateId = stateId; |
17 | assert(nearestBaleServerId ~= nil or self.stateId ~= BaleWrapper.CHANGE_GRAB_BALE); |
18 | self.nearestBaleServerId = nearestBaleServerId; |
19 | return self; |
20 | end; |
21 | |
22 | function BaleWrapperStateEvent:readStream(streamId, connection) |
23 | self.object = networkGetObject(streamReadInt32(streamId)); |
24 | |
25 | self.stateId = streamReadInt8(streamId); |
26 | if self.stateId == BaleWrapper.CHANGE_GRAB_BALE then |
27 | self.nearestBaleServerId = streamReadInt32(streamId); |
28 | end; |
29 | self:run(connection); |
30 | end; |
31 | |
32 | function BaleWrapperStateEvent:writeStream(streamId, connection) |
33 | streamWriteInt32(streamId, networkGetObjectId(self.object)); |
34 | streamWriteInt8(streamId, self.stateId); |
35 | if self.stateId == BaleWrapper.CHANGE_GRAB_BALE then |
36 | streamWriteInt32(streamId, self.nearestBaleServerId); |
37 | end; |
38 | end; |
39 | |
40 | function BaleWrapperStateEvent:run(connection) |
41 | self.object:doStateChange(self.stateId, self.nearestBaleServerId); |
42 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de