SetAgriSaatEvent = {};
SetAgriSaatEvent_mt = Class(SetAgriSaatEvent, Event);

InitEventClass(SetAgriSaatEvent, "SetAgriSaatEvent");

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

function SetAgriSaatEvent:new(vehicle, allumer)
    local self = SetAgriSaatEvent:emptyNew()
    self.vehicle = vehicle;
	self.allumer = allumer;
    return self;
end;

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

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

function SetAgriSaatEvent:run(connection)   
	self.vehicle:setAllumer(self.allumer, true);
    if not connection:getIsServer() then
        g_server:broadcastEvent(SetAgriSaatEvent:new(vehicle, self.allumer), nil, connection, self.vehicle);
    end;
end;

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