public static DudExplosive Deserialize(Stream stream, DudExplosive instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num != 13)
         {
             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
         {
             instance.fuseTimeLeft = ProtocolParser.ReadSingle(stream);
         }
     }
     return(instance);
 }
        public static DudExplosive DeserializeLength(Stream stream, int length, DudExplosive 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 != 13)
                {
                    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
                {
                    instance.fuseTimeLeft = ProtocolParser.ReadSingle(stream);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
        public static DudExplosive DeserializeLength(Stream stream, int length)
        {
            DudExplosive dudExplosive = Pool.Get <DudExplosive>();

            DudExplosive.DeserializeLength(stream, length, dudExplosive, false);
            return(dudExplosive);
        }
        public static DudExplosive Deserialize(Stream stream)
        {
            DudExplosive dudExplosive = Pool.Get <DudExplosive>();

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

            this.CopyTo(dudExplosive);
            return(dudExplosive);
        }
 public static DudExplosive Deserialize(byte[] buffer, DudExplosive instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         DudExplosive.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
        public static void Serialize(Stream stream, DudExplosive instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(13);
            ProtocolParser.WriteSingle(stream, instance.fuseTimeLeft);
            Pool.FreeMemoryStream(ref memoryStream);
        }
 public virtual void WriteToStreamDelta(Stream stream, DudExplosive previous)
 {
     if (previous == null)
     {
         DudExplosive.Serialize(stream, this);
         return;
     }
     DudExplosive.SerializeDelta(stream, this, previous);
 }
 public static void ResetToPool(DudExplosive instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.fuseTimeLeft = 0f;
     Pool.Free <DudExplosive>(ref instance);
 }
Пример #10
0
        public static DudExplosive Deserialize(byte[] buffer)
        {
            DudExplosive dudExplosive = Pool.Get <DudExplosive>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                DudExplosive.Deserialize(memoryStream, dudExplosive, false);
            }
            return(dudExplosive);
        }
Пример #11
0
 public static byte[] SerializeToBytes(DudExplosive instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         DudExplosive.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
Пример #12
0
        public static void SerializeDelta(Stream stream, DudExplosive instance, DudExplosive previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.fuseTimeLeft != previous.fuseTimeLeft)
            {
                stream.WriteByte(13);
                ProtocolParser.WriteSingle(stream, instance.fuseTimeLeft);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
Пример #13
0
 public void ToProto(Stream stream)
 {
     DudExplosive.Serialize(stream, this);
 }
Пример #14
0
 public void CopyTo(DudExplosive instance)
 {
     instance.fuseTimeLeft = this.fuseTimeLeft;
 }
Пример #15
0
 public virtual void WriteToStream(Stream stream)
 {
     DudExplosive.Serialize(stream, this);
 }
Пример #16
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     DudExplosive.DeserializeLength(stream, size, this, isDelta);
 }
Пример #17
0
 public static void SerializeLengthDelimited(Stream stream, DudExplosive instance)
 {
     byte[] bytes = DudExplosive.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
Пример #18
0
 public void ResetToPool()
 {
     DudExplosive.ResetToPool(this);
 }
Пример #19
0
 public byte[] ToProtoBytes()
 {
     return(DudExplosive.SerializeToBytes(this));
 }
Пример #20
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     DudExplosive.Deserialize(stream, this, isDelta);
 }