Example #1
0
        public override bool Equals(object obj)
        {
            PlayerVariables playerVariable = obj as PlayerVariables;

            if (playerVariable == null)
            {
                return(false);
            }
            if (!this.Identity.Equals(playerVariable.Identity))
            {
                return(false);
            }
            if (this.HasRating != playerVariable.HasRating || this.HasRating && !this.Rating.Equals(playerVariable.Rating))
            {
                return(false);
            }
            if (this.Attribute.Count != playerVariable.Attribute.Count)
            {
                return(false);
            }
            for (int i = 0; i < this.Attribute.Count; i++)
            {
                if (!this.Attribute[i].Equals(playerVariable.Attribute[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
        public static void Serialize(Stream stream, PlayerVariables instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.Identity == null)
            {
                throw new ArgumentNullException("Identity", "Required by proto specification.");
            }
            stream.WriteByte(10);
            ProtocolParser.WriteUInt32(stream, instance.Identity.GetSerializedSize());
            bnet.protocol.Identity.Serialize(stream, instance.Identity);
            if (instance.HasRating)
            {
                stream.WriteByte(17);
                binaryWriter.Write(instance.Rating);
            }
            if (instance.Attribute.Count > 0)
            {
                foreach (bnet.protocol.attribute.Attribute attribute in instance.Attribute)
                {
                    stream.WriteByte(26);
                    ProtocolParser.WriteUInt32(stream, attribute.GetSerializedSize());
                    bnet.protocol.attribute.Attribute.Serialize(stream, attribute);
                }
            }
        }
Example #3
0
        public static PlayerVariables DeserializeLengthDelimited(Stream stream)
        {
            PlayerVariables playerVariable = new PlayerVariables();

            PlayerVariables.DeserializeLengthDelimited(stream, playerVariable);
            return(playerVariable);
        }
Example #4
0
        public static PlayerVariables DeserializeLengthDelimited(Stream stream, PlayerVariables instance)
        {
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            return(PlayerVariables.Deserialize(stream, instance, position));
        }
        public uint GetSerializedSize()
        {
            uint num = 0u;

            if (this.PlayerVariables.get_Count() > 0)
            {
                using (List <PlayerVariables> .Enumerator enumerator = this.PlayerVariables.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        PlayerVariables current = enumerator.get_Current();
                        num += 1u;
                        uint serializedSize = current.GetSerializedSize();
                        num += serializedSize + ProtocolParser.SizeOfUInt32(serializedSize);
                    }
                }
            }
            if (this.HasHost)
            {
                num += 1u;
                uint serializedSize2 = this.Host.GetSerializedSize();
                num += serializedSize2 + ProtocolParser.SizeOfUInt32(serializedSize2);
            }
            return(num);
        }
        public static PlayerVariables DeserializeLengthDelimited(Stream stream, PlayerVariables instance)
        {
            long num = (long)((ulong)ProtocolParser.ReadUInt32(stream));

            num += stream.get_Position();
            return(PlayerVariables.Deserialize(stream, instance, num));
        }
        public override bool Equals(object obj)
        {
            PlayerVariables playerVariables = obj as PlayerVariables;

            if (playerVariables == null)
            {
                return(false);
            }
            if (!this.Identity.Equals(playerVariables.Identity))
            {
                return(false);
            }
            if (this.HasRating != playerVariables.HasRating || (this.HasRating && !this.Rating.Equals(playerVariables.Rating)))
            {
                return(false);
            }
            if (this.Attribute.get_Count() != playerVariables.Attribute.get_Count())
            {
                return(false);
            }
            for (int i = 0; i < this.Attribute.get_Count(); i++)
            {
                if (!this.Attribute.get_Item(i).Equals(playerVariables.Attribute.get_Item(i)))
                {
                    return(false);
                }
            }
            return(true);
        }
        public static void Serialize(Stream stream, PlayerVariables instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.Identity == null)
            {
                throw new ArgumentNullException("Identity", "Required by proto specification.");
            }
            stream.WriteByte(10);
            ProtocolParser.WriteUInt32(stream, instance.Identity.GetSerializedSize());
            Identity.Serialize(stream, instance.Identity);
            if (instance.HasRating)
            {
                stream.WriteByte(17);
                binaryWriter.Write(instance.Rating);
            }
            if (instance.Attribute.get_Count() > 0)
            {
                using (List <Attribute> .Enumerator enumerator = instance.Attribute.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Attribute current = enumerator.get_Current();
                        stream.WriteByte(26);
                        ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                        bnet.protocol.attribute.Attribute.Serialize(stream, current);
                    }
                }
            }
        }
Example #9
0
        public static PlayerVariables Deserialize(Stream stream, PlayerVariables instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            if (instance.Attribute == null)
            {
                instance.Attribute = new List <bnet.protocol.attribute.Attribute>();
            }
            while (limit < 0L || stream.Position < limit)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    if (limit >= 0L)
                    {
                        throw new EndOfStreamException();
                    }
                    return(instance);
                }
                else if (num != 10)
                {
                    if (num != 17)
                    {
                        if (num != 26)
                        {
                            Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                            uint field = key.Field;
                            if (field == 0u)
                            {
                                throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                            }
                            ProtocolParser.SkipKey(stream, key);
                        }
                        else
                        {
                            instance.Attribute.Add(bnet.protocol.attribute.Attribute.DeserializeLengthDelimited(stream));
                        }
                    }
                    else
                    {
                        instance.Rating = binaryReader.ReadDouble();
                    }
                }
                else if (instance.Identity == null)
                {
                    instance.Identity = Identity.DeserializeLengthDelimited(stream);
                }
                else
                {
                    Identity.DeserializeLengthDelimited(stream, instance.Identity);
                }
            }
            if (stream.Position == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
Example #10
0
        public override int GetHashCode()
        {
            int num = base.GetType().GetHashCode();

            using (List <PlayerVariables> .Enumerator enumerator = this.PlayerVariables.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    PlayerVariables current = enumerator.get_Current();
                    num ^= current.GetHashCode();
                }
            }
            return(num);
        }
Example #11
0
 public static void Serialize(Stream stream, GetPlayerVariablesResponse instance)
 {
     if (instance.PlayerVariables.get_Count() > 0)
     {
         using (List <PlayerVariables> .Enumerator enumerator = instance.PlayerVariables.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 PlayerVariables current = enumerator.get_Current();
                 stream.WriteByte(10);
                 ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                 bnet.protocol.game_utilities.PlayerVariables.Serialize(stream, current);
             }
         }
     }
 }
Example #12
0
 public void AddPlayerVariables(PlayerVariables val)
 {
     this._PlayerVariables.Add(val);
 }
Example #13
0
 public static PlayerVariables Deserialize(Stream stream, PlayerVariables instance)
 {
     return(PlayerVariables.Deserialize(stream, instance, (long)-1));
 }
Example #14
0
 public void Deserialize(Stream stream)
 {
     PlayerVariables.Deserialize(stream, this);
 }