using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlateKitchenObject : KitchenObject { public event EventHandler OnIngreedientAdded; public class OnIngreedientAddedEventArgs : EventArgs { public KitchenObjectSO KitchenObjectSO; } [SerializeField] private List validKitchenObjectSOList; private List kitchenObjectSOList; private void Awake() { kitchenObjectSOList = new List(); } public bool TryAddIngreedient(KitchenObjectSO kitchenObjectSO) { if (!validKitchenObjectSOList.Contains(kitchenObjectSO)) { // Not a valid ingreedient return false; } if (kitchenObjectSOList.Contains(kitchenObjectSO)) { return false; } else { kitchenObjectSOList.Add(kitchenObjectSO); OnIngreedientAdded?.Invoke(this, new OnIngreedientAddedEventArgs { KitchenObjectSO = kitchenObjectSO, }); return true; } } public List GetKitchenObjectSOList() { return kitchenObjectSOList; } }