using System; using System.Collections.Generic; using UnityEngine; public class PlateKitchenObject : KitchenObject { [SerializeField] private List validKitchenObjectSOList; private List kitchenObjectSOList; protected override void Awake() { base.Awake(); kitchenObjectSOList = new List(); } public event EventHandler OnIngredientAdded; 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 IngredientAddedEventArgs{ KitchenObjectSO = kitchenObjectSO }); return true; } public List GetKitchenObjectSOList() { return kitchenObjectSOList; } public class IngredientAddedEventArgs : EventArgs { public KitchenObjectSO KitchenObjectSO; } }