using System; using System.Collections.Generic; using UnityEngine; public class PlateKitchenObject : KitchenObject { public event EventHandler OnIngredientAdded; public class IngredientAddedEventArgs : System.EventArgs { public KitchenObjectSO KitchenObjectSO; } [SerializeField] private List validKitchenObjectSOList; private List kitchenObjectSOList; private void Awake() { kitchenObjectSOList = new(); } public bool TryAddIngredient(KitchenObjectSO kitchenObjectSO) { if (!validKitchenObjectSOList.Contains(kitchenObjectSO)) { // Debug.Log("Not a valid ingredient"); return false; } if (kitchenObjectSOList.Contains(kitchenObjectSO)) { // Debug.Log("Ingredient is already on the plate!"); return false; } kitchenObjectSOList.Add(kitchenObjectSO); // Debug.Log("Ingredient is added to the plate."); OnIngredientAdded?.Invoke(this, new() { KitchenObjectSO = kitchenObjectSO }); return true; } public List GetKitchenObjectSOList() { return kitchenObjectSOList; } }