StewManager
A class in Root.Township, Alta.Cooking.
Runs the stew in a cooking pot: liquid base, ingredients, garnishes, matching a stew recipe, and swapping the stew entity as it cooks. Probably server driven; the stew entity and ingredient fades are synced to clients.
- Listed in Crafting and making
- Inherits or implements
NetworkEntityBehaviour,ISavable<StewManagerSaveData>,ISavableSave<StewManagerSaveData>,ISavableSaveBase - Derived types
StewManagerSaveData - Documented in Cooking
Constructors
| Member | What it is |
|---|---|
StewManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
13 private and internal fields
| Member | What it is |
|---|---|
private List<Player> cookingPlayers | Players who last held each added ingredient. Only filled and cleared in this build, probably meant for experience. |
private StewRecipe currentRecipe | The stew recipe that matched, or null. |
private List<CookingGarnish> garnishes | Backing field for Garnishes. Saved. |
private AltaEvent garnishRejected | Event fired when a garnish is added beyond the pot's garnish limit. |
private List<CookableItem> ingredients | Backing field for Ingredients. Saved. |
private bool isRealRecipe | True when the ingredients matched a real recipe. Only set and cleared in this build. |
private NetworkEntity liquidSurfaceEntity | Entity at the liquid surface that the stew entity is parented to. |
private static Logger logger | NLog logger for this class. |
private CookingPot pot | The cooking pot on the same object. |
private StewComponent stew | The current stew component, or null. |
private LiquidDefinition stewLiquidBase | Backing field for StewLiquidBase. Saved. |
private MethodSyncStruct<uint> syncFadeOutIngredient | Method sync that fades out an added ingredient. |
private MethodSync syncStewFromEntity | Method sync that tells clients which entity is the stew. |
Properties
| Member | What it is |
|---|---|
List<CookingGarnish> Garnishes { get; } | Garnishes added so far. |
List<CookableItem> Ingredients { get; } | Ingredients added so far. |
LiquidDefinition StewLiquidBase { get; } | The liquid the stew is made from. |
Events
| Member | What it is |
|---|---|
event Action<CookableItem> AddedIngredient | Raised with the cookable item when an ingredient is added. |
Methods
| Member | What it is |
|---|---|
void AddCookableToStew(Cookable cookable) | Adds a cookable's item as an ingredient, fades it out and destroys it. Checks for a recipe once the pot's minimum ingredient count is reached. |
void AddGarnishToStew(ICookingGarnishMarker garnish) | Adds a garnish and fades it out, or raises garnishRejected if the pot already has its maximum garnishes. |
void CreateDefaultStew() | Spawns the default stew from the cooking settings and sets it as this pot's stew. |
override void Initialize() | Sets up the stew created and ingredient fade out sync messages. |
override void OnConnected(Player player) | Server: tells the joining player which entity is the current stew. |
void RemoveAnyStew(bool isDestroyingStewEntity = true) | Clears the stew, ingredients, garnishes, liquid base and recipe, and by default destroys the stew entity. |
void SetBaseLiquid(LiquidDefinition liquid) | Sets the stew's liquid base. Ignores null. |
void SetStewFromEntity(NetworkEntity stewEntity, bool isUsingLiquidBaseTint = false) | Makes an entity the pot's stew: parents it to the liquid surface, updates the liquid, syncs it and follows its cooking stages. |
22 private and internal methods
| Member | What it is |
|---|---|
private void AddGarnish(CookingGarnish garnishItem) | Adds a garnish item to the stew's list and updates the liquid. |
private void AddIngredient(Cookable cookable) | Adds an ingredient to the stew, resets the stew's cooking progress and checks for a recipe once enough are in. |
private bool CheckForRecipe() | Once the pot has its minimum number of ingredients, checks for a recipe and returns true. |
private void CheckForValidRecipe() | Swaps the stew to the matching recipe stew, or to the non-recipe stew, then locks the pot. |
private void CleanExperienceCalculation() | Clears cookingPlayers and isRealRecipe. |
private LiquidContent CreateContentWithTint(Color colorTint) | Builds custom stew liquid content from the stew's visuals and effects, the ingredients, chunk visuals and a tint. |
private IEnumerator DelayDestroyEntity(NetworkEntity entityToDestroy, float waitDuration) (iterator) | Coroutine that destroys an added ingredient's root after the fade-out time. |
private void FadeOutAddedIngredient(IPlayer player, Stream stream, uint addedIngredientEntityIdentifier) | Method sync handler: freezes an added ingredient's pickup and, on reading, dissolves its renderers. |
private void FadeOutEntity(NetworkEntity entity) | Syncs the fade-out of an added ingredient or garnish and destroys it after the fade. |
private IEnumerable<LiquidVisualChunkDefinition> GetChunkVisuals() (iterator) | Lists the chunk visuals of the base liquid, the ingredients and the garnishes. |
private CookableItem[] GetCookableItems() | Returns the ingredients as an array. |
private IEnumerable<EffectDefinitionApplication> GetStewEffects(StewComponent stew) | Gets the stew's effects from StewRecipe.GetStewEffects for the current recipe, base liquid, ingredients and garnishes. |
private void HandleNewStewStage(NetworkEntity newStewEntity) | When the stew cooks to its next stage, takes the new stew entity; if it burnt away, empties the pot. |
private void PlayStewCreatedEffect() | Plays the stew's created effect at the liquid surface. |
private void PlayVisualEffectForStew() | Plays the stew created effect. |
private void SerializeGarnishesList(Stream stream) | Writes or reads the garnish list as item hashes. Not called in this build. |
private void SerializeIngredientsList(Stream stream) | Writes or reads the ingredient list as item hashes. Not called in this build. |
private void StewIngredientsFilled() | Plays the ingredients-filled effect at the liquid surface. |
private void SwapStewToRecipe(StewRecipe recipe) | Replaces the stew with the recipe's base version. |
private void SwapStewToRecipeBaseVersion(uint recipeBaseVersionHash) | Replaces the stew entity with the one for the given prefab hash and uses it. |
private void SyncStewCreated(IPlayer player, Stream stream) | Method sync handler that sends the stew entity; remote clients store it and play the created effect. |
private void UpdateLiquidContainer(bool isUsingLiquidBaseTint = false) | Turns the pot's liquid into stew liquid with the current visuals and effects. |
Used in
Members of other types that take, return or hold a StewManager: