using UnityEngine;

/// <summary>
/// GAME 1303 Tier 3 — A fuel can. Sprite + trigger collider + this. Player must have FuelSystem.
/// </summary>
[RequireComponent(typeof(Collider2D))]
public class FuelPickup : MonoBehaviour
{
    public float amount = 30f;
    public string sfxName = "collect";
    public bool bob = true;

    private Vector3 start;
    void Reset() { GetComponent<Collider2D>().isTrigger = true; }
    void Start() { start = transform.position; }
    void Update() { if (bob) transform.position = start + Vector3.up * Mathf.Sin(Time.time * 2f) * 0.15f; }

    void OnTriggerEnter2D(Collider2D other)
    {
        var fuel = other.GetComponentInParent<FuelSystem>();
        if (fuel == null) return;
        fuel.Refill(amount);
        AudioManager.Instance?.PlaySFX(sfxName);
        Destroy(gameObject);
    }
}