using HurricaneVR.Framework.Weapons.Guns;
using TMPro;
using UnityEngine;

public class WeaponCountAmmoUI : MonoBehaviour
{
    [SerializeField] private HVRGunBase gun;
    [SerializeField] private TMP_Text countText;

    private int cachedCount = -1;
    private void Update()
    {
        var count = 0;
        if (gun != null && gun.Ammo != null)
        {
            count = gun.Ammo.CurrentAmmoCount;
        }

        if (count != cachedCount)
        {
            cachedCount = count;
            countText.text = count.ToString();
        }
    }
}
