コード例 #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);
 }