public static void SerializeDelta(Stream stream, LootableCorpse instance, LootableCorpse previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.privateData != null)
            {
                stream.WriteByte(10);
                memoryStream.SetLength((long)0);
                LootableCorpse.Private.SerializeDelta(memoryStream, instance.privateData, previous.privateData);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            if (instance.playerID != previous.playerID)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt64(stream, instance.playerID);
            }
            if (instance.playerName != null && instance.playerName != previous.playerName)
            {
                stream.WriteByte(26);
                ProtocolParser.WriteString(stream, instance.playerName);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
        public LootableCorpse Copy()
        {
            LootableCorpse lootableCorpse = Pool.Get <LootableCorpse>();

            this.CopyTo(lootableCorpse);
            return(lootableCorpse);
        }
        public static LootableCorpse Deserialize(Stream stream)
        {
            LootableCorpse lootableCorpse = Pool.Get <LootableCorpse>();

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

            LootableCorpse.DeserializeLength(stream, length, lootableCorpse, false);
            return(lootableCorpse);
        }
 public static LootableCorpse Deserialize(byte[] buffer, LootableCorpse instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         LootableCorpse.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
 public virtual void WriteToStreamDelta(Stream stream, LootableCorpse previous)
 {
     if (previous == null)
     {
         LootableCorpse.Serialize(stream, this);
         return;
     }
     LootableCorpse.SerializeDelta(stream, this, previous);
 }
 public static byte[] SerializeToBytes(LootableCorpse instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         LootableCorpse.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
        public static LootableCorpse Deserialize(byte[] buffer)
        {
            LootableCorpse lootableCorpse = Pool.Get <LootableCorpse>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                LootableCorpse.Deserialize(memoryStream, lootableCorpse, false);
            }
            return(lootableCorpse);
        }
 public static void ResetToPool(LootableCorpse instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     if (instance.privateData != null)
     {
         instance.privateData.ResetToPool();
         instance.privateData = null;
     }
     instance.playerID   = (ulong)0;
     instance.playerName = string.Empty;
     Pool.Free <LootableCorpse>(ref instance);
 }
        public static LootableCorpse DeserializeLengthDelimited(Stream stream, LootableCorpse instance, bool isDelta)
        {
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            while (stream.Position < position)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    throw new EndOfStreamException();
                }
                if (num == 10)
                {
                    if (instance.privateData != null)
                    {
                        LootableCorpse.Private.DeserializeLengthDelimited(stream, instance.privateData, isDelta);
                    }
                    else
                    {
                        instance.privateData = LootableCorpse.Private.DeserializeLengthDelimited(stream);
                    }
                }
                else if (num == 16)
                {
                    instance.playerID = ProtocolParser.ReadUInt64(stream);
                }
                else if (num == 26)
                {
                    instance.playerName = ProtocolParser.ReadString(stream);
                }
                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);
        }
 public void CopyTo(LootableCorpse instance)
 {
     if (this.privateData == null)
     {
         instance.privateData = null;
     }
     else if (instance.privateData != null)
     {
         this.privateData.CopyTo(instance.privateData);
     }
     else
     {
         instance.privateData = this.privateData.Copy();
     }
     instance.playerID   = this.playerID;
     instance.playerName = this.playerName;
 }
 public void FromProto(Stream stream, bool isDelta = false)
 {
     LootableCorpse.Deserialize(stream, this, isDelta);
 }
 public virtual void WriteToStream(Stream stream)
 {
     LootableCorpse.Serialize(stream, this);
 }
 public byte[] ToProtoBytes()
 {
     return(LootableCorpse.SerializeToBytes(this));
 }
 public void ToProto(Stream stream)
 {
     LootableCorpse.Serialize(stream, this);
 }
 public static void SerializeLengthDelimited(Stream stream, LootableCorpse instance)
 {
     byte[] bytes = LootableCorpse.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     LootableCorpse.DeserializeLength(stream, size, this, isDelta);
 }
 public void ResetToPool()
 {
     LootableCorpse.ResetToPool(this);
 }