DeliveryAnimalsEvent = {};
DeliveryAnimalsEvent_mt = Class(DeliveryAnimalsEvent, Event);
InitEventClass(DeliveryAnimalsEvent, "DeliveryAnimalsEvent");

DeliveryAnimalsEvent.NUM_BITS_ID = 1;

function DeliveryAnimalsEvent.emptyNew()
    local self = Event.new(DeliveryAnimalsEvent_mt);
    return self;
end;

function DeliveryAnimalsEvent.new(mission, deliveryAnimals)
    local self = DeliveryAnimalsEvent.emptyNew();
    self.mission = mission;	
	self.deliveryAnimals = deliveryAnimals;    
    return self;
end;

function DeliveryAnimalsEvent:writeStream(streamId, connection)
    NetworkUtil.writeNodeObject(streamId, self.mission);
	streamWriteUInt8(streamId, self.deliveryAnimals, DeliveryAnimalsEvent.NUM_BITS_ID);	
end;

function DeliveryAnimalsEvent:readStream(streamId, connection)
    self.mission = NetworkUtil.readNodeObject(streamId)
	self.deliveryAnimals = streamReadUInt8(streamId, DeliveryAnimalsEvent.NUM_BITS_ID);	
	local numAnimals = math.clamp(self.deliveryAnimals, 0, self.mission.numObjects - self.mission.numDeliveryAnimals);
	self.mission.numDeliveryAnimals = self.mission.numDeliveryAnimals + numAnimals;
end;
