KitchenChaos/Assets/Scripts/PlateKitchenObject.cs

36 lines
1.2 KiB
C#

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