Example #1
0
        /// <summary>
        /// Adds a living to the group
        /// </summary>
        /// <param name="living">GameLiving to be added to the group</param>
        /// <returns>true if added successfully</returns>
        public virtual bool AddMember(GameLiving living)
        {
            if (!m_groupMembers.FreezeWhile <bool>(l => {
                if (l.Count >= ServerProperties.Properties.GROUP_MAX_MEMBER || l.Count >= (byte.MaxValue - 1))
                {
                    return(false);
                }

                if (l.Contains(living))
                {
                    return(false);
                }

                l.Add(living);
                living.Group = this;
                living.GroupIndex = (byte)(l.Count - 1);
                return(true);
            }))
            {
                return(false);
            }

            SendMessageToGroupMembers(string.Format("{0} has joined the group.", living.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            GameEventMgr.Notify(GroupEvent.MemberJoined, this, new MemberJoinedEventArgs(living));
            return(true);
        }
Example #2
0
        /// <summary>
        /// Adds a living to the group
        /// </summary>
        /// <param name="living">GameLiving to be added to the group</param>
        /// <returns>true if added successfully</returns>
        public virtual bool AddMember(GameLiving living)
        {
            if (!m_groupMembers.FreezeWhile <bool>(l => {
                if (l.Count >= ServerProperties.Properties.GROUP_MAX_MEMBER || l.Count >= (byte.MaxValue - 1))
                {
                    return(false);
                }

                if (l.Contains(living))
                {
                    return(false);
                }

                l.Add(living);
                living.Group = this;
                living.GroupIndex = (byte)(l.Count - 1);
                return(true);
            }))
            {
                return(false);
            }

            UpdateGroupWindow();

            // update icons of joined player to everyone in the group
            UpdateMember(living, true, false);

            // update all icons for just joined player
            var player = living as GamePlayer;

            if (player != null)
            {
                player.Out.SendGroupMembersUpdate(true);
            }

            SendMessageToGroupMembers(string.Format("{0} has joined the group.", living.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            GameEventMgr.Notify(GroupEvent.MemberJoined, this, new MemberJoinedEventArgs(living));
            return(true);
        }