-- Name: BSU_clearAreaEvent
-- Author: Chissel

BSU_clearAreaEvent = {}

local BSU_clearAreaEvent_mt = Class(BSU_clearAreaEvent, Event)
InitEventClass(BSU_clearAreaEvent, "BSU_clearAreaEvent")

function BSU_clearAreaEvent.emptyNew()
	local self = Event.new(BSU_clearAreaEvent_mt)

	return self
end

function BSU_clearAreaEvent.new(bunkerSilo)
	local self = BSU_clearAreaEvent.emptyNew()
	self.bunkerSilo = bunkerSilo

	return self
end

function BSU_clearAreaEvent:readStream(streamId, connection)
    self.bunkerSilo = NetworkUtil.readNodeObject(streamId)

	self:run(connection)
end

function BSU_clearAreaEvent:writeStream(streamId, connection)
    NetworkUtil.writeNodeObject(streamId, self.bunkerSilo)
end

function BSU_clearAreaEvent:run(connection)
	if not connection:getIsServer() then
		self.bunkerSilo:clearArea()
	end
end