/// <summary> /// /// </summary> /// <param name="member"></param> public void AddMember(CharacterEntity member) { // new player just joined Dispatch(WorldMessage.PARTY_MEMBER_LIST(member)); m_memberById.Add(member.Id, member); AddHandler(member.SafeDispatch); // set party and send members list member.PartyId = Id; member.SafeDispatch(WorldMessage.PARTY_CREATE_SUCCESS(m_leader.Name)); member.SafeDispatch(WorldMessage.PARTY_SET_LEADER(m_leader.Id)); member.SafeDispatch(WorldMessage.PARTY_MEMBER_LIST(m_memberById.Values.ToArray())); }
/// <summary> /// /// </summary> /// <param name="member"></param> /// <param name="kickerId"></param> public void RemoveMember(CharacterEntity member, string kickerId = "") { if (m_memberById.ContainsKey(member.Id)) { member.PartyId = -1; m_memberById.Remove(member.Id); RemoveHandler(member.SafeDispatch); Dispatch(WorldMessage.PARTY_MEMBER_LEFT(member.Id)); member.SafeDispatch(WorldMessage.PARTY_LEAVE(kickerId)); if (m_memberById.Count == 1) { Dispose(); } else if (member.Id == m_leader.Id) { m_leader = m_memberById.First().Value; Dispatch(WorldMessage.PARTY_SET_LEADER(m_leader.Id)); } } }
/// <summary> /// /// </summary> /// <param name="member"></param> /// <param name="memberId"></param> public void KickMember(CharacterEntity member, long memberId) { // only the leader can kick someone if (member.Id != m_leader.Id || member.Id == memberId) { member.SafeDispatch(WorldMessage.BASIC_NO_OPERATION()); return; } // exists ? if (!m_memberById.ContainsKey(memberId)) { member.SafeDispatch(WorldMessage.BASIC_NO_OPERATION()); return; } // get the f**k out RemoveMember(m_memberById[memberId], member.Id.ToString()); }