BLightFendt12130NEvent = {};
BLightFendt12130NEvent_mt = Class(BLightFendt12130NEvent, Event);

InitEventClass(BLightFendt12130NEvent, "BLightFendt12130NEvent");

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

function BLightFendt12130NEvent:new(vehicle, mode)
    local self = BLightFendt12130NEvent:emptyNew()
    self.vehicle = vehicle;
	self.mode = mode;
    return self;
end;

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

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

function BLightFendt12130NEvent:run(connection)
	self.vehicle:BLightFendt12130N(self.mode, true);
    if not connection:getIsServer() then
        g_server:broadcastEvent(BLightFendt12130NEvent:new(self.vehicle, self.mode), nil, connection, self.vehicle);
    end;
end;

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