KitchenChaos/Assets/Scripts/Counters/ClearCounter.cs

57 lines
1.5 KiB
C#

using UnityEngine;
public class ClearCounter : BaseCounter, IKitchenObjectParent
{
public KitchenObjectSO KitchenObjectSO { get; set; }
public override void Interact(Player player)
{
if (KitchenObject == null)
{
// Debug.Log("There is no KitchenObject here");
if (player.KitchenObject != null)
{
//Debug.Log($"Player is putting {player.KitchenObject.KitchenObjectSO.objectName} to ClearCounter");
player.KitchenObject.SetKitchenObjectParent(this);
player.KitchenObject = null;
}
else
{
Debug.Log("Player not carrying anything");
}
}
else
{
// Debug.Log("There is a KitchenObject");
if (player.KitchenObject != null)
{
if (player.KitchenObject.TryGetPlate(out PlateKitchenObject plateKitchenObject))
{
// Debug.Log("Player is holding a plate");
if (plateKitchenObject.TryAddIngredient(KitchenObject.KitchenObjectSO))
{
KitchenObject.DestroySelf();
}
}
else
{
// Debug.Log("Player is carrying something but not a plate");
if (KitchenObject.TryGetPlate(out plateKitchenObject))
{
// Debug.Log("ClearCounter is holding a plate");
if (plateKitchenObject.TryAddIngredient(player.KitchenObject.KitchenObjectSO))
{
player.KitchenObject.DestroySelf();
}
}
}
}
else
{
Debug.Log("Player is taking KitchenObject from ClearCounter");
KitchenObject.SetKitchenObjectParent(player);
KitchenObject = null;
}
}
}
}