mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-05 13:25:54 +00:00
Update Weapon in status
This commit is contained in:
parent
8f9e4f0bb9
commit
83d3cc7835
10 changed files with 45 additions and 15 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Resources;
|
||||
|
||||
public partial class StatusMenu : PanelContainer
|
||||
|
|
@ -7,11 +8,15 @@ public partial class StatusMenu : PanelContainer
|
|||
[Export] public StringName HealthExpansionName { get; private set; }
|
||||
|
||||
[Export] public StringName ShieldExpansionName { get; private set; }
|
||||
|
||||
//[Export] public ItemsDatabase ItemsDatabase { get; private set; }
|
||||
|
||||
[Export] public Button HealthExpansionCounter { get; private set; }
|
||||
|
||||
[Export] public Button ShieldExpansionCounter { get; private set; }
|
||||
|
||||
[Export] public Button WeaponButton { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CallDeferred(MethodName.InitializeDeferred);
|
||||
|
|
@ -31,6 +36,23 @@ public partial class StatusMenu : PanelContainer
|
|||
ShieldExpansionCounter.Text = $"x{shieldExpansions}";
|
||||
|
||||
InventoryManager.Instance.ItemAdded += InstanceOnItemAdded;
|
||||
|
||||
InventoryManager.Instance.WeaponEquip += InstanceOnWeaponEquip;
|
||||
}
|
||||
|
||||
private void InstanceOnWeaponEquip(string itemKey)
|
||||
{
|
||||
//var weaponData = ItemsDatabase.GetLootItem(itemKey);
|
||||
|
||||
var succ = InventoryManager.Instance.TryGetItem(itemKey, out var item);
|
||||
if (!succ)
|
||||
{
|
||||
GD.Print($"Could not get item {itemKey}");
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponButton.Text = item.Item.ShortName;
|
||||
WeaponButton.Icon = item.Item.InventorySprite;
|
||||
}
|
||||
|
||||
private void InstanceOnItemAdded(LootItem item, int currentamount)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue