Пример #1
0
        public HotAirBalloon Copy()
        {
            HotAirBalloon hotAirBalloon = Pool.Get <HotAirBalloon>();

            this.CopyTo(hotAirBalloon);
            return(hotAirBalloon);
        }
Пример #2
0
        public static HotAirBalloon DeserializeLengthDelimited(Stream stream)
        {
            HotAirBalloon hotAirBalloon = Pool.Get <HotAirBalloon>();

            HotAirBalloon.DeserializeLengthDelimited(stream, hotAirBalloon, false);
            return(hotAirBalloon);
        }
Пример #3
0
        public static HotAirBalloon DeserializeLength(Stream stream, int length, HotAirBalloon 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)
                {
                    instance.inflationAmount = ProtocolParser.ReadSingle(stream);
                }
                else if (num == 18)
                {
                    Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.velocity, isDelta);
                }
                else
                {
                    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);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
Пример #4
0
 public static HotAirBalloon Deserialize(byte[] buffer, HotAirBalloon instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         HotAirBalloon.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
Пример #5
0
 public virtual void WriteToStreamDelta(Stream stream, HotAirBalloon previous)
 {
     if (previous == null)
     {
         HotAirBalloon.Serialize(stream, this);
         return;
     }
     HotAirBalloon.SerializeDelta(stream, this, previous);
 }
Пример #6
0
        public static HotAirBalloon Deserialize(byte[] buffer)
        {
            HotAirBalloon hotAirBalloon = Pool.Get <HotAirBalloon>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                HotAirBalloon.Deserialize(memoryStream, hotAirBalloon, false);
            }
            return(hotAirBalloon);
        }
Пример #7
0
 public static byte[] SerializeToBytes(HotAirBalloon instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         HotAirBalloon.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
Пример #8
0
 public static void ResetToPool(HotAirBalloon instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.inflationAmount = 0f;
     instance.velocity        = new Vector3();
     Pool.Free <HotAirBalloon>(ref instance);
 }
Пример #9
0
        public static void Serialize(Stream stream, HotAirBalloon instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(13);
            ProtocolParser.WriteSingle(stream, instance.inflationAmount);
            stream.WriteByte(18);
            memoryStream.SetLength((long)0);
            Vector3Serialized.Serialize(memoryStream, instance.velocity);
            uint length = (uint)memoryStream.Length;

            ProtocolParser.WriteUInt32(stream, length);
            stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            Pool.FreeMemoryStream(ref memoryStream);
        }
Пример #10
0
 public static void SerializeLengthDelimited(Stream stream, HotAirBalloon instance)
 {
     byte[] bytes = HotAirBalloon.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
Пример #11
0
 public void CopyTo(HotAirBalloon instance)
 {
     instance.inflationAmount = this.inflationAmount;
     instance.velocity        = this.velocity;
 }
Пример #12
0
 public virtual void WriteToStream(Stream stream)
 {
     HotAirBalloon.Serialize(stream, this);
 }
Пример #13
0
 public byte[] ToProtoBytes()
 {
     return(HotAirBalloon.SerializeToBytes(this));
 }
Пример #14
0
 public void ToProto(Stream stream)
 {
     HotAirBalloon.Serialize(stream, this);
 }
Пример #15
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     HotAirBalloon.Deserialize(stream, this, isDelta);
 }
Пример #16
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     HotAirBalloon.DeserializeLength(stream, size, this, isDelta);
 }
Пример #17
0
 public void ResetToPool()
 {
     HotAirBalloon.ResetToPool(this);
 }