Exemple #1
2
        /// <summary>
        /// Returns a list of recipes from selected skill
        /// </summary>
        /// <param name="skillLine"></param>
        /// <returns></returns>
        public static TradeSkill GetTradeSkill(SkillLine skillLine)
        {
            if (!ObjectManager.IsInGame)
            {
                throw new InvalidOperationException("Must Be in game to call GetTradeSkill()");
            }
            if (skillLine == 0 || !SupportedSkills.Contains(skillLine))
            {
                throw new InvalidOperationException(String.Format("The tradekill {0} can not be loaded", skillLine));
            }
            // if HB is not running then we need to pulse objectmanger for item counts
            if (!TreeRoot.IsRunning)
            {
                ObjectManager.Update();
            }
            //Stopwatch sw = new Stopwatch();
            TradeSkill tradeSkill = null;

            try
            {
                //using (new FrameLock())
                //{
                WoWSkill wowSkill = ObjectManager.Me.GetSkill(skillLine);
                // sw.Start();
                tradeSkill = new TradeSkill(wowSkill);

                List <SkillLineAbilityEntry> entries = tradeSkill.GetSkillLineAbilityEntries();
                foreach (SkillLineAbilityEntry entry in entries)
                {
                    // check if the entry is a recipe
                    if (entry.NextSpellId == 0 && entry.GreySkillLevel > 0)
                    {
                        var recipe = new Recipe(tradeSkill, entry);
                        recipe.UpdateHeader();
                        tradeSkill.AddRecipe(recipe);
                    }
                    //Logging.Write(entry.ToString());
                }
                //}
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
            }
            //Logging.Write("it took {0} ms to load {1}", sw.ElapsedMilliseconds, skillLine);
            return(tradeSkill);
        }
Exemple #2
0
        /// <summary>
        /// Returns a list of recipes from selected skill
        /// </summary>
        /// <param name="skillLine"></param>
        /// <returns></returns>
        public static TradeSkill GetTradeSkill(SkillLine skillLine)
        {
            if (!StyxWoW.IsInGame)
                throw new InvalidOperationException("Must Be in game to call GetTradeSkill()");
            if (skillLine == 0 || !SupportedSkills.Contains(skillLine))
                throw new InvalidOperationException(String.Format("The tradekill {0} can not be loaded", skillLine));
            // if HB is not running then we need to pulse objectmanger for item counts
            if (!TreeRoot.IsRunning)
                ObjectManager.Update();
            //Stopwatch sw = new Stopwatch();
            TradeSkill tradeSkill = null;
            try
            {
                using (StyxWoW.Memory.AcquireFrame())
                {
                    WoWSkill wowSkill = StyxWoW.Me.GetSkill(skillLine);
                    // sw.Start();
                    tradeSkill = new TradeSkill(wowSkill);

                    List<SkillLineAbilityEntry> entries = tradeSkill.GetSkillLineAbilityEntries();
                    foreach (SkillLineAbilityEntry entry in entries)
                    {
                        // check if the entry is a recipe
                        if (entry.NextSpellId == 0 && entry.GreySkillLevel > 0 && entry.TradeSkillCategoryIndex != 0)
                        {
                            var recipe = new Recipe(tradeSkill, entry);
                            recipe.UpdateHeader();
                            tradeSkill.AddRecipe(recipe);
                        }
                        //Logging.Write(entry.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
            }
            //Logging.Write("it took {0} ms to load {1}", sw.ElapsedMilliseconds, skillLine);
            return tradeSkill;
        }