Esempio n. 1
0
        /// <summary>
        /// Clear this group
        /// </summary>
        public void DisbandGroup()
        {
            GroupMgr.RemoveGroup(this);

            if (Mission != null)
            {
                Mission.ExpireMission();
            }

            LivingLeader = null;
            m_groupMembers.Clear();
        }
Esempio n. 2
0
        /// <summary>
        /// Removes a player from the group
        /// </summary>
        /// <param name="player">GamePlayer to be removed</param>
        /// <returns>true if removed, false if not</returns>
        public virtual bool RemoveMember(GameLiving living)
        {
            lock (m_groupMembers)
            {
                if (!m_groupMembers.Contains(living))
                {
                    return(false);
                }

                m_groupMembers.Remove(living);

                if (m_groupMembers.Count <= 0)
                {
                    GroupMgr.RemoveGroup(this);
                }
            }

            living.Group      = null;
            living.GroupIndex = 0xFF;
            if (living is GamePlayer)
            {
                ((GamePlayer)living).Out.SendGroupWindowUpdate();
                ((GamePlayer)living).Out.SendQuestListUpdate();
            }
            UpdateGroupWindow();
            if (living is GamePlayer)
            {
                GamePlayer player = (GamePlayer)living;
                player.Out.SendMessage("You leave your group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                player.Notify(GamePlayerEvent.LeaveGroup, player);
            }
            SendMessageToGroupMembers(living.Name + " has left the group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);

            // only one player left?
            if (MemberCount == 1)
            {
                // RR4: Group is disbanded, ending mission group if any
                if (Mission != null)
                {
                    Mission.ExpireMission();
                }
                RemoveMember(m_groupMembers[0]);
            }
            else if (Leader == living && MemberCount > 0)
            {
                //only allow players to be leaders
                for (int i = 0; i < m_groupMembers.Count; i++)
                {
                    if (m_groupMembers[i] is GamePlayer)
                    {
                        Leader = m_groupMembers[i] as GamePlayer;
                        SendMessageToGroupMembers(Leader.Name + " is the new group leader.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        break;
                    }
                }
                //if the leader is still the same, disband group, only npcs left
                if (Leader == living)
                {
                    lock (m_groupMembers)
                    {
                        foreach (GameLiving member in m_groupMembers)
                        {
                            member.Group      = null;
                            member.GroupIndex = 0xFF;
                            GameEventMgr.Notify(GroupEvent.MemberDisbanded, this, new MemberDisbandedEventArgs(member));
                        }
                    }
                    m_groupMembers.Clear();
                }
            }
            UpdateGroupIndexes();
            GameEventMgr.Notify(GroupEvent.MemberDisbanded, this, new MemberDisbandedEventArgs(living));

            return(true);
        }