TrimmerEvent = {};
TrimmerEvent_mt = Class(TrimmerEvent, Event);
InitEventClass(TrimmerEvent, "TrimmerEvent");

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

function TrimmerEvent:new(object, numDiscs)
    local self = TrimmerEvent:emptyNew(); 
    self.object = object; 
    self.numDiscs = numDiscs;
    return self;
end;

function TrimmerEvent:writeStream(streamId, connection)
    local id = networkGetObjectId(self.object);
    streamWriteInt32(streamId, id);
    streamWriteInt8(streamId, self.numDiscs);
end;

function TrimmerEvent:readStream(streamId, connection)
    self.object = networkGetObject(streamReadInt32(streamId));
    self.numDiscs = streamReadInt8(streamId);
    self:run(connection);
end;

function TrimmerEvent:run(connection)
    self.object:setActiveDisks(self.numDiscs, true); 
    if not connection:getIsServer() then
        g_server:broadcastEvent(TrimmerEvent:new(self.object, self.numDiscs), nil, connection, self.object);
    end; 
end;

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