47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using ScriptableObjects;
|
|
using UnityEngine;
|
|
|
|
namespace Counters {
|
|
public class ClearCounter : BaseCounter {
|
|
[SerializeField] private KitchenObjectSO kitchenObjectSo;
|
|
|
|
public override void Interact(Player player) {
|
|
if (!HasKitchenObject()) {
|
|
// Debug.Log("There is no KitchenObject here");
|
|
if (player.HasKitchenObject()) {
|
|
// Debug.Log("Player is putting KitchenObject to ClearCounter");
|
|
player.GetKitchenObject().SetKitchenObjectParent(this);
|
|
player.ClearKitchenObject();
|
|
}
|
|
else {
|
|
// Debug.Log("Player not carrying anything");
|
|
}
|
|
}
|
|
else {
|
|
// Debug.Log("There is a KitchenObject");
|
|
if (player.HasKitchenObject()) {
|
|
if (player.GetKitchenObject().TryGetPlate(out PlateKitchenObject plateKitchenObject)) {
|
|
// Debug.Log("Player is holding a plate");
|
|
if (plateKitchenObject.TryAddIngredient(GetKitchenObject().GetKitchenObjectSO())) {
|
|
GetKitchenObject().DestroySelf();
|
|
}
|
|
}
|
|
else {
|
|
// Debug.Log("Player is carrying something but not a plate");
|
|
if (GetKitchenObject().TryGetPlate(out plateKitchenObject)) {
|
|
// Debug.Log("ClearCounter is holding a plate");
|
|
if (plateKitchenObject.TryAddIngredient(player.GetKitchenObject().GetKitchenObjectSO())) {
|
|
player.GetKitchenObject().DestroySelf();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
// Debug.Log("Player is taking KitchenObject from ClearCounter");
|
|
GetKitchenObject().SetKitchenObjectParent(player);
|
|
ClearKitchenObject();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |