public static void Serialize(Stream stream, ArcadeMachine instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.scores != null)
            {
                for (int i = 0; i < instance.scores.Count; i++)
                {
                    ArcadeMachine.ScoreEntry item = instance.scores[i];
                    stream.WriteByte(10);
                    memoryStream.SetLength((long)0);
                    ArcadeMachine.ScoreEntry.Serialize(memoryStream, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            stream.WriteByte(16);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.genericInt1);
            stream.WriteByte(24);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.genericInt2);
            stream.WriteByte(32);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.genericInt3);
            stream.WriteByte(40);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.genericInt4);
            stream.WriteByte(53);
            ProtocolParser.WriteSingle(stream, instance.genericFloat1);
            stream.WriteByte(61);
            ProtocolParser.WriteSingle(stream, instance.genericFloat2);
            stream.WriteByte(69);
            ProtocolParser.WriteSingle(stream, instance.genericFloat3);
            stream.WriteByte(77);
            ProtocolParser.WriteSingle(stream, instance.genericFloat4);
            Pool.FreeMemoryStream(ref memoryStream);
        }
        public static ArcadeMachine Deserialize(Stream stream)
        {
            ArcadeMachine arcadeMachine = Pool.Get <ArcadeMachine>();

            ArcadeMachine.Deserialize(stream, arcadeMachine, false);
            return(arcadeMachine);
        }
        public ArcadeMachine Copy()
        {
            ArcadeMachine arcadeMachine = Pool.Get <ArcadeMachine>();

            this.CopyTo(arcadeMachine);
            return(arcadeMachine);
        }
 public static void ResetToPool(ArcadeMachine instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     if (instance.scores != null)
     {
         for (int i = 0; i < instance.scores.Count; i++)
         {
             if (instance.scores[i] != null)
             {
                 instance.scores[i].ResetToPool();
                 instance.scores[i] = null;
             }
         }
         List <ArcadeMachine.ScoreEntry> scoreEntries = instance.scores;
         Pool.FreeList <ArcadeMachine.ScoreEntry>(ref scoreEntries);
         instance.scores = scoreEntries;
     }
     instance.genericInt1   = 0;
     instance.genericInt2   = 0;
     instance.genericInt3   = 0;
     instance.genericInt4   = 0;
     instance.genericFloat1 = 0f;
     instance.genericFloat2 = 0f;
     instance.genericFloat3 = 0f;
     instance.genericFloat4 = 0f;
     Pool.Free <ArcadeMachine>(ref instance);
 }
        public static ArcadeMachine DeserializeLength(Stream stream, int length)
        {
            ArcadeMachine arcadeMachine = Pool.Get <ArcadeMachine>();

            ArcadeMachine.DeserializeLength(stream, length, arcadeMachine, false);
            return(arcadeMachine);
        }
 public static ArcadeMachine Deserialize(byte[] buffer, ArcadeMachine instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         ArcadeMachine.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
 public virtual void WriteToStreamDelta(Stream stream, ArcadeMachine previous)
 {
     if (previous == null)
     {
         ArcadeMachine.Serialize(stream, this);
         return;
     }
     ArcadeMachine.SerializeDelta(stream, this, previous);
 }
        public static ArcadeMachine Deserialize(byte[] buffer)
        {
            ArcadeMachine arcadeMachine = Pool.Get <ArcadeMachine>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                ArcadeMachine.Deserialize(memoryStream, arcadeMachine, false);
            }
            return(arcadeMachine);
        }
 public static byte[] SerializeToBytes(ArcadeMachine instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         ArcadeMachine.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
 public virtual void WriteToStream(Stream stream)
 {
     ArcadeMachine.Serialize(stream, this);
 }
 public byte[] ToProtoBytes()
 {
     return(ArcadeMachine.SerializeToBytes(this));
 }
 public void CopyTo(ArcadeMachine instance)
 {
     throw new NotImplementedException();
 }
 public void FromProto(Stream stream, bool isDelta = false)
 {
     ArcadeMachine.Deserialize(stream, this, isDelta);
 }
 public static void SerializeLengthDelimited(Stream stream, ArcadeMachine instance)
 {
     byte[] bytes = ArcadeMachine.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
 public void ResetToPool()
 {
     ArcadeMachine.ResetToPool(this);
 }
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     ArcadeMachine.DeserializeLength(stream, size, this, isDelta);
 }
 public static ArcadeMachine Deserialize(Stream stream, ArcadeMachine instance, bool isDelta)
 {
     if (!isDelta && instance.scores == null)
     {
         instance.scores = Pool.Get <List <ArcadeMachine.ScoreEntry> >();
     }
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num <= 32)
         {
             if (num <= 16)
             {
                 if (num == 10)
                 {
                     instance.scores.Add(ArcadeMachine.ScoreEntry.DeserializeLengthDelimited(stream));
                     continue;
                 }
                 else if (num == 16)
                 {
                     instance.genericInt1 = (int)ProtocolParser.ReadUInt64(stream);
                     continue;
                 }
             }
             else if (num == 24)
             {
                 instance.genericInt2 = (int)ProtocolParser.ReadUInt64(stream);
                 continue;
             }
             else if (num == 32)
             {
                 instance.genericInt3 = (int)ProtocolParser.ReadUInt64(stream);
                 continue;
             }
         }
         else if (num <= 53)
         {
             if (num == 40)
             {
                 instance.genericInt4 = (int)ProtocolParser.ReadUInt64(stream);
                 continue;
             }
             else if (num == 53)
             {
                 instance.genericFloat1 = ProtocolParser.ReadSingle(stream);
                 continue;
             }
         }
         else if (num == 61)
         {
             instance.genericFloat2 = ProtocolParser.ReadSingle(stream);
             continue;
         }
         else if (num == 69)
         {
             instance.genericFloat3 = ProtocolParser.ReadSingle(stream);
             continue;
         }
         else if (num == 77)
         {
             instance.genericFloat4 = ProtocolParser.ReadSingle(stream);
             continue;
         }
         Key key = ProtocolParser.ReadKey((byte)num, stream);
         if (key.Field == 0)
         {
             throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
         }
         ProtocolParser.SkipKey(stream, key);
     }
     return(instance);
 }
 public void ToProto(Stream stream)
 {
     ArcadeMachine.Serialize(stream, this);
 }