(Feat) Add Build
This commit is contained in:
@@ -55,7 +55,8 @@ namespace Ashwild.Inventory
|
||||
{
|
||||
// Visual setup that does not need the player.
|
||||
for (int i = 0; i < hotbarSlot.Length; i++)
|
||||
hotbarSlot[i].Initialize(i, InventoryUI.OnSwapRequested, OnSlotClicked, OnSlotHoverEnter, OnSlotHoverExit);
|
||||
hotbarSlot[i].Initialize(SlotContainer.Inventory, i,
|
||||
InventoryUI.HandleSlotDrop, OnSlotClicked, OnSlotHoverEnter, OnSlotHoverExit);
|
||||
|
||||
transform.localScale = Vector3.one * idleScale;
|
||||
if (canvasGroup != null)
|
||||
@@ -154,15 +155,27 @@ namespace Ashwild.Inventory
|
||||
ZoomOut();
|
||||
}
|
||||
|
||||
private void OnSlotClicked(int index, bool rightClick)
|
||||
/// <summary>
|
||||
/// Right-click on a hotbar slot: a quick deposit into the open chest, otherwise the slot context
|
||||
/// menu (only while the inventory window is open — the hotbar must not pop a menu during play).
|
||||
/// </summary>
|
||||
private void OnSlotClicked(SlotContainer container, int index, bool rightClick)
|
||||
{
|
||||
if (rightClick && PlayerEvents.IsInventoryOpen)
|
||||
if (!rightClick) return;
|
||||
|
||||
if (PlayerEvents.IsChestOpen)
|
||||
{
|
||||
if (contextMenu != null)
|
||||
contextMenu.Show(index);
|
||||
else
|
||||
inventory.UseItem(index);
|
||||
if (InventoryUI.Instance != null)
|
||||
InventoryUI.Instance.RequestQuickTransfer(SlotContainer.Inventory, index);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PlayerEvents.IsInventoryOpen) return;
|
||||
|
||||
if (contextMenu != null)
|
||||
contextMenu.Show(index);
|
||||
else
|
||||
inventory.UseItem(index);
|
||||
}
|
||||
|
||||
private void OnSlotChanged(int index)
|
||||
@@ -173,11 +186,12 @@ namespace Ashwild.Inventory
|
||||
|
||||
/// <summary>
|
||||
/// Shows the shared description panel for a hovered hotbar slot, but only while the inventory
|
||||
/// is open — during normal play the hotbar must not pop a description. The duration bar
|
||||
/// reflects the item's remaining uses/durability.
|
||||
/// is open and no chest is open (chest mode hides the description entirely) — during normal play
|
||||
/// the hotbar must not pop a description. The duration bar reflects the item's remaining uses.
|
||||
/// </summary>
|
||||
private void OnSlotHoverEnter(int index)
|
||||
private void OnSlotHoverEnter(SlotContainer container, int index)
|
||||
{
|
||||
if (PlayerEvents.IsChestOpen) return;
|
||||
if (hoverDescription == null || inventory == null || !PlayerEvents.IsInventoryOpen) return;
|
||||
|
||||
InventorySlot slot = inventory.GetSlot(index);
|
||||
@@ -187,13 +201,7 @@ namespace Ashwild.Inventory
|
||||
return;
|
||||
}
|
||||
|
||||
ItemData item = slot.ItemData;
|
||||
bool hasDuration = item.HasUses;
|
||||
float fill = hasDuration ? (float)slot.CurrentUses / item.MaxUses : 0f;
|
||||
string durationText = hasDuration ? $"{slot.CurrentUses} / {item.MaxUses}" : string.Empty;
|
||||
|
||||
hoverDescription.Show(new ItemDescriptionView(
|
||||
item.Icon, item.ItemName, item.Description, hasDuration, fill, durationText));
|
||||
hoverDescription.Show(ItemDescriptionView.From(slot));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user