-- author: rafftnix
-- date: 16.12.2012


StopMotorSawEvent = {};
StopMotorSawEvent_mt = Class(StopMotorSawEvent, Event);
InitEventClass(StopMotorSawEvent, "StopMotorSawEvent");
function StopMotorSawEvent:emptyNew()
    local self = Event:new(StopMotorSawEvent_mt);
    self.className="StopMotorSawEvent";
    return self;
end;

function StopMotorSawEvent:new(object)
    local self = StopMotorSawEvent:emptyNew(); 
    self.object = object; 
    return self;
end;

function StopMotorSawEvent:writeStream(streamId, connection)
    streamWriteInt32(streamId, networkGetObjectId(self.object));
end;

function StopMotorSawEvent:readStream(streamId, connection)
    self.object = networkGetObject(streamReadInt32(streamId));
    self:run(connection);
end;

function StopMotorSawEvent:run(connection)
	self.object:stopMotorSaw(true);
	if not connection:getIsServer() then
		g_server:broadcastEvent(StopMotorSawEvent:new(self.object), nil, connection, self.object);
	end; 
end;

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