Ejemplo n.º 1
0
        /// <summary>Initialize the Guild after loading from DB</summary>
        internal void InitAfterLoad()
        {
            GuildRank[] all = GuildRank.FindAll(this);
            if (all.Length == 0)
            {
                Guild.log.Warn(string.Format("Guild {0} did not have ranks - Recreating default Ranks.",
                                             (object)this));
                this.m_ranks = GuildMgr.CreateDefaultRanks(this);
            }
            else
            {
                this.m_ranks = new ImmutableList <GuildRank>(
                    (IEnumerable <GuildRank>)((IEnumerable <GuildRank>)all).OrderBy <GuildRank, int>(
                        (Func <GuildRank, int>)(rank => rank.RankIndex)));
            }

            foreach (GuildRank rank in this.m_ranks)
            {
                rank.InitRank();
            }
            foreach (GuildMember guildMember in GuildMember.FindAll(this.Id))
            {
                guildMember.Init(this, World.GetCharacter((uint)guildMember.CharacterLowId));
                this.Members.Add(guildMember.Id, guildMember);
            }

            foreach (GuildSkill record in GuildSkill.FindAll(this))
            {
                record.InitAfterLoad(this);
                if (this.Skills[(int)record.Id] == null)
                {
                    this.Skills[(int)record.Id] = record;
                }
                else
                {
                    record.DeleteLater();
                }
            }

            this.m_leader = this[this.LeaderLowId];
            if (this.m_leader == null)
            {
                this.OnNoLeaderFound();
            }
            if (this.m_leader == null)
            {
                return;
            }
            this.Register();
        }
Ejemplo n.º 2
0
        /// <summary>Initialize the Guild after loading from DB</summary>
        internal void InitAfterLoad()
        {
            GuildRank[] all = GuildRank.FindAll(this);
            if (all.Length == 0)
            {
                log.Warn(string.Format("Guild {0} did not have ranks - Recreating default Ranks.",
                                       this));
                m_ranks = GuildMgr.CreateDefaultRanks(this);
            }
            else
            {
                m_ranks = new ImmutableList <GuildRank>(
                    all.OrderBy(
                        rank => rank.RankIndex));
            }

            foreach (GuildRank rank in m_ranks)
            {
                rank.InitRank();
            }
            foreach (GuildMember guildMember in GuildMember.FindAll(Id))
            {
                guildMember.Init(this, World.GetCharacter((uint)guildMember.CharacterLowId));
                Members.Add(guildMember.Id, guildMember);
            }

            foreach (GuildSkill record in GuildSkill.FindAll(this))
            {
                record.InitAfterLoad(this);
                if (Skills[(int)record.Id] == null)
                {
                    Skills[(int)record.Id] = record;
                }
                else
                {
                    record.DeleteLater();
                }
            }

            m_leader = this[LeaderLowId];
            if (m_leader == null)
            {
                OnNoLeaderFound();
            }
            if (m_leader == null)
            {
                return;
            }
            Register();
        }