/// <summary> /// Matches best recipe for the current input items. /// Please note it will return null if there best recipe is already selected. /// Please note it will not return better recipe if currently /// there is a selected recipe which using more input slots. /// </summary> public static Recipe SharedMatchBestRecipe( ManufacturingState state, ManufacturingConfig config, IStaticWorldObject objectManufacturer) { var selectedRecipe = state.SelectedRecipe; var bestRecipe = config.MatchRecipe(objectManufacturer, state.CraftingQueue); if (selectedRecipe == bestRecipe) { return(null); } if (bestRecipe != null && selectedRecipe != null && selectedRecipe.CanBeCrafted(objectManufacturer, state.CraftingQueue, 1) && bestRecipe.InputItems.Count <= selectedRecipe.InputItems.Count) { // the best recipe is ignored because selected recipe is also valid // and it has the same or more amount of input items return(null); } return(bestRecipe); }