SetAugmenterVitesseTapisEvent = {};
SetAugmenterVitesseTapisEvent_mt = Class(SetAugmenterVitesseTapisEvent, Event);

InitEventClass(SetAugmenterVitesseTapisEvent, "SetAugmenterVitesseTapisEvent");

function SetAugmenterVitesseTapisEvent:emptyNew()
    local self = Event:new(SetAugmenterVitesseTapisEvent_mt);
    self.className="SetAugmenterVitesseTapisEvent";
    return self;
end;

function SetAugmenterVitesseTapisEvent:new(vehicle, augmenterVitesseTapis)
    local self = SetAugmenterVitesseTapisEvent:emptyNew()
    self.vehicle = vehicle;
	self.augmenterVitesseTapis = augmenterVitesseTapis;
    return self;
end;

function SetAugmenterVitesseTapisEvent:readStream(streamId, connection)
    local id = streamReadInt32(streamId);
	self.augmenterVitesseTapis = streamReadBool(streamId);
    self.vehicle = networkGetObject(id);
    self:run(connection);
end;

function SetAugmenterVitesseTapisEvent:writeStream(streamId, connection)
    streamWriteInt32(streamId, networkGetObjectId(self.vehicle));
	streamWriteBool(streamId, self.augmenterVitesseTapis);
end;

function SetAugmenterVitesseTapisEvent:run(connection)
	self.vehicle:setAugmenterVitesseTapis(self.augmenterVitesseTapis, true);
    if not connection:getIsServer() then
        g_server:broadcastEvent(SetAugmenterVitesseTapisEvent:new(self.vehicle, self.augmenterVitesseTapis), nil, connection, self.vehicle);
    end;
end;

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