示例#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);
 }