KitchenChaos/Assets/Scripts/PlateKitchenObject.cs

46 lines
1.1 KiB
C#

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