Beispiel #1
0
        /// <summary>
        /// Initialize the Guild after loading from DB
        /// </summary>
        internal void InitAfterLoad()
        {
            var ranks = GuildRank.FindAll(this);

            if (ranks.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>(ranks.OrderBy(rank => rank.RankIndex));
            }

            foreach (var rank in m_ranks)
            {
                rank.InitRank();
            }

            var members = GuildMember.FindAll(Id);

            foreach (var gm in members)
            {
                gm.Init(this, World.GetCharacter((uint)gm.CharacterLowId));
                Members.Add(gm.Id, gm);
            }

            var skills = GuildSkill.FindAll(this);

            foreach (var guildSkill in skills)
            {
                guildSkill.InitAfterLoad(this);
                if (Skills[(int)guildSkill.Id] == null)
                {
                    Skills[(int)guildSkill.Id] = guildSkill;
                }
                else
                {
                    guildSkill.DeleteLater();
                }
            }
            m_leader = this[LeaderLowId];
            if (m_leader == null)
            {
                OnNoLeaderFound();
            }
            if (m_leader != null)
            {
                Register();
            }
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }