Ejemplo n.º 1
0
        /// <summary>
        /// If we want this method to be public,
        /// it should update all Quests correctly (remove non-existant ones etc)
        /// </summary>
        internal void Load()
        {
            QuestRecord[] records;
            try
            {
                records = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }
            catch (Exception e)
            {
                RealmDBMgr.OnDBError(e);
                records = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }

            if (records != null)
            {
                foreach (var record in records)
                {
                    var templ = QuestMgr.GetTemplate(record.QuestTemplateId);
                    if (templ != null)
                    {
                        var quest = new Quest(this, record, templ);
                        AddQuest(quest);

                        //Cancel any quests relating to inactive events
                        if (templ.EventIds.Count > 0)
                        {
                            if (!templ.EventIds.Where(WorldEventMgr.IsEventActive).Any())
                            {
                                quest.Cancel(false);
                            }
                        }
                    }
                    else
                    {
                        log.Error("Character {0} had Invalid Quest: {1} (Record: {2})", Owner,
                                  record.QuestTemplateId, record.QuestRecordId);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// If we want this method to be public,
        /// it should update all Quests correctly (remove non-existant ones etc)
        /// </summary>
        internal void Load()
        {
            QuestRecord[] recordForCharacter;
            try
            {
                recordForCharacter = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }
            catch (Exception ex)
            {
                RealmDBMgr.OnDBError(ex);
                recordForCharacter = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }

            if (recordForCharacter == null)
            {
                return;
            }
            foreach (QuestRecord record in recordForCharacter)
            {
                QuestTemplate template = QuestMgr.GetTemplate(record.QuestTemplateId);
                if (template != null)
                {
                    Quest quest = new Quest(this, record, template);
                    AddQuest(quest);
                    if (template.EventIds.Count > 0 && !template.EventIds
                        .Where(WorldEventMgr.IsEventActive).Any())
                    {
                        quest.Cancel(false);
                    }
                }
                else
                {
                    log.Error("Character {0} had Invalid Quest: {1} (Record: {2})", Owner,
                              record.QuestTemplateId, record.QuestRecordId);
                }
            }
        }