internal Recipe(TradeSkill parent, SkillLineAbilityEntry skillLineAbilityEntry) { _parent = parent; SpellId = skillLineAbilityEntry.SpellId; OrangeSkillLevel = skillLineAbilityEntry.OrangeSkillLevel; YellowSkillLevel = skillLineAbilityEntry.YellowSkillLevel; GreenSkillLevel = (skillLineAbilityEntry.YellowSkillLevel + skillLineAbilityEntry.GreySkillLevel) / 2; GreySkillLevel = skillLineAbilityEntry.GreySkillLevel; OptimalSkillups = skillLineAbilityEntry.SkillPointsEarned; Skill = skillLineAbilityEntry.SkillLine; HasRecipe = TradeSkill.HasSpell(SpellId); }
/// <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); }
public void LoadTradeSkills() { var newTradeSkills = new List <TradeSkill>(); try { using (StyxWoW.Memory.AcquireFrame()) { foreach (WoWSkill skill in SupportedTradeSkills) { PBLog.Log("Adding TradeSkill {0}", skill.Name); TradeSkill ts = TradeSkill.GetTradeSkill((SkillLine)skill.Id); if (ts != null) { newTradeSkills.Add(ts); } else { IsTradeSkillsLoaded = false; PBLog.Log("Unable to load tradeskill {0}", (SkillLine)skill.Id); return; } } } } catch (Exception ex) { Logging.Write(Colors.Red, ex.ToString()); } finally { lock (tradeSkillLocker) { TradeSkillList = newTradeSkills; } PBLog.Log("Done Loading Tradeskills."); IsTradeSkillsLoaded = true; if (OnTradeSkillsLoaded != null) { OnTradeSkillsLoaded(this, null); } } }
public void Update() { HasRecipe = TradeSkill.HasSpell(SpellId); }