示例#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);
        }
示例#2
1
 public TradeSkill(WoWSkill skill)
 {
     this.WoWSkill = skill;
     Recipes       = new Dictionary <uint, Recipe>();
 }
示例#3
1
        /// <summary>
        /// Returns a list of recipes from selected skill
        /// </summary>
        /// <param name="skillLine"></param>
        /// <param name="blockFrame">prevents tradeskill frame from showing</param>
        /// <returns></returns>
        public TradeSkill GetTradeSkill(SkillLine skillLine, bool blockFrame)
        {
            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();
            }
            WoWSkill wowSkill = ObjectManager.Me.GetSkill(skillLine);

            TradeSkill tradeSkill = new TradeSkill(wowSkill);

            //lets copy over to a local variable for performance
            bool   _isVisible = IsVisible;
            bool   loadSkill  = Skill != skillLine || !_isVisible;
            string lua        = string.Format("{0}{1}{2}{3}",
                                              blockFrame && loadSkill ? "if not TradeSkillFrame then LoadAddOn('Blizzard_TradeSkillUI') end local fs = {} local f = EnumerateFrames() while f do if f:IsEventRegistered('TRADE_SKILL_SHOW') == 1 and f:GetName() ~= 'UIParent' then f:UnregisterEvent('TRADE_SKILL_SHOW') table.insert (fs,f) end f = EnumerateFrames(f) end " : "",
                                              // have to hard code in mining since I need to cast 'Smelting' not 'Mining' XD
                                              // also using lua over SpellManager.Cast since its grabing name from DBC. one word, localization.
                                              loadSkill ? (skillLine == SkillLine.Mining ? "CastSpellByID(2656) " : string.Format("CastSpellByName('{0}') ", wowSkill.Name)) : "",
                                              // force cache load
                                              "for i=1, GetNumTradeSkills() do GetTradeSkillItemLink(i) for n=1,GetTradeSkillNumReagents(i) do GetTradeSkillReagentInfo(i,n) end end ",
                                              blockFrame && loadSkill ? "for k,v in pairs(fs) do v:RegisterEvent('TRADE_SKILL_SHOW') end CloseTradeSkill() " : ""
                                              );

            using (new FrameLock())
            {
                if (!string.IsNullOrEmpty(lua))
                {
                    Lua.DoString(lua);
                }

                int _recipeCount = RecipeCount;
                if (Skill != skillLine || _recipeCount <= 0)
                {// we failed to load tradeskill
                    throw new Exception(string.Format("Unable to load {0}", skillLine));
                }
                // array of pointers that point to each recipe structure.
                uint[] recipePtrArray = ObjectManager.Wow.ReadStructArray <uint>(RecipeOffset, RecipeCount);
                for (int index = 0; index < _recipeCount; index++)
                {
                    uint[] recipeData = ObjectManager.Wow.ReadStructArray <uint>(recipePtrArray[index], 9);
                    uint   id         = recipeData[(int)Recipe.RecipeIndex.RecipeID];
                    // check if its a header
                    if (id == uint.MaxValue)
                    {
                        continue; // no further info to get for header
                    }
                    tradeSkill.Recipes.Add(id, new Recipe(recipeData, tradeSkill, skillLine));
                }
                tradeSkill.InitIngredientList();
                tradeSkill.InitToolList();
            }
            return(tradeSkill);
        }
示例#4
0
 /// Opens TradeSkill Frame for the specific skill
 /// </summary>
 /// <param name="skillLine"></param>
 public void Show(SkillLine skillLine)
 {
     if (skillLine != 0 && ObjectManager.IsInGame && !IsVisible)
     {
         WoWSkill wowSkill  = ObjectManager.Me.GetSkill(skillLine);
         bool     loadSkill = Skill != skillLine || !IsVisible;
         // have to hard code in mining since I need to cast 'Smelting' not 'Mining' XD
         // also using lua over SpellManager.Cast since its grabing name from DBC. one word, localization.
         string lua = loadSkill ? (skillLine == SkillLine.Mining ? "CastSpellByID(2656);" : string.Format("CastSpellByName('{0}');", wowSkill.Name)) : null;
         if (lua != null)
         {
             Lua.DoString(lua);
         }
     }
 }
            public ProfessionSkill(SkillLine skill, WoWSkill spell)
            {
                Skill                 = skill;
                MaxValue              = spell.MaxValue;
                CurrentValue          = spell.CurrentValue;
                DailyCooldownSpellIds = null;

                if (MaxValue >= 700 && ProfessionDailyCooldownSpellIds.ContainsKey(Skill))
                {
                    DailyCooldownSpellIds = ProfessionDailyCooldownSpellIds[Skill];
                }

                if (DraenorProfessionSpellIds.ContainsKey(Skill))
                {
                    SpellbookId = DraenorProfessionSpellIds[Skill];
                }
            }
示例#6
0
 public TradeskillHelper(SkillLine skillLine)
 {
     _skillLine = skillLine;
     _wowSkill  = ObjectManager.Me.GetSkill(skillLine);
 }
示例#7
0
 public TradeskillHelper(SkillLine skillLine)
 {
     _skillLine = skillLine;
     _wowSkill = ObjectManager.Me.GetSkill(skillLine);
 }
示例#8
0
        /// <summary>
        /// Updates the skill level, recipe difficulty and adds new recipes.
        /// </summary>
        public void Update()
        {
            if (!StyxWoW.IsInGame)
                return;
            // if HB is not running then we should maybe pulse objectmanger for item counts
            if (!TreeRoot.IsRunning)
                ObjectManager.Update();

            WoWSkill = StyxWoW.Me.GetSkill(SkillLine);
            Dictionary<uint, Recipe> oldList = KnownRecipes;
            // cycle through entire recipe list and check update the 'HasRecipe' property
            foreach (var recipe in Recipes)
            {
                recipe.Value.Update();
            }
            IEnumerable<KeyValuePair<uint, Recipe>> newRecipies = KnownRecipes.Except(oldList);
            foreach (var kv in newRecipies)
            {
                Professionbuddy.Log("Leaned a new recipe {0}", kv.Value.Name);
                using (StyxWoW.Memory.AcquireFrame())
                {
                    kv.Value.UpdateHeader();
                }
            }
            PulseBags();
        }
示例#9
0
 private TradeSkill(WoWSkill skill)
 {
     WoWSkill = skill;
     Recipes = new Dictionary<uint, Recipe>();
 }
示例#10
0
 private TradeSkill(WoWSkill skill)
 {
     WoWSkill = skill;
     Recipes  = new Dictionary <uint, Recipe>();
 }
示例#11
0
 public TradeskillHelper(SkillLine skillLine)
 {
     _skillLine = skillLine;
     _wowSkill  = StyxWoW.Me.GetSkill(skillLine);
 }
 public TradeSkill(WoWSkill skill)
 {
     this.WoWSkill = skill;
     Recipes = new Dictionary<uint, Recipe>();
 }
示例#13
0
 public TradeskillHelper(SkillLine skillLine)
 {
     _skillLine = skillLine;
     _wowSkill = StyxWoW.Me.GetSkill(skillLine);
 }