Ejemplo n.º 1
0
 public static SAMSite Deserialize(Stream stream, SAMSite instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num != 10)
         {
             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);
         }
         else
         {
             Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.aimDir, isDelta);
         }
     }
     return(instance);
 }
Ejemplo n.º 2
0
        public static SAMSite DeserializeLength(Stream stream, int length, SAMSite instance, bool isDelta)
        {
            long position = stream.Position + (long)length;

            while (stream.Position < position)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    throw new EndOfStreamException();
                }
                if (num != 10)
                {
                    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);
                }
                else
                {
                    Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.aimDir, isDelta);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
Ejemplo n.º 3
0
        public static SAMSite Deserialize(Stream stream)
        {
            SAMSite sAMSite = Pool.Get <SAMSite>();

            SAMSite.Deserialize(stream, sAMSite, false);
            return(sAMSite);
        }
Ejemplo n.º 4
0
        public SAMSite Copy()
        {
            SAMSite sAMSite = Pool.Get <SAMSite>();

            this.CopyTo(sAMSite);
            return(sAMSite);
        }
Ejemplo n.º 5
0
        public static SAMSite DeserializeLength(Stream stream, int length)
        {
            SAMSite sAMSite = Pool.Get <SAMSite>();

            SAMSite.DeserializeLength(stream, length, sAMSite, false);
            return(sAMSite);
        }
Ejemplo n.º 6
0
 public static SAMSite Deserialize(byte[] buffer, SAMSite instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         SAMSite.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
Ejemplo n.º 7
0
 public virtual void WriteToStreamDelta(Stream stream, SAMSite previous)
 {
     if (previous == null)
     {
         SAMSite.Serialize(stream, this);
         return;
     }
     SAMSite.SerializeDelta(stream, this, previous);
 }
Ejemplo n.º 8
0
 public static void ResetToPool(SAMSite instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.aimDir = new Vector3();
     Pool.Free <SAMSite>(ref instance);
 }
Ejemplo n.º 9
0
        public static SAMSite Deserialize(byte[] buffer)
        {
            SAMSite sAMSite = Pool.Get <SAMSite>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                SAMSite.Deserialize(memoryStream, sAMSite, false);
            }
            return(sAMSite);
        }
Ejemplo n.º 10
0
 public static byte[] SerializeToBytes(SAMSite instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         SAMSite.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
Ejemplo n.º 11
0
        public static void Serialize(Stream stream, SAMSite instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(10);
            memoryStream.SetLength((long)0);
            Vector3Serialized.Serialize(memoryStream, instance.aimDir);
            uint length = (uint)memoryStream.Length;

            ProtocolParser.WriteUInt32(stream, length);
            stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            Pool.FreeMemoryStream(ref memoryStream);
        }
Ejemplo n.º 12
0
 public void ToProto(Stream stream)
 {
     SAMSite.Serialize(stream, this);
 }
Ejemplo n.º 13
0
 public void CopyTo(SAMSite instance)
 {
     instance.aimDir = this.aimDir;
 }
Ejemplo n.º 14
0
 public virtual void WriteToStream(Stream stream)
 {
     SAMSite.Serialize(stream, this);
 }
Ejemplo n.º 15
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     SAMSite.DeserializeLength(stream, size, this, isDelta);
 }
Ejemplo n.º 16
0
 public static void SerializeLengthDelimited(Stream stream, SAMSite instance)
 {
     byte[] bytes = SAMSite.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
Ejemplo n.º 17
0
 public void ResetToPool()
 {
     SAMSite.ResetToPool(this);
 }
Ejemplo n.º 18
0
 public byte[] ToProtoBytes()
 {
     return(SAMSite.SerializeToBytes(this));
 }
Ejemplo n.º 19
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     SAMSite.Deserialize(stream, this, isDelta);
 }