using UnityEngine;
using System.Collections;

public class SlotItemCollider : MonoBehaviour {
    private Slot slot;

    void Start()
    {
        slot = this.gameObject.GetComponent<Slot>();
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        if (slot == null)
            return;

        if (slot.item != null)
        {
            //return;
        }

        Item otherItem = other.gameObject.GetComponent<Item>();
        if (otherItem == null)
            return;

        if (!otherItem.slots.Contains(slot))
            otherItem.slots.Add(slot);


        //print(GameObject.FindObjectOfType<Person>().checkRituals());
    }

    void OnTriggerExit2D(Collider2D other)
    {
        if (slot == null)
            return;

        if (slot.item == null)
            return;

        Item otherItem = other.gameObject.GetComponent<Item>();
        if (otherItem != null)
            otherItem.slots.Remove(slot);

        if (otherItem != slot.item)
            return;

        slot.item = null;

        
        //print(GameObject.FindObjectOfType<Person>().checkRituals());
    }
}
