using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InteractableItem : MonoBehaviour
{


	public string craftableName;
	public bool canAcceptItems = false;
    public bool CanPutInInventory = false;
    public bool DontDestroyOnPickup = false;
    public Item InventoryItem;

    public delegate void ItemPickedUp();
    public event ItemPickedUp OnItemPickup;

    public virtual void Start()
	{
		foreach (var i in GameManager.instance.itemRegister)
		{
			if(i.Name == craftableName)
			{
				canAcceptItems = i.IsCraftable;
			}
		}
	}

    public void PickUpItem()
    {
        if(OnItemPickup != null)
        {
            OnItemPickup();
        }
    }
	/// <summary>
	/// Calls if player drags over an item but haven't relesed it yet
	/// </summary>
	/// <param name="item"></param>
	/// <returns></returns>
	public bool CanAcceptItem(Item item)
	{
		Debug.Log(canAcceptItems + " -- " + IsItemNeeded(item));
		return canAcceptItems && IsItemNeeded(item);
	}

	/// <summary>
	/// Process incoming item from player, if it can be accepted
	/// </summary>
	/// <param name="item"></param>
	public virtual void TakeItem(Item item)
	{
		Debug.Log("TakeIteem");
	}

	/// <summary>
	/// separate check if item needed based on craft formula and current state of fire
	/// </summary>
	/// <param name="item"></param>
	/// <returns></returns>
	public virtual bool IsItemNeeded(Item item)
	{
		return true;
		//if (!canAcceptItems) return false;

	}
}

[Serializable]
public class InteractableItemSlider
{
	public string name;
	public int amount;
	public GameObject[] prefabs;
}

