Пример #1
0
 public virtual void WriteToStreamDelta(Stream stream, Attack previous)
 {
     if (previous == null)
     {
         Attack.Serialize(stream, this);
         return;
     }
     Attack.SerializeDelta(stream, this, previous);
 }
        public static void SerializeDelta(Stream stream, PlayerAttack instance, PlayerAttack previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.attack == null)
            {
                throw new ArgumentNullException("attack", "Required by proto specification.");
            }
            stream.WriteByte(10);
            memoryStream.SetLength((long)0);
            Attack.SerializeDelta(memoryStream, instance.attack, previous.attack);
            uint length = (uint)memoryStream.Length;

            ProtocolParser.WriteUInt32(stream, length);
            stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            if (instance.projectileID != previous.projectileID)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt64(stream, (ulong)instance.projectileID);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }