TopSawCutTreeEvent = {}
local TopSawCutTreeEvent_mt = Class(TopSawCutTreeEvent, Event)

InitEventClass(TopSawCutTreeEvent, "TopSawCutTreeEvent")

function TopSawCutTreeEvent.emptyNew()
	local self = Event.new(TopSawCutTreeEvent_mt)

	return self
end

function TopSawCutTreeEvent.new(object)
	local self = TopSawCutTreeEvent.emptyNew()
	self.object = object

	return self
end

function TopSawCutTreeEvent:readStream(streamId, connection)
	self.object = NetworkUtil.readNodeObject(streamId)

	self:run(connection)
end

function TopSawCutTreeEvent:writeStream(streamId, connection)
	NetworkUtil.writeNodeObject(streamId, self.object)
end

function TopSawCutTreeEvent:run(connection)
	if not connection:getIsServer() then
		g_server:broadcastEvent(TopSawCutTreeEvent.new(self.object), nil, connection, self.object)
	end

	if self.object ~= nil and self.object:getIsSynchronized() then
		self.object:cutTop(true)
	end
end

function TopSawCutTreeEvent.sendEvent(object, noEventSend)
	if noEventSend == nil or noEventSend == false then
		if g_server ~= nil then
			g_server:broadcastEvent(TopSawCutTreeEvent.new(object), nil, false, object)
		else
			g_client:getServerConnection():sendEvent(TopSawCutTreeEvent.new(object))
		end
	end
end
