/// <summary>Called when the given member is added</summary> protected virtual void OnAddMember(GroupMember member) { ++this.m_Count; Character character = member.Character; if (character != null) { character.GroupMember = member; } if (this.m_firstMember == null) { this.m_firstMember = this.m_lastMember = member; } else { this.m_lastMember.Next = member; this.m_lastMember = member; } Group.GroupMemberHandler memberAdded = Group.MemberAdded; if (memberAdded == null) { return; } memberAdded(member); }
/// <summary> /// Called before the given member is removed to clean up everything related to the given member /// </summary> protected void OnMemberRemoved(GroupMember member) { Character chr = member.Character; if (chr != null && chr.IsInWorld) { if (!chr.IsInContext) { chr.ExecuteInContext((Action)(() => this.OnMemberRemoved(member))); return; } Group.GroupMemberHandler memberRemoved = Group.MemberRemoved; if (memberRemoved != null) { memberRemoved(member); } --this.m_Count; this.SendEmptyUpdate(chr); chr.GroupMember = (GroupMember)null; GroupHandler.SendResult((IPacketReceiver)chr.Client, GroupResult.NoError); member.SubGroup.RemoveMember(member); member.Character = (Character)null; if (chr.Map is BaseInstance) { BaseInstance instance = (BaseInstance)chr.Map; chr.Map.CallDelayed(Group.GroupInstanceKickDelayMillis, (Action)(() => { if (!chr.IsInWorld || chr.Map != instance || instance.CanEnter(chr)) { return; } chr.TeleportToNearestGraveyard(); })); } } else { Group.GroupMemberHandler memberRemoved = Group.MemberRemoved; if (memberRemoved != null) { memberRemoved(member); } --this.m_Count; Singleton <GroupMgr> .Instance.OfflineChars.Remove(member.Id); member.m_subGroup = (SubGroup)null; } member.m_nextMember = (GroupMember)null; }