// Get the total amount of a specific needed mat in all steps public static int GetTotalNeededMat(IProfession profession, Item itemToSearch) { int amount = 0; foreach (Step s in profession.AllSteps) { int pickFromVirtualBag = 0; // If it's the current step make sure we mitigate to match amount goal if (s == profession.CurrentStep && s.Type == Step.StepType.CraftToLevel && s.EstimatedAmountOfCrafts != 0) { s.EstimatedAmountOfCrafts = s.GetRemainingProfessionLevels(); } else if (s == profession.CurrentStep && s.Type == Step.StepType.CraftAll) { pickFromVirtualBag = PickFromVirtualBag(s.ItemoCraft, s.EstimatedAmountOfCrafts); } // We search the targetted mat in the current step item or its children Item.Mat searchedMat = s.ItemoCraft.Materials.Find(i => i.Item.ItemId == itemToSearch.ItemId || i.Item.Materials.Exists(it => it.Item.ItemId == itemToSearch.ItemId)); if (searchedMat.Item != null) { if (ToolBox.GetProfessionLevel(profession.Name) < s.LevelToReach || s.ItemoCraft.IsAPrerequisiteItem) { amount += GetMaterialAmountInItem(s.ItemoCraft, itemToSearch, s.EstimatedAmountOfCrafts - pickFromVirtualBag); } } } virtualBag.Clear(); return(amount); }
public int GetAmountMissingMaterial(Item.Mat mat) { // If craft all items if (Type == StepType.CraftAll) { return((EstimatedAmountOfCrafts * mat.Amount) - ItemsManager.GetItemCountById(mat.Item.ItemId)); //return Math.Max(0, (estimatedAmountOfCrafts * mat.amount) - ToolBox.GetAlreadyCrafted(Main.currentProfession.ProfessionName.ToString(), mat.item.name)); } // or if we only need to craft until we level up else { Logger.LogDebug($"{GetRemainingProfessionLevels()} levels to gain"); return((GetRemainingProfessionLevels() * mat.Amount) - ItemsManager.GetItemCountById(mat.Item.ItemId)); } }