using System; using UnityEngine; public class Gem : MonoBehaviour, IItem { public static event Action OnGemCollected; public int value = 5; private bool collected = false; public void Collect() { if (collected) return; // Prevent double collection collected = true; OnGemCollected?.Invoke(value); SoundEffectManager.Play("Gem"); FindFirstObjectByType()?.NotifyObjectDestroyed(gameObject); Destroy(gameObject); } }