Sprache Deutsch Language English

Script Dokumentation LS 2015 - HPWPlaceableStateEvent (Patch 1.3)

Script Dokumentation Übersicht

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