Exemplo n.º 1
0
        /// <summary>
        /// Cleanup character invitations and group leader, looter change on character logout/disconnect
        /// </summary>
        /// <param name="member">The GuildMember logging out / disconnecting (or null if the corresponding Character is not in a Guild)</param>
        internal void OnCharacterLogout(GuildMember member)
        {
            if (member == null)
            {
                return;
            }
            Character character = member.Character;

            foreach (IBaseRelation passiveRelation in Singleton <RelationMgr> .Instance.GetPassiveRelations(
                         character.EntityId.Low, CharacterRelationType.GuildInvite))
            {
                Singleton <RelationMgr> .Instance.RemoveRelation(passiveRelation);
            }
            foreach (GuildSkill activeSkill in character.Guild.ActiveSkills)
            {
                activeSkill.RemoveFromCharacter(character);
            }
            if (member.Guild == null)
            {
                return;
            }
            member.LastLogin = DateTime.Now;
            Zone zone = member.Character.Zone;

            member.ZoneId    = zone != null ? (int)zone.Id : 0;
            member.Class     = member.Character.Class;
            member.Level     = member.Character.Level;
            member.Character = null;
            member.UpdateLater();
            using (membersLock.EnterWriteLock())
                OfflineMembers[character.EntityId.Low] = member;
            GuildHandler.SendEventToGuild(member.Guild, GuildEvents.OFFLINE, member);
        }
Exemplo n.º 2
0
 /// <summary>Demotes GuildMember</summary>
 /// <param name="member">member to promote</param>
 /// <returns>true, if success</returns>
 public bool Demote(GuildMember member)
 {
     if (member.Rank.RankIndex >= this.m_ranks.Count - 1)
     {
         return(false);
     }
     ++member.RankId;
     member.UpdateLater();
     return(true);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Promotes GuildMember. It's impossible to promote to guild leader
 /// </summary>
 /// <param name="member">member to promote</param>
 /// <returns>true, if success</returns>
 public bool Promote(GuildMember member)
 {
     if (member.Rank.RankIndex <= 1)
     {
         return(false);
     }
     --member.RankId;
     member.UpdateLater();
     return(true);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Cleanup character invitations and group leader, looter change on character logout/disconnect
        /// </summary>
        /// <param name="member">The GuildMember logging out / disconnecting (or null if the corresponding Character is not in a Guild)</param>
        internal void OnCharacterLogout(GuildMember member)
        {
            if (member == null)
            {
                // null check is only required because we stated in the documentation of this method that memeber is allowed to be null
                return;
            }

            var chr          = member.Character;
            var listInviters = RelationMgr.Instance.GetPassiveRelations(chr.EntityId.Low, CharacterRelationType.GuildInvite);

            foreach (IBaseRelation inviteRelation in listInviters)
            {
                RelationMgr.Instance.RemoveRelation(inviteRelation);
            }
            foreach (var activeSkill in chr.Guild.ActiveSkills)
            {
                activeSkill.RemoveFromCharacter(chr);
            }
            var guild = member.Guild;

            if (guild == null)             // ???
            {
                return;
            }

            member.LastLogin = DateTime.Now;
            var zone = member.Character.Zone;

            member.ZoneId = zone != null ? (int)zone.Id : 0;
            member.Class  = member.Character.Class;
            member.Level  = member.Character.Level;

            member.Character = null;

            member.UpdateLater();

            using (membersLock.EnterWriteLock())
            {
                OfflineMembers[chr.EntityId.Low] = member;
            }

            GuildHandler.SendEventToGuild(member.Guild, GuildEvents.OFFLINE, member);
        }