protected override bool PrivateAllow(SimDescription me) { if (!base.PrivateAllow(me)) { return(false); } if (me.SkillManager == null) { return(false); } SpellcraftSkill skill = me.SkillManager.GetSkill <SpellcraftSkill>(SkillNames.Spellcraft); return(skill != null); }
protected override bool Run(SimDescription me, bool singleSelection) { SpellcraftSkill skill = me.SkillManager.GetSkill <SpellcraftSkill>(SkillNames.Spellcraft); if (skill == null) { if (singleSelection) { SimpleMessageDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me })); } return(false); } if (!ApplyAll) { List <Item> allOptions = new List <Item>(); allOptions.Add(null); foreach (AlchemyRecipe recipe in AlchemyRecipe.AlchemyRecipes) { if (skill.SkillLevel < recipe.SpellcraftSkillLevelRequired) { continue; } int count = 0; if (skill.KnownAlchemyRecipes.Contains(recipe)) { count = 1; } allOptions.Add(new Item(recipe, count)); } CommonSelection <Item> .Results selection = new CommonSelection <Item>(Name, me.FullName, allOptions).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) { return(false); } CommonSelection <Item> .HandleAllOrNothing(selection); mChoices = selection; } foreach (Item item in mChoices) { if (item == null) { continue; } AlchemyRecipe recipe = item.Value; if (skill.KnownAlchemyRecipes.Contains(recipe)) { if (!item.IsSet) { continue; } skill.KnownAlchemyRecipes.Remove(recipe); } else { if (item.IsSet) { continue; } skill.LearnARecipe(recipe); } } return(true); }