WorkFendt12130NEvent = {};
WorkFendt12130NEvent_mt = Class(WorkFendt12130NEvent, Event);

InitEventClass(WorkFendt12130NEvent, "WorkFendt12130NEvent");

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

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

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

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

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

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