kolarzedoweAttachEvent = {};
kolarzedoweAttachEvent_mt = Class(kolarzedoweAttachEvent, Event);

InitEventClass(kolarzedoweAttachEvent, "kolarzedoweAttachEvent");

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

function kolarzedoweAttachEvent:new(vehicle, attacherVehicle)
    local self = kolarzedoweAttachEvent:emptyNew()
    self.vehicle = vehicle;
	self.attacherVehicle = attacherVehicle;
    return self;
end;

function kolarzedoweAttachEvent:readStream(streamId, connection)
    local id = streamReadInt32(streamId);
	local attacherId = streamReadInt32(streamId);
	self.attacherVehicle = networkGetObject(attacherId);
    self.vehicle = networkGetObject(id);
    self:run(connection);
end;

function kolarzedoweAttachEvent:writeStream(streamId, connection)
    streamWriteInt32(streamId, networkGetObjectId(self.vehicle));
	streamWriteInt32(streamId, networkGetObjectId(self.attacherVehicle));
end;

function kolarzedoweAttachEvent:run(connection)
	self.vehicle:assembleeWheels(self.attacherVehicle, true);
    if not connection:getIsServer() then
        g_server:broadcastEvent(kolarzedoweAttachEvent:new(self.vehicle, self.attacherVehicle), nil, connection, self.object);
    end;
end;


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