private void AddCookedIngredient(int playerWhoCooked, SO_Tag ingredient, SO_Tag cookingMethod) { // Checking if the cooking pot belongs to the player who cooked the ingredients if (playerWhoCooked != _CookingPotOwner.ViewID) { return; } CookedIngredient cookedIngredient = new CookedIngredient(ingredient, cookingMethod); DishesBeingPrepared[_CurrentDishBeingCooked].Add(cookedIngredient); // Checking if there is progress after adding ingredient to the pot int preUpdateNumber = _NumberOfIngredientsInPlace; UpdateDishStatus(); if (preUpdateNumber == _NumberOfIngredientsInPlace) { Debug.Log("Ingredient Wasted"); // Letting the spawner know that the current ingredient cooked was not used properly and needs to be spawned again _IngredientWastedEvent.Invoke(ingredient); } else { if (PhotonView.Find(playerWhoCooked).IsMine) { Debug.Log("Ingredient added to the cooking pot"); _IngredientAddedToCookingPotEvent.Invoke(cookedIngredient); } } }
private void OnIngredientAddedToCookingPot(object cookingStepData) { // Check if the ingredient matches and if it matches update the cooking step CookedIngredient cookedIngredient = (CookedIngredient)cookingStepData; // Checking if this was the ingredient cooked if (cookedIngredient != null && cookedIngredient.Ingredient == Ingredient) { // Also checking if all the ingredient steps are completed bool ingredientCompletelyCooked = false; foreach (var cookingStepIcon in CookingStepsIcon) { cookingStepIcon.ValidateAndUpdate(cookedIngredient.CookingMethod); ingredientCompletelyCooked = ingredientCompletelyCooked && cookingStepIcon.IsCompleted; } if (ingredientCompletelyCooked) { StartCoroutine(MarkAsCompletedDelay()); } } }