forked from loki79uk/FS22_LumberJack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeleteShapeEvent.lua
52 lines (45 loc) · 1.48 KB
/
DeleteShapeEvent.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
41
42
43
44
45
46
47
48
49
50
51
52
-- ============================================================= --
-- DELETE SHAPE EVENT
-- ============================================================= --
DeleteShapeEvent = {}
DeleteShapeEvent_mt = Class(DeleteShapeEvent, Event)
InitEventClass(DeleteShapeEvent, "DeleteShapeEvent")
function DeleteShapeEvent.emptyNew()
--print("DeleteShape - EMPTY NEW")
local self = Event.new(DeleteShapeEvent_mt)
return self
end
function DeleteShapeEvent.new(splitShapeId)
--print("DeleteShape - NEW")
local self = DeleteShapeEvent.emptyNew()
self.splitShapeId = splitShapeId
return self
end
function DeleteShapeEvent:readStream(streamId, connection)
--print("DeleteShape - READ STREAM")
if not connection:getIsServer() then
local splitShapeId = readSplitShapeIdFromStream(streamId)
if splitShapeId ~= 0 then
--print("DeleteShape CLIENT")
delete(splitShapeId)
end
end
end
function DeleteShapeEvent:writeStream(streamId, connection)
--print("DeleteShape - WRITE STREAM");
if connection:getIsServer() then
writeSplitShapeIdToStream(streamId, self.splitShapeId)
end
end
function DeleteShapeEvent:run(connection)
--print("Error: DeleteShapeEvent is not allowed to be executed on a local client")
end
function DeleteShapeEvent.sendEvent(splitShapeId)
--print("DeleteShape - RUN")
if g_server ~= nil then
--print("DeleteShape SERVER")
delete(splitShapeId)
else
g_client:getServerConnection():sendEvent(DeleteShapeEvent.new(splitShapeId))
end
end