This repository has been archived on 2025-03-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
mojo-kitchen-chaos/Assets/Scripts/PlateKitchenObject.cs

46 lines
1.1 KiB
C#

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