graphics and ammo counting

This commit is contained in:
MaddoScientisto 2025-03-06 21:16:04 +01:00
commit dfe936461e
11 changed files with 45 additions and 35 deletions

View file

@ -37,13 +37,31 @@ public partial class WeaponAmmoCounter : Container
return;
}
if (InventoryManager.Instance.TryGetItem(item.WeaponData.AmmoKey, out var ammoItem))
{
AmmoIcon.Texture = ammoItem.Item.InventorySprite;
}
else
{
AmmoIcon.Hide();
}
//AmmoIcon.Texture = InventoryManager.Instance.
UpdateCounter();
// Register this only if there's ammo
InventoryManager.Instance.TotalAmmoChanged += (ammoKey, count) =>
{
if (ammoKey != Item.WeaponData.AmmoKey) return;
TotalAmmoLabel.Text = count.ToString();
};
InventoryManager.Instance.TotalAmmoChanged += OnInstanceOnTotalAmmoChanged;
}
private void OnInstanceOnTotalAmmoChanged(StringName ammoKey, int count)
{
if (ammoKey != Item.WeaponData.AmmoKey) return;
TotalAmmoLabel.Text = count.ToString();
}
public void Delete()
{
InventoryManager.Instance.TotalAmmoChanged -= OnInstanceOnTotalAmmoChanged;
QueueFree();
}
private void UpdateCounter()