-
Notifications
You must be signed in to change notification settings - Fork 1
/
OpenCoverEvent.lua
40 lines (35 loc) · 1.01 KB
/
OpenCoverEvent.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
OpenCoverEvent = {}
OpenCoverEvent_mt = Class(OpenCoverEvent, Event)
InitEventClass(OpenCoverEvent, "OpenCoverEvent")
function OpenCoverEvent.emptyNew()
local self = Event.new(OpenCoverEvent_mt)
return self
end
function OpenCoverEvent.new(myObject, myState)
local self = OpenCoverEvent.emptyNew()
self.object = myObject
self.state = myState
return self
end
function OpenCoverEvent:readStream(streamId, connection)
if not connection:getIsServer() then
self.object = NetworkUtil.readNodeObject(streamId)
self.state = streamReadInt32(streamId)
end
self:run(connection)
end
function OpenCoverEvent:writeStream(streamId, connection)
if connection:getIsServer() then
NetworkUtil.writeNodeObject(streamId, self.object)
streamWriteInt32(streamId, self.state)
end
end
function OpenCoverEvent:run(connection)
if not connection:getIsServer() then
--print("OpenCoverEvent: server")
self.object:openCover(self.state, true)
else
--print("OpenCoverEvent: client")
--self.object:openCover(self.state, true)
end
end