SetTipSideEvent = {};
SetTipSideEvent_mt = Class(SetTipSideEvent, Event);

InitEventClass(SetTipSideEvent, "SetTipSideEvent");

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

function SetTipSideEvent:new(vehicle, state)
    local self = SetTipSideEvent:emptyNew()
    self.object = object;
	self.state = state;
	return self;
end;

function SetTipSideEvent:readStream(streamId, connection)
    local id = streamReadInt32(streamId);
	self.state = streamReadInt32(streamId);
    self.object = networkGetObject(id);
    self:run(connection);
end;

function SetTipSideEvent:writeStream(streamId, connection)
    streamWriteInt32(streamId, networkGetObjectId(self.object));	
	streamWriteInt32(streamId, self.state);
end;

function SetTipSideEvent:run(connection)
	self.object:setTipSide(self.state, true);
	if not connection:getIsServer() then
		g_server:broadcastEvent(SetTipSideEvent:new(self.object, self.state), nil, connection, self.object);
	end;
end;

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