kolarzedoweDetachEvent = {};
kolarzedoweDetachEvent_mt = Class(kolarzedoweDetachEvent, Event);

InitEventClass(kolarzedoweDetachEvent, "kolarzedoweDetachEvent");

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

function kolarzedoweDetachEvent:new(vehicle)
    local self = kolarzedoweDetachEvent:emptyNew()
    self.vehicle = vehicle;
    return self;
end;

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

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

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


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