mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 00:35:54 +00:00
graphics and ammo counting
This commit is contained in:
parent
7548cf7d84
commit
dfe936461e
11 changed files with 45 additions and 35 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue