KitchenChaos/Assets/Scripts/PlateKitchenObject.cs

36 lines
1.1 KiB
C#

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