[Lookup Anything] show Custom Farming Redux recipes
Pathoschild opened this issue ยท 3 comments
Code snippet from Platonymous:
/// <summary>Returns the name, Texture and required stack of all machines that can use the specified item</summary>
/// <param name="item">The item to be used as material.</param>
public List<Tuple<string, Texture2D, int>> getMachinesForItem(StardewValley.Object item)
{
List<Tuple<string,Texture2D, int>> result = new List<Tuple<string, Texture2D, int>>();
foreach (CustomMachineBlueprint blueprint in CustomFarmingReduxMod.machines)
{
var find = findRecipe(blueprint, new List<Item> { maxed(item) });
if (find is RecipeBlueprint recipe && recipe.materials != null && recipe.materials.Count > 0) {
var material = recipe.materials.Find(i => i.index == -999 || i.index == item.ParentSheetIndex || item.Category == i.index);
if(material is IngredientBlueprint ing)
result.Add(new Tuple<string, Texture2D, int>(blueprint.name, blueprint.getTexture(),ing.stack));
}
}
return result;
}
Proposed Custom Farming Redux API:
/// <summary>Get the machine name + texture + source rectangle, required ingredient stack, and a sample output for all machines that can use the specified item as an ingredient.</summary>
/// <param name="item">The item to use as an ingredient.</param>
public IEnumerable<Tuple<string, Texture2D, Rectangle, int, Item>> getRecipesForIngredient(Item item);