Skip to content

RecipeLayers

Namespace Nfty.Core.Formats in assembly Nfty.Core.

public static class RecipeLayers

Resolving a recipe's layerOrder to its ingredients, in one place.

Methods

ById(LoadedRecipe)

public static Dictionary<string, LoadedIngredient> ById(LoadedRecipe recipe);

The recipe's ingredients by id; on a duplicate id the last one wins.

Parameters

  • recipe (LoadedRecipe) - The recipe.

Returns. The ingredients by id.

TryResolve(LoadedRecipe, List<LoadedIngredient>)

public static bool TryResolve(LoadedRecipe recipe, out List<LoadedIngredient> layers);

Resolves a recipe's layerOrder to its ingredients, in order. Never throws: a transiently invalid book (a duplicate ingredient id, or a layerOrder entry naming a removed ingredient) is a normal state for live callers, not a crash. Ids resolve duplicate-tolerantly (last one wins, as RecipeLayers.ById()), and an entry with no ingredient fails the whole recipe back as "unresolved". Deciding what makes a book legal is the validator's job.

Parameters

  • recipe (LoadedRecipe) - The recipe.
  • layers (List<LoadedIngredient>) - The ingredients in layer order when this returns true; otherwise empty.

Returns. Whether every layerOrder entry named an ingredient.