예제 #1
0
        /// <summary>
        /// Loads all Factions that this Character already knows from the DB
        /// </summary>
        public void Load()
        {
            foreach (var record in ReputationRecord.Load(m_owner.Record.Guid))
            {
                var fac = FactionMgr.Get(record.ReputationIndex);
                if (fac != null)
                {
                    if (m_byIndex.ContainsKey(record.ReputationIndex))
                    {
                        log.Warn("Character {0} had Reputation with Faction {1} more than once.", m_owner, record.ReputationIndex);
                    }
                    else
                    {
                        var rep = new Reputation(record, fac);
                        m_byIndex.Add(record.ReputationIndex, rep);
                    }
                }
                else
                {
                    log.Warn("Character {0} has saved Reputation with invalid Faction: {1}", m_owner, record.ReputationIndex);

                    // record.DeleteAndFlush();
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Loads all Factions that this Character already knows from the DB
 /// </summary>
 public void Load()
 {
     foreach (ReputationRecord record in ReputationRecord.Load(this.m_owner.Record.Guid))
     {
         Faction faction = FactionMgr.Get(record.ReputationIndex);
         if (faction != null)
         {
             if (this.m_byIndex.ContainsKey(record.ReputationIndex))
             {
                 ReputationCollection.log.Warn("Character {0} had Reputation with Faction {1} more than once.",
                                               (object)this.m_owner, (object)record.ReputationIndex);
             }
             else
             {
                 Reputation reputation = new Reputation(record, faction);
                 this.m_byIndex.Add(record.ReputationIndex, reputation);
             }
         }
         else
         {
             ReputationCollection.log.Warn("Character {0} has saved Reputation with invalid Faction: {1}",
                                           (object)this.m_owner, (object)record.ReputationIndex);
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Creates a Reputation object that represents the relation to the given faction, or null
        /// </summary>
        /// <param name="factionIndex">The repListId of the faction</param>
        private Reputation Create(FactionReputationIndex factionIndex)
        {
            var fac = FactionMgr.Get(factionIndex);

            if (fac != null)
            {
                return(Create(fac));
            }
            return(null);
        }
예제 #4
0
        /// <summary>
        /// Creates a Reputation object that represents the relation to the given faction, or null
        /// </summary>
        /// <param name="factionIndex">The repListId of the faction</param>
        private Reputation Create(FactionReputationIndex factionIndex)
        {
            Faction faction = FactionMgr.Get(factionIndex);

            if (faction != null)
            {
                return(this.Create(faction));
            }
            return((Reputation)null);
        }
예제 #5
0
        private static void InitFactionTemplateDBC()
        {
            foreach (FactionTemplateEntry template in
                     new MappedDBCReader <FactionTemplateEntry, FactionTemplateConverter>(
                         RealmServerConfiguration.GetDBCFile("FactionTemplate.dbc")).Entries.Values)
            {
                FactionMgr.FactionTplEntries[template.Id] = template;
                if (template.FactionId != FactionId.None)
                {
                    FactionEntry factionEntry = FactionMgr.FactionEntries[template.FactionId];
                    Faction      val          = new Faction(factionEntry, template);
                    ArrayUtil.Set <Faction>(ref FactionMgr.ByTemplateId, template.Id, val);
                    if (FactionMgr.Get(template.FactionId) == null)
                    {
                        ArrayUtil.Set <Faction>(ref FactionMgr.ById, (uint)factionEntry.Id, val);
                        if (factionEntry.FactionIndex > FactionReputationIndex.None)
                        {
                            ArrayUtil.Set <Faction>(ref FactionMgr.ByReputationIndex, (uint)factionEntry.FactionIndex,
                                                    val);
                        }
                    }
                }
            }

            (FactionMgr.ByRace[1] = FactionMgr.ById[1]).SetAlliancePlayer();
            (FactionMgr.ByRace[3] = FactionMgr.ById[3]).SetAlliancePlayer();
            (FactionMgr.ByRace[4] = FactionMgr.ById[4]).SetAlliancePlayer();
            (FactionMgr.ByRace[7] = FactionMgr.ById[8]).SetAlliancePlayer();
            (FactionMgr.ByRace[11] = FactionMgr.ById[927]).SetAlliancePlayer();
            (FactionMgr.ByRace[2] = FactionMgr.ById[2]).SetHordePlayer();
            (FactionMgr.ByRace[5] = FactionMgr.ById[5]).SetHordePlayer();
            (FactionMgr.ByRace[6] = FactionMgr.ById[6]).SetHordePlayer();
            (FactionMgr.ByRace[8] = FactionMgr.ById[9]).SetHordePlayer();
            (FactionMgr.ByRace[10] = FactionMgr.ById[914]).SetHordePlayer();
            foreach (Faction faction1 in FactionMgr.ById)
            {
                if (faction1 != null)
                {
                    faction1.Init();
                    if (faction1.Entry.ParentId != FactionId.None)
                    {
                        Faction faction2 = FactionMgr.Get(faction1.Entry.ParentId);
                        if (faction2 != null)
                        {
                            faction2.Children.Add(faction1);
                        }
                    }
                }
            }
        }
예제 #6
0
        public Reputation ModValue(FactionId factionId, int value)
        {
            var faction = FactionMgr.Get(factionId);

            return(ModValue(faction.ReputationIndex, value));
        }
예제 #7
0
 public Reputation ModValue(FactionId factionId, int value)
 {
     return(this.ModValue(FactionMgr.Get(factionId).ReputationIndex, value));
 }
예제 #8
0
        internal void Init()
        {
            if (this.Id == FactionId.Alliance || this.Entry.ParentId == FactionId.Alliance)
            {
                this.IsAlliance = true;
                this.Group      = FactionGroup.Alliance;
            }
            else if (this.Id == FactionId.Horde || this.Entry.ParentId == FactionId.Horde)
            {
                this.IsHorde = true;
                this.Group   = FactionGroup.Horde;
            }

            foreach (Faction faction in ((IEnumerable <Faction>)FactionMgr.ByTemplateId).Where <Faction>(
                         (Func <Faction, bool>)(faction => faction != null)))
            {
                if (this.IsPlayer && faction.Template.FriendGroup.HasAnyFlag(FactionGroupMask.Player))
                {
                    this.Friends.Add(faction);
                    faction.Friends.Add(this);
                }

                if (this.Template.FriendGroup.HasAnyFlag(faction.Template.FactionGroup))
                {
                    this.Friends.Add(faction);
                }
            }

            foreach (FactionId friendlyFaction in this.Template.FriendlyFactions)
            {
                Faction faction = FactionMgr.Get(friendlyFaction);
                if (faction != null)
                {
                    this.Friends.Add(faction);
                    faction.Friends.Add(this);
                }
            }

            this.Friends.Add(this);
            foreach (Faction faction in ((IEnumerable <Faction>)FactionMgr.ByTemplateId).Where <Faction>(
                         (Func <Faction, bool>)(faction => faction != null)))
            {
                if (this.IsPlayer && faction.Template.EnemyGroup.HasAnyFlag(FactionGroupMask.Player))
                {
                    this.Enemies.Add(faction);
                    faction.Enemies.Add(this);
                }

                if (this.Template.EnemyGroup.HasAnyFlag(faction.Template.FactionGroup))
                {
                    this.Enemies.Add(faction);
                }
            }

            foreach (FactionId enemyFaction in this.Template.EnemyFactions)
            {
                Faction faction = FactionMgr.Get(enemyFaction);
                if (faction != null)
                {
                    if (!this.Template.Flags.HasAnyFlag(FactionTemplateFlags.Flagx400))
                    {
                        this.Enemies.Add(faction);
                    }
                    faction.Enemies.Add(this);
                }
            }

            foreach (Faction faction in ((IEnumerable <Faction>)FactionMgr.ByTemplateId).Where <Faction>(
                         (Func <Faction, bool>)(faction => faction != null)))
            {
                if (!this.Friends.Contains(faction) && !this.Enemies.Contains(faction))
                {
                    this.Neutrals.Add(faction);
                }
            }

            if (this.Id == FactionId.Prey)
            {
                this.Enemies.Clear();
            }
            this.IsNeutral = this.Enemies.Count == 0 && this.Friends.Count == 0;
        }
예제 #9
0
        internal void Init()
        {
            if (Id == FactionId.Alliance || Entry.ParentId == FactionId.Alliance)
            {
                IsAlliance = true;
                Group      = FactionGroup.Alliance;
            }
            else if (Id == FactionId.Horde || Entry.ParentId == FactionId.Horde)
            {
                IsHorde = true;
                Group   = FactionGroup.Horde;
            }

            foreach (Faction faction in FactionMgr.ByTemplateId.Where(
                         faction => faction != null))
            {
                if (IsPlayer && faction.Template.FriendGroup.HasAnyFlag(FactionGroupMask.Player))
                {
                    Friends.Add(faction);
                    faction.Friends.Add(this);
                }

                if (Template.FriendGroup.HasAnyFlag(faction.Template.FactionGroup))
                {
                    Friends.Add(faction);
                }
            }

            foreach (FactionId friendlyFaction in Template.FriendlyFactions)
            {
                Faction faction = FactionMgr.Get(friendlyFaction);
                if (faction != null)
                {
                    Friends.Add(faction);
                    faction.Friends.Add(this);
                }
            }

            Friends.Add(this);
            foreach (Faction faction in FactionMgr.ByTemplateId.Where(
                         faction => faction != null))
            {
                if (IsPlayer && faction.Template.EnemyGroup.HasAnyFlag(FactionGroupMask.Player))
                {
                    Enemies.Add(faction);
                    faction.Enemies.Add(this);
                }

                if (Template.EnemyGroup.HasAnyFlag(faction.Template.FactionGroup))
                {
                    Enemies.Add(faction);
                }
            }

            foreach (FactionId enemyFaction in Template.EnemyFactions)
            {
                Faction faction = FactionMgr.Get(enemyFaction);
                if (faction != null)
                {
                    if (!Template.Flags.HasAnyFlag(FactionTemplateFlags.Flagx400))
                    {
                        Enemies.Add(faction);
                    }
                    faction.Enemies.Add(this);
                }
            }

            foreach (Faction faction in FactionMgr.ByTemplateId.Where(
                         faction => faction != null))
            {
                if (!Friends.Contains(faction) && !Enemies.Contains(faction))
                {
                    Neutrals.Add(faction);
                }
            }

            if (Id == FactionId.Prey)
            {
                Enemies.Clear();
            }
            IsNeutral = Enemies.Count == 0 && Friends.Count == 0;
        }
예제 #10
0
        internal void Init()
        {
            if (Id == FactionId.Alliance || Entry.ParentId == FactionId.Alliance)
            {
                IsAlliance = true;
                Group      = FactionGroup.Alliance;
            }
            else if (Id == FactionId.Horde || Entry.ParentId == FactionId.Horde)
            {
                IsHorde = true;
                Group   = FactionGroup.Horde;
            }

            // friends
            foreach (var faction in FactionMgr.ByTemplateId.Where(faction => faction != null))
            {
                if (IsPlayer && faction.Template.FriendGroup.HasAnyFlag(FactionGroupMask.Player))
                {
                    Friends.Add(faction);
                    faction.Friends.Add(this);
                }

                if (!Template.FriendGroup.HasAnyFlag(faction.Template.FactionGroup))
                {
                    continue;
                }

                Friends.Add(faction);
            }


            var friends = Template.FriendlyFactions;

            foreach (var factionId in friends)
            {
                var friend = FactionMgr.Get(factionId);
                if (friend == null)
                {
                    continue;
                }
                Friends.Add(friend);
                friend.Friends.Add(this);
            }

            // we are friends with ourselves
            Friends.Add(this);

            // enemies
            foreach (var faction in FactionMgr.ByTemplateId.Where(faction => faction != null))
            {
                if (IsPlayer && faction.Template.EnemyGroup.HasAnyFlag(FactionGroupMask.Player))
                {
                    Enemies.Add(faction);
                    faction.Enemies.Add(this);
                }

                if (!Template.EnemyGroup.HasAnyFlag(faction.Template.FactionGroup))
                {
                    continue;
                }

                Enemies.Add(faction);
            }

            var enemies = Template.EnemyFactions;

            for (var j = 0; j < enemies.Length; j++)
            {
                var enemy = FactionMgr.Get(enemies[j]);
                if (enemy == null)
                {
                    continue;
                }

                if (!Template.Flags.HasAnyFlag(FactionTemplateFlags.Flagx400))
                {
                    Enemies.Add(enemy);
                }


                enemy.Enemies.Add(this);
            }

            // neutrals
            foreach (var faction in FactionMgr.ByTemplateId.Where(faction => faction != null))
            {
                if (!Friends.Contains(faction) && !Enemies.Contains(faction))
                {
                    Neutrals.Add(faction);
                }
            }

            if (Id == FactionId.Prey)
            {
                // For some reason, prey has predators as enemy (but they shouldnt ever attack)
                Enemies.Clear();
            }

            IsNeutral = Enemies.Count == 0 && Friends.Count == 0;
        }