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.
- Listed in Crafting and making
- Inherits or implements
HashedGeneralValue<StewRecipe>,IPageBasis,ICraftingIngredientProvider - Derived types
StewRecipe,StewRecipePageProvider - Attributes
HashedPath - Documented in Cooking
Constructors
| Member | What it is |
|---|---|
StewRecipe() | Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private uint baseVersionHash | Backing field for BaseVersionHash. |
private static Dictionary<EffectDefinition, float> combinedStrengths | Shared scratch map used while working out stew effects. |
private EffectDefinitionApplication[] effectModifiers | Backing field for EffectModifiers. |
private Dictionary<EffectDefinition, float> effectModifiersMap | Lazy cache behind EffectModifiersMap. |
private EffectDefinitionApplication[] extraEffects | Backing field for ExtraEffects. |
private static List<CookableItem> givenIngredients | Shared scratch list used while matching ingredients. |
private List<LiquidDefinition> possibleLiquids | Liquids this stew can be made with. FindStewRecipeForIngredients requires the stew's liquid to be in it. |
private List<StewIngredientBase> stewIngredients | Backing field for StewIngredients. |
Properties
| Member | What 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
| Member | What 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
| Member | What 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: