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

/// <summary>
/// Simple pickup behaviour.  Requires a collider.
/// </summary>
[RequireComponent(typeof(Collider))]
public class Pickup : MonoBehaviour
{
    //reference back to the ScriptableObject InventoryItem
    public InventoryItem item;

    //which inventory do we go back to?
    public Inventory inventory;

    private void Start()
    {
        //Be lazy and just grab the first inventory we find if not set manually
        if (inventory == null)
            inventory = FindObjectOfType<Inventory>();
    }

    //Add item to inventory when the object is clicked
    private void OnMouseUp()
    {
        if(inventory != null)
        {
            inventory.AddItem(item);
            Destroy(gameObject);
        }
    }
}
