예제 #1
0
        /// <summary>
        /// Appends a message to a <see cref="BitStream"/> for synchronizing all of the client's quest information.
        /// The message is then read and handled by the receiver using <see cref="UserQuestInformation.Read"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to append the message to.</param>
        /// <param name="completedQuests">All of the completed quests.</param>
        /// <param name="activeQuests">All of the active quests.</param>
        public static void WriteQuestInfo(BitStream bs, IEnumerable<QuestID> completedQuests, IEnumerable<QuestID> activeQuests)
        {
            completedQuests = completedQuests.ToImmutable();
            activeQuests = activeQuests.ToImmutable();

            bs.WriteEnum(QuestInfoMessages.RemoveActiveQuest);

            // Write the completed quests
            bs.Write((ushort)completedQuests.Count());
            foreach (var q in completedQuests)
            {
                bs.Write(q);
            }

            // Write the active quests
            bs.Write((byte)activeQuests.Count());
            foreach (var q in activeQuests)
            {
                bs.Write(q);
            }
        }
예제 #2
0
 /// <summary>
 /// Appends a message to a <see cref="BitStream"/> for synchronizing the client's quest information for when
 /// a quest is removed from the active quests.
 /// The message is then read and handled by the receiver using <see cref="UserQuestInformation.Read"/>.
 /// </summary>
 /// <param name="bs">The <see cref="BitStream"/> to append the message to.</param>
 /// <param name="questID">The ID of the removed active quest.</param>
 public static void WriteRemoveActiveQuest(BitStream bs, QuestID questID)
 {
     bs.WriteEnum(QuestInfoMessages.RemoveActiveQuest);
     bs.Write(questID);
 }
예제 #3
0
        /// <summary>
        /// Appends a message to a <see cref="BitStream"/> for synchronizing all of the client's quest information.
        /// The message is then read and handled by the receiver using <see cref="UserQuestInformation.Read"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to append the message to.</param>
        /// <param name="completedQuests">All of the completed quests.</param>
        /// <param name="activeQuests">All of the active quests.</param>
        /// <param name="repeatableQuests">All of the repeatable quests.</param>
        public static void WriteQuestInfo(BitStream bs, IEnumerable<QuestID> completedQuests, IEnumerable<QuestID> activeQuests, IEnumerable<QuestID> repeatableQuests)
        {
            completedQuests = completedQuests.ToImmutable();
            activeQuests = activeQuests.ToImmutable();
            repeatableQuests = repeatableQuests.ToImmutable();

            bs.WriteEnum(QuestInfoMessages.LoadInitialValues);

            // Write the completed quests
            bs.Write((ushort)completedQuests.Count());
            foreach (var q in completedQuests)
            {
                bs.Write(q);
            }

            // Write the active quests
            bs.Write((byte)activeQuests.Count());
            foreach (var q in activeQuests)
            {
                bs.Write(q);
            }

            // Write the repeatable quests
            bs.Write((byte)repeatableQuests.Count());
            foreach (var q in repeatableQuests)
            {
                bs.Write(q);
            }
        }
예제 #4
0
 /// <summary>
 /// Appends a message to a <see cref="BitStream"/> for synchronizing the client's quest information for when
 /// a quest is completed.
 /// The message is then read and handled by the receiver using <see cref="UserQuestInformation.Read"/>.
 /// </summary>
 /// <param name="bs">The <see cref="BitStream"/> to append the message to.</param>
 /// <param name="questID">The ID of the completed quest.</param>
 public static void WriteAddCompletedQuest(BitStream bs, QuestID questID)
 {
     bs.WriteEnum(QuestInfoMessages.AddCompletedQuest);
     bs.Write(questID);
 }
예제 #5
0
 /// <summary>
 /// Appends a message to a <see cref="BitStream"/> for synchronizing the client's guild information for when
 /// a the guild's name or tag changes and needs to be updated.
 /// The message is then read and handled by the receiver using <see cref="UserGuildInformation.Read"/>.
 /// </summary>
 /// <param name="pw">The <see cref="BitStream"/> to append the message to.</param>
 /// <param name="name">The new guild name.</param>
 /// <param name="tag">The new guild tag.</param>
 public static void WriteUpdateNameTag(BitStream pw, string name, string tag)
 {
     pw.WriteEnum(GuildInfoMessages.UpdateNameTag);
     pw.Write(name);
     pw.Write(tag);
 }
예제 #6
0
 /// <summary>
 /// Appends a message to a <see cref="BitStream"/> for synchronizing the client's quest information for when
 /// a quest is repeatable.
 /// The message is then read and handled by the receiver using <see cref="UserQuestInformation.Read"/>.
 /// </summary>
 /// <param name="bs">The <see cref="BitStream"/> to append the message to.</param>
 /// <param name="questID">The ID of the repeatable quest.</param>
 public static void WriteAddRepeatableQuest(BitStream bs, QuestID questID)
 {
     bs.WriteEnum(QuestInfoMessages.AddRepeatableQuest);
     bs.Write(questID);
 }
예제 #7
0
 /// <summary>
 /// Appends a message to a <see cref="BitStream"/> for synchronizing the client's guild information for when
 /// a member goes offline.
 /// The message is then read and handled by the receiver using <see cref="UserGuildInformation.Read"/>.
 /// </summary>
 /// <param name="pw">The <see cref="BitStream"/> to append the message to.</param>
 /// <param name="memberName">The name of the guild member that went offline.</param>
 public static void WriteRemoveOnlineMember(BitStream pw, string memberName)
 {
     pw.WriteEnum(GuildInfoMessages.RemoveOnlineMember);
     pw.Write(memberName);
 }
예제 #8
0
 /// <summary>
 /// Appends a message to a <see cref="BitStream"/> for synchronizing the client's guild information for when
 /// a member's rank changes.
 /// The message is then read and handled by the receiver using <see cref="UserGuildInformation.Read"/>.
 /// </summary>
 /// <param name="pw">The <see cref="BitStream"/> to append the message to.</param>
 /// <param name="member">The guild member who's rank changed.</param>
 public static void WriteUpdateMemberRank(BitStream pw, GuildMemberNameRank member)
 {
     pw.WriteEnum(GuildInfoMessages.UpdateRank);
     pw.Write(null, member);
 }
예제 #9
0
        /// <summary>
        /// Appends a message to a <see cref="BitStream"/> for synchronizing the client's guild information for when
        /// the guild changes or the user is receiving their first update on the guild state and all values have to be sent.
        /// The message is then read and handled by the receiver using <see cref="UserGuildInformation.Read"/>.
        /// </summary>
        /// <param name="pw">The <see cref="BitStream"/> to append the message to.</param>
        /// <param name="guild">The guild to send the state values for.</param>
        public static void WriteGuildInfo(BitStream pw, IGuild guild)
        {
            pw.WriteEnum(GuildInfoMessages.SetGuild);

            if (guild == null)
            {
                pw.Write(false);
                return;
            }

            var members = guild.GetMembers().ToArray();
            var onlineMembers = guild.OnlineMembers.ToArray();

            pw.Write(true);
            pw.Write(guild.Name);
            pw.Write(guild.Tag);

            pw.Write((ushort)members.Length);
            for (var i = 0; i < members.Length; i++)
            {
                pw.Write(null, members[i]);
            }

            pw.Write((ushort)onlineMembers.Length);
            for (var i = 0; i < onlineMembers.Length; i++)
            {
                pw.Write(onlineMembers[i].Name);
            }
        }
예제 #10
0
 /// <summary>
 /// Appends a message to a <see cref="BitStream"/> for synchronizing the client's guild information for when
 /// a member is added to the guild.
 /// The message is then read and handled by the receiver using <see cref="UserGuildInformation.Read"/>.
 /// </summary>
 /// <param name="pw">The <see cref="BitStream"/> to append the message to.</param>
 /// <param name="member">The guild member that was added.</param>
 public static void WriteAddMember(BitStream pw, GuildMemberNameRank member)
 {
     pw.WriteEnum(GuildInfoMessages.AddMember);
     pw.Write(null, member);
 }
예제 #11
0
 /// <summary>
 /// Appends a message to a <see cref="BitStream"/> for synchronizing the client's group information for when
 /// a member is removed from the group.
 /// The message is then read and handled by the receiver using <see cref="UserGroupInformation.Read"/>.
 /// </summary>
 /// <param name="bs">The <see cref="BitStream"/> to append the message to.</param>
 /// <param name="member">The group member to remove.</param>
 public static void WriteRemoveMember(BitStream bs, IGroupable member)
 {
     bs.WriteEnum(GroupInfoMessages.RemoveMember);
     bs.Write(member.Name);
 }
예제 #12
0
        /// <summary>
        /// Appends a message to a <see cref="BitStream"/> for synchronizing all of the client's group information.
        /// The message is then read and handled by the receiver using <see cref="UserGroupInformation.Read"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to append the message to.</param>
        /// <param name="group">The group information. Can be null for when the user is not in a group.</param>
        public static void WriteGroupInfo(BitStream bs, IGroup group)
        {
            bs.WriteEnum(GroupInfoMessages.SetGroup);

            // Check if in a group
            if (group == null)
            {
                bs.Write(false);
                return;
            }

            bs.Write(true);

            // Write the group member names
            var members = group.Members.Select(x => x.Name).ToArray();
            Debug.Assert(members.Length <= byte.MaxValue);
            bs.Write((byte)members.Length);
            bs.Write(members, 0, members.Length);

            // Write the founder's name
            bs.Write(group.Founder.Name);
        }
예제 #13
0
 /// <summary>
 /// Writes an unsigned integer of up to 32 bits.
 /// </summary>
 /// <param name="name">Unused by the <see cref="BinaryValueWriter"/>.</param>
 /// <param name="value">Value to write.</param>
 /// <param name="bits">Number of bits to write.</param>
 public void Write(string name, uint value, int bits)
 {
     _writer.Write(value, bits);
 }