Skip to main content

StewRecipe

A class in Root.Township, Alta.Cooking.

A stew recipe asset: which liquids and ingredients make it, its base prefab and how it changes the stew's effects. Looked up by hash; also a page basis for recipe books.

Constructors​

MemberWhat it is
StewRecipe()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

8 private and internal fields
MemberWhat it is
private uint baseVersionHashBacking field for BaseVersionHash.
private static Dictionary<EffectDefinition, float> combinedStrengthsShared scratch map used while working out stew effects.
private EffectDefinitionApplication[] effectModifiersBacking field for EffectModifiers.
private Dictionary<EffectDefinition, float> effectModifiersMapLazy cache behind EffectModifiersMap.
private EffectDefinitionApplication[] extraEffectsBacking field for ExtraEffects.
private static List<CookableItem> givenIngredientsShared scratch list used while matching ingredients.
private List<LiquidDefinition> possibleLiquidsLiquids this stew can be made with. FindStewRecipeForIngredients requires the stew's liquid to be in it.
private List<StewIngredientBase> stewIngredientsBacking field for StewIngredients.

Properties​

MemberWhat it is
uint BaseVersionHash { get; }Hash of the prefab for this recipe's stew.
EffectDefinitionApplication[] EffectModifiers { get; }Multipliers for effects this recipe changes.
Dictionary<EffectDefinition, float> EffectModifiersMap { get; }EffectModifiers as a dictionary by effect, built on first read.
EffectDefinitionApplication[] ExtraEffects { get; }Effects the recipe adds on top of its ingredients.
bool IsDisabledOnSimpleServer { get; }Always false.
Dictionary<uint, int> PrefabQuantities { get; }Ingredient counts by prefab hash. Only counts cookables whose prefab name contains "Ripe".
List<StewIngredientBase> StewIngredients { get; }The ingredients the recipe needs, one entry each.

Methods​

MemberWhat it is
PageData CreatePage(int preferredProvider)Makes the recipe's page data with the stew recipe page provider.
static StewRecipe FindStewRecipeForIngredients(LiquidDefinition liquid, IEnumerable<CookableItem> ingredients)Best scoring recipe for a liquid and ingredient list (same count, every ingredient matched), or null.
uint GetHash()The recipe's hash.
int GetProviderID(int preferredProvider)Identifier of the stew recipe page provider.
static IEnumerable<EffectDefinitionApplication> GetStewEffects(StewContentArguments arguments) (iterator)Works out a stew's final effects: global, ingredients, liquid, recipe extras and garnishes, then recipe modifiers. Zero strengths are skipped.
protected override void OnValidate()Editor: fills in a default liquid and logs duplicate effects.
6 private and internal methods
MemberWhat it is
private void CheckForDuplicates(EffectDefinitionApplication[] effectsList, string listName)Editor check that logs an error if an effect list has the same effect twice.
private Dictionary<uint, int> GetIngredients()Builds PrefabQuantities: for each ingredient slot, the first cookable whose prefab name has Ripe, counted by prefab hash.
private static float GetModifiedStrength(StewRecipe currentRecipe, EffectDefinition effect, float multiplier)Returns the recipe's modifier for an effect times the multiplier, or 1 or 0 by cooking settings when the recipe has none.
private static void HandleEffectApplication(Dictionary<EffectDefinition, float> combined, IEnumerable<EffectDefinitionApplication> effectApplications, float multiplier)Adds each effect's strength, times a multiplier, into the combined strength map.
private static void HandleGarnishModifiers(Dictionary<EffectDefinition, float> combined, List<CookingGarnish> garnishes)Multiplies already-combined effects by each garnish's effect multipliers.
private bool IsValidIngredientList(IEnumerable<CookableItem> ingredients, out int recipeScore)Checks every recipe slot matches one of the given ingredients and totals a match score for picking the best recipe.

Used in​

Members of other types that take, return or hold a StewRecipe: