using UnityEngine;

public class Collectible : MonoBehaviour
{
    [SerializeField] private bool collected;

    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("[접촉] " + other.name);

        if (collected || !other.CompareTag("Player"))
        {
            Debug.Log("[중단] 이미 수집했거나 Player Tag가 아닙니다.");
            return;
        }

        if (!other.TryGetComponent(out PlayerProgress progress))
        {
            Debug.Log("[중단] PlayerProgress가 없습니다.");
            return;
        }

        collected = true;
        progress.AddCollectible();
        Debug.Log("[수집] Collectible 비활성화");
        gameObject.SetActive(false);
    }
}